I mentioned 2 ways:
1. Provide the location of test.xsd. When setting the JAXP schemaSource
property, instead of opening a stream, use its physical location (a URI
string), or a File Object. This way, the parser knows how to resolve the
relative reference to test2.xsd.
2. Set an EntityResolver. You can set SAX EntityResolver on JAXP
DocumentBuilder.
HTH,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
[EMAIL PROTECTED]
Predrag Knezevic
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
g.de> cc:
Subject: Re: validation against
schema that imports other namespaces
08/12/2003 08:42
AM
Please respond to
xerces-j-user
> You need to either provide the location of test.xsd (which is used to
> resolve the relative reference to test2.xsd) (by using a string or input
> source instead of a stream), or you need to register an EntityResolver
(the
> javadoc [1] tells you what it's for and how to use it).[1]
>
http://xml.apache.org/xerces2-j/javadocs/api/org/xml/sax/EntityResolver.html
Ok, this is valid if I use SAX, but I want to use DOM parser and to
get a DOM tree at the end. The real problem about validation and schema
locations is when document instances are created somewhere else and they
have to be validated on some other places. In such situations,
schemaLocation attribute does not help much, because its value is
usually binded to some local files.
Therefore, I would like to have a possibility to specify the locations
of all needed schemas during run-time, so the parser could know where to
look for.
I have found property
http://apache.org/xml/properties/schema/external-schemaLocation, but it
is not JAXP compliant and it matches only schemaLocation attributes from
import elements, so it does not help in general.
Any idea?
Predrag
---------------------------------------------------------------------
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]