I'm trying to parse an XML document (root is called "myPlatform") against a
locally controlled schema file (.xsd).  What I'm not sure, is how to specify
the schema files to use since the main schema does an include of another
schema (<xs:include schemaLocation="basicTypes.xsd"/>)

The XML is described in a schema file called platform.xsd, which includes
the basicTypes.xsd.

I've set these features (via JDOM, but it's using Xerces under the hood):

      SAXBuilder saxBuilder = new SAXBuilder(true); // validate
   saxBuilder.setFeature("http://xml.org/sax/features/validation",true);

saxBuilder.setFeature("http://apache.org/xml/features/validation/schema",tru
e);

saxBuilder.setProperty("http://apache.org/xml/properties/schema/external-sch
emaLocation","file:///home/xml/schema/basicTypes.xsd
file:///home/xml/schema/platform.xsd");

I've tried the schemaLocations by not specifying the "file://" prefix and I
get the same error:

Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of element 'myPlatform'.
        at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
        at
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
Source)
        at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRoot
ElementHook(Unknown Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch(Unknown Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.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:455)

I'm sure the files are okay because they can be validated fine using XMLSPY.
I'm not just not sure how to tell the parser to use the locally defined
schema files.

Thanks,
David


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to