[jdom-interest] Feature Request

Jeremy.Prellwitz at siras.com Jeremy.Prellwitz at siras.com
Fri Feb 20 06:29:24 PST 2004

I think this is a correct statement.

>If I understand this correctly, if you don't use nekohtmlXni.jar, then
>you won't have the problem?

My work around is to set the system property as described in step 1.  And
then to un-set the property immediately after i've the parser has been
created, so that the NekoHTML code will still work properly, and get its
HTML parser confirguration from step 3.

According to the xml.apache.org website:

The DOM and SAX parsers decide which parser configuration to use in the
following order:

1.) First, the org.apache.xerces.xni.parser.XMLParserConfiguration system
property is queried for the class name of the parser configuration.

2.) Next, if a file called xerces.properties exists in the lib subdirectory
of the JRE installation and the
org.apache.xerces.xni.parser.XMLParserConfiguration property is defined it,
then its value will be read from the file.

3.) Next, the org.apache.xerces.xni.parser.XMLParserConfiguration file is
requested from the META-INF/services/ directory. This file contains the
class name of the parser configuration.

4.) Finally, the org.apache.xerces.parsers.XML11Configuration is used as
the default parser configuration.

----- Forwarded by Jeremy Prellwitz/Siras on 02/20/2004 06:30 AM -----
             02/19/2004 06:56          jdom-interest at jdom.org              
             PM                                                         cc 
                                       Re: [jdom-interest] Feature Request 
                                       (Document link: Jeremy Prellwitz)   

This sounds like a good description of the problem.  Because i'm using
NekoHTML to parse HTML documents, and in the same webapp, i also need to
parse XML documents.

To clarify, i do have a work around, and that is to set a Java runtime
system property.  Its just not a clean solution, and I think offering a way
to pass in an XMLReader class that can be instantiated with the
StandardParserConfiguration class would be a good way to go.


             Elliotte Rusty                                                
             <elharo at metalab.u                                          To 
             nc.edu>                   "Chris B." <chris at tech.com.au>      
             02/19/2004 06:26          Jeremy.Prellwitz at siras.com,         
             PM                        jdom-interest at jdom.org              
                                       Re: [jdom-interest] Feature Request 

At 11:40 AM +1100 2/20/04, Chris B. wrote:
>Nekohtml has some information on making it play nice with other parsers.
>I'm not an expert on the internals of sax etc, but wouldn't the
>Right Thing (tm) for have been for NekoHtml to have provided an
>XMLReader implementation, which could then be plugged into JDOM?

The problem here is a design flaw in Xerces. It assumes you will only
ever want one parser configuration in the same VM. (This is not an
XMLReader. This is an internal, non-standard class in Xerces.) Thus
once the parser configuration has been set through the appropriate
system property or default, you're stuck with it for all your Xerces
parsing. Possibly you could change the system property in your code,
but I'm not sure whether that would work or not.

   Elliotte Rusty Harold
   elharo at metalab.unc.edu
   Effective XML (Addison-Wesley, 2003)


More information about the jdom-interest mailing list