[jdom-interest] SAXBuilder.setProperty() to schemaLocation

Laurent Bihanic laurent.bihanic at atosorigin.com
Wed Mar 12 00:59:49 PST 2003


Hi,

You've just hit Xerces bug #16528. This bug appears when using the Xerces 
proprietary properties for schema validation on Xerces 2.3.0.
See http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16528 for details.

There are 2 possible ways to work around this bug:
1. Revert to Xerces 2.2.1
2. Switch to JAXP 1.2 properties for schema validation. Please refer to 
http://lists.denveronline.net/lists/jdom-interest/2003-February/012086.html 
that details the extra steps required to make this work with JDOM's SAXBuilder.

Laurent


Brian Ales wrote:
> Hi
> 
> I'm not sure if this is a JDOM issue or a Xerces issue, but I'm getting the following error when I try to use the JDOM SAXBuilder setProperty() method to get to my Xerces parser to set a schemaLocation for a namespace.  
> 
> Here's the code (it's the setProperty() call that breaks): 
> 
> SAXBuilder builder =new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
> builder.setFeature("http://apache.org/xml/features/validation/schema", true);
> builder.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
>                     "http://www.xbrl.org/2001/XLink/xbrllinkbase http://www.xbrl.org/2001/xbrl-linkbase.xsd");
> 
> I know the namespace/schemaLocation strings are valid because if I comment out setProperty() and paste them into the document I'm trying to validate itself as the schemaLocation attribute of the root, validation succeeds.  However, I think the spec says that's just a 'hint' for the parser, and also some documents I'll be seeing only have the filename not the complete url of the schema, so I'd like to force it like this.  According to some code I got from JDOM, the above should work.  However, when I run my app I get the following trace:
> 
>  
> 
> java.lang.ClassCastException
>         at org.apache.xerces.impl.xs.XMLSchemaLoader.processExternalHints(Unknown Source)
>         at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown Source)
>         at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown Source)
>         at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
>         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:371)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:814)
>         at JDOMLinkBaseSAXViewer.main(JDOMLinkBaseSAXViewer.java:143)
> 
> 
> Any help?
> 
>  
> 
> Thnaks in advance, 
> 
> Brian Ales




More information about the jdom-interest mailing list