[jdom-interest] Using a DefaultJDOMFactory Subclass in 0.8

T.B. Pogie pogietb at netscape.net
Mon Jun 10 06:06:36 PDT 2002

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) {
 public CleanElement(Sting name, Namespace ns) {
public CleanElement(Sting name, String uri) {
public CleanElement(Sting name, String prefix, String uri) {

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();
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/

More information about the jdom-interest mailing list