Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM and Catalogs

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: Michael Abato <mrabato AT earthlink.net>
  • Cc: norman.walsh AT sun.com, xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM and Catalogs
  • Date: Tue, 22 Mar 2005 14:28:12 -0500

I've tracked it down. This is absolutely due to a bug in the ResolvingXMLReader class. That class uses JAXP to create a SAXParser (always a mistake) and then forgets to make it namespace aware. That is,

public ResolvingXMLReader() {
super();
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
SAXParser parser = spf.newSAXParser();
setParent(parser.getXMLReader());
} catch (Exception ex) {
ex.printStackTrace();
}
}

/**
* Construct a new reader from the JAXP factory.
*
* <p>In order to do its job, a ResolvingXMLReader must in fact be
* a filter. So the only difference between this code and the filter
* code is that the constructor builds a new reader.</p>
*/
public ResolvingXMLReader(CatalogManager manager) {
super(manager);
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
SAXParser parser = spf.newSAXParser();
setParent(parser.getXMLReader());
} catch (Exception ex) {
ex.printStackTrace();
}
}


should be

public ResolvingXMLReader() {
super();
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
try {
SAXParser parser = spf.newSAXParser();
setParent(parser.getXMLReader());
} catch (Exception ex) {
ex.printStackTrace();
}
}

/**
* Construct a new reader from the JAXP factory.
*
* <p>In order to do its job, a ResolvingXMLReader must in fact be
* a filter. So the only difference between this code and the filter
* code is that the constructor builds a new reader.</p>
*/
public ResolvingXMLReader(CatalogManager manager) {
super(manager);
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
try {
SAXParser parser = spf.newSAXParser();
setParent(parser.getXMLReader());
} catch (Exception ex) {
ex.printStackTrace();
}
}


Better yet, this class should be rewritten to use XMLReaderFactory and not go anywhere near SAXParserFactory. I'm cc'ing Norm Walsh, and will file a bug in Apache's Jira as soon as I can dig up my password. In the meantime, XOM will work around this bug.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page