I hava an applet/application which can validate an XML.
But there are some problems because the schemaLocation
In the xml-file the schemaLocation = "mySchema.xsd".
But if I start my app in a browser as applet the parser searches on the
local drive for mySchema.xsd.
This is not really the problem beacause I found out, that I can set the
Property
"http://apache.org/xml/properties/schema/external-schemaLocation" to
"myNameSpace url_to_mySchema.xsd"
The problem occours because mySchema.xsd (which is not really my schema
;-) )includes some "sub-schemas" in that way:
mySchema.xsd
...
<xsd:include schemaLocation = "mySchema_a.xsd"/>
<xsd:include schemaLocation = "mySchema_b.xsd"/>
..
The parses found mySchema.xsd on the given URL but searches mySchema_a
and _b under local driver anyway. :-/
Does anybody know a solution to configure the parser to load all XSDs
from a given URL?
-> I'm using JDOM and Xerces.
Kind regards
Markus
Markus - 23 Nov 2005 14:41 GMT
Here is the (a better) solution:
//Creating a ErrorHandler
m_SAXErrorHandler = new SPSCSAXErrorHandler();
//Setting the parser
m_builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
//activate validation
m_builder.setValidation(a_b_validate);
//setting Errorhandler
m_builder.setErrorHandler(m_SAXErrorHandler);
//activate schema-validation
m_builder.setFeature("http://apache.org/xml/features/validation/schema",
a_b_validate);
m_builder.setFeature("http://apache.org/xml/features/validation/schema-full-checking",
a_b_validate);
m_builder.setFeature("http://xml.org/sax/features/validation",
a_b_validate);
//buidling document - all relative paths are relative to a_st_base
m_document = m_builder.build(a_inputStreamXML, a_st_base);
Markus