[jdom-interest] Interesting problem

Blanton, Mike mikeb at cybersource.com
Tue Sep 12 10:09:38 PDT 2000


I've written a class that extends Document.  In that class, I have a
function called "createXMLFile", which basically takes a path, creates an
XML file from the extended document.  However, the main document has 2 root
nodes.
 
So, my code looks something like this:
 
public class ProductXMLDocument extends Document {
  public ProductXMLDocument() {
    super (new Element("root"));
    elemCatalog = new Element("catalog");
    this.setRootElement(elemCatalog);
  }
 
  public void createXMLFile(String _filePath) throws JDOMException,
IOException {
    FileOutputStream fos = new FileOutputStream(new File(_filePath,
"products.xml"));
    XMLOutputter xmlOut = new XMLOutputter();
    xmlOut.output(this, fos);
    fos.close(); // Is this necessary?
  }
}
 
When I look at the file, It adds the catalog node, then all of the products,
then another catalog node, then all of the products again.  Has anyone seen
this before?  I've tried taking the createXMLFile code out of the
ProductXMLDocument and put it in the code that calls it, but it yields the
same results.
 
Thanks.

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Michael Blanton
Architect
CyberSource Professional Services
 <http://www.cybersource.com/> www.cybersource.com 
 <mailto:mikeb at cybersource.com> mikeb at cybersource.com
(408) 359-2232

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20000912/330b5241/attachment.htm


More information about the jdom-interest mailing list