commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John La Barge" <jlaba...@jacent.com>
Subject Determining which parser to use, XercesParser or GenericParser in ParserFeatureSetterFactory
Date Fri, 07 Jul 2006 15:04:41 GMT
Hello, 
 
 
I am currently having a problem with commons-digester that seems to be
caused by the chosen method for determining whether to use the
XercesParser. The lines of code of interest are from
ParserFeatureSetterFactory and are as follows: 
 
 static {
        try{
            // Use reflection to avoid a build dependency with Xerces.
            Class versionClass = 
 
Class.forName("org.apache.xerces.impl.Version");
            isXercesUsed = true;
        } catch (Exception ex){
            isXercesUsed = false;
        }
    }
 
 
This causes a problem for me, because org.apache.xerces.impl.Version is
in my classpath, but I am using the Crimson parser, which is also in my
classpath and more proximate than the xerces jar. 
 
When the XercesParser class is selected it attempts to use features: 
 
 factory.setFeature(XERCES_DYNAMIC, true). 
 
where 

  protected static String XERCES_DYNAMIC = 
        "http://apache.org/xml/features/validation/dynamic";
 



But, this feature does not exist wih the crimson parser that is indeed
my chosen parser within my local classpath and I get an interesting
stack trace: 
 


2006-07-07 07:53:02,489 ERROR [org.apache.commons.digester.Digester]
Digester.getParser:
org.xml.sax.SAXNotRecognizedException: Feature:
http://apache.org/xml/features/validation/dynamic
        at
org.apache.crimson.parser.XMLReaderImpl.setFeature(XMLReaderImpl.java:21
3)
        at
org.apache.crimson.jaxp.SAXParserImpl.setFeatures(SAXParserImpl.java:143
)
        at
org.apache.crimson.jaxp.SAXParserImpl.<init>(SAXParserImpl.java:126)
        at
org.apache.crimson.jaxp.SAXParserFactoryImpl.newSAXParserImpl(SAXParserF
actoryImpl.java:113)
        at
org.apache.crimson.jaxp.SAXParserFactoryImpl.setFeature(SAXParserFactory
Impl.java:141)
        at
org.apache.commons.digester.parser.XercesParser.configureXerces(XercesPa
rser.java:185)
        at
org.apache.commons.digester.parser.XercesParser.newSAXParser(XercesParse
r.java:138)
        at
org.apache.commons.digester.ParserFeatureSetterFactory.newSAXParser(Pars
erFeatureSetterFactory.java:73)
        at
org.apache.commons.digester.Digester.getParser(Digester.java:682)
        at
org.apache.commons.digester.Digester.getXMLReader(Digester.java:891)
        at
org.apache.commons.digester.Digester.parse(Digester.java:1572)
        at
org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServl
et.java:738)
        at
org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.ja
va:687)
        at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)
        at javax.servlet.GenericServlet.init(GenericServlet.java:211)
        at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav
a:1091)
 
 So I have a XercesParser class trying to set a Feature on a
parserFactory it receives from the crimson api.

Please excuse my ignorance in asking why the
System.getProperty("org.xml.sax.driver") call couldn't be used instead? 

This all started when I moved a webapp that was humming along in tomcat
5.5 with struts 1.2.8 (which depends on commons-digester) to Jboss which
has an XercesImpl.jar in its lib/endorsed directory (thus making the
above referenced forName not throw an exception).  It may be drastic for
me to switch over to Xerces alltogether. Does anyone know of another
solution? 


Thanks in advance for anyone's help. And I apologize if my question is
not smart enough. 

John La Barge




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message