[jdom-interest] Using a DefaultJDOMFactory Subclass in 0.8

Frank Sauer Frank.Sauer at trcinc.com
Mon Jun 10 07:09:33 PDT 2002


What happens if in al factory methods you simply 
return new CleanElement(name) instead of calling
the constructors with the namesapce arguments?

Frank

-----Original Message-----
From: T.B. Pogie [mailto:pogietb at netscape.net] 
Sent: Monday, June 10, 2002 9:07 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Using a DefaultJDOMFactory Subclass in 0.8


I apologize if this is addressed elsewhere in this forum, the API or the FAQ's - I couldn't find it.

I have an extremely simple DefaultJDOMFactory subclass, calling an even simpler Element subclass. The Element subclass:

public class CleanElement extends Element {
 public CleanElement(String name) {
     super(name);
 }
 public CleanElement(Sting name, Namespace ns) {
     super(name);
 }
public CleanElement(Sting name, String uri) {
     super(name);
 }
public CleanElement(Sting name, String prefix, String uri) {
     super(name);
 }
}

The DefaultJDOMFactory subclass: 

public class CustomJDOMFactory extends DefaultJDOMFactory {  public Element element(String name) {
     return new CleanElement(name);
 }
public Element element(String name, Namespace ns) {
     return new CleanElement(name, ns);
 }
public Element element(String name, String uri) {
     return new CleanElement(name, uri);
 }
public Element element(String name, String prefix, String uri) {
     return new CleanElement(name, prefix, uri);
 }
}

The code used to call these subclasses is:

SAXBuilder sb = new SAXBuilder();
JDOMFactory factory = new CustomJDOMFactory(); sb.setFactory(factory); Document xmlDoc = sb.build(xmlFile);

The documents I'm reading in have a namespace declared in the root element that I want to strip out. Using the subclasses worked fine in 0.7. As soon as I switched to 0.8, however, the namespace is not being removed. I tried changing CustomJDOMFactory to only pass the name, not the namespace, to CleanElement but it doesn't help. I don't think the SAXBuilder is using the CustomJDOMFactory at all.

What are the changes to 0.8 that might be causing this and how can I code around it? 

Thanks very much.
TB Pogie


__________________________________________________________________
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/

_______________________________________________
To control your jdom-interest membership: http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com






More information about the jdom-interest mailing list