Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schema

M

Markus

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
 
M

Markus

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top