[jdom-interest] Using a DefaultJDOMFactory Subclass in 0.8
T.B. Pogie
pogietb at netscape.net
Tue Jun 11 06:05:37 PDT 2002
**This is a resend to correct the missing subject line.**
OK, I'm wrong. It *is* returning a CleanElement.
I ran the following:
SAXBuilder sb = new SAXBuilder();
JDOMFactory factory = new CustomJDOMFactory();
sb.setFactory(factory);
Document xmlDoc = sb.build(xmlFile);
System.out.println("root is " + xmlDoc.getRootElement().getClass.getName());
System.out.println("root name is " + xmlDoc.getRootElement().getName());
System.out.println("root ns is " + xmlDoc.getRootElement().getNamespace().toString());
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(filePath));
XMLOutputter out = new XMLOutputter();
out.output(xmlDoc,bw);
} catch {
...
}
The command line output is:
root is CleanElement
root name is document
root ns is [Namespace:prefix "" is mapped to URI ""]
But the xml file itself has a root of:
<document xmlns:"http://www.lotus.com/dxl" >
and each element has:
<item xmlns:" ">
TB Pogie
"Ken Rune Helland" <kenh at csc.no> wrote:
>[SNIP]
>> I don't think the
>> SAXBuilder is using the CustomJDOMFactory at all.
>
>Try this:
>
>SAXBuilder sb = new SAXBuilder();
>JDOMFactory factory = new CustomJDOMFactory();
>sb.setFactory(factory);
>Document xmlDoc = sb.build(xmlFile);
>
>CleanElement root = (CleanElement)xmlDoc.getRoot()
>
>If the element is not really a CleanElement it will
>trow an ClassCastException.
>
>
>KenR
>
>
>
>
__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop at Netscape! http://shopnow.netscape.com/
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
More information about the jdom-interest
mailing list