David,
You should specify your governing schema in an instance document (as opposed to 
code):

<root_node xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"; 
xsi:noNamespaceSchemaLocation = "file:///pathname/myPlatform.xsd">

where root_node is the name of your root element in myPlatform.xsd.

Note the 3 slashes after file:, very important.

Ed
-----Original Message-----
From: David Wall [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 07, 2004 4:36 PM
To: [EMAIL PROTECTED]
Subject: Validating with XML Schema using local schema files


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]


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

Reply via email to