[jdom-interest] Using XSD schema to validate a JDOM tree
Laurent Bihanic
laurent.bihanic at atosorigin.com
Tue Sep 17 05:59:17 PDT 2002
Olivier Coppel wrote:
> I've read that there is a way to specify the name of the XSD schema directly
> in my program by using parser properties :
> 1) propertie "http://java.sun.com/xml/jaxp/properties/schemaLanguage" with
> value "http://www.w3.org/2001/XMLSchema"
> 2) propertie "http://java.sun.com/xml/jaxp/properties/schemaSource" with
> value "File(myXSDSchemaFile)"
This is new in JAXP 1.2
> First, I have to overload the protected method "configureParser(XMLReader
> parser, SAXHandler contentHandler)" of SAXBuilder by doing :
JDOM Beta 8 has introduced a SAXBuilder.setProperty to help avoiding this.
> But it doesn't work. It seems that only validation by DTD works but not with
> XSD schema.
Neither Xerces 1.4.x nor Xerces 2.1.0 support JAXP 1.2 and Crimson (included
in JDK) does not validate against schemas.
> Is there a way to solve this problem ?
While waiting for Xerces to support JAXP 1.2, you could use Xerces'
proprietary properties:
"http://apache.org/xml/properties/schema/external-SchemaLocation" and
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation".
Laurent
More information about the jdom-interest
mailing list