S
Sascha Hennig
Hi.
My problem is that i parse an xml-document and validate it against a
schema. but the schema has multiple other schemas included (i'm using
"include" not "import" because all schemas using the same namespace).
and the sax parser (from xerces) can't find these schemas, because he
is obviously searching in the wrong directory - in fact in the
dirctory of the application, not in the directory of the including
schema. the path, within the "include" attribute is given relativ to
the including schema.
i'm using java 1.3.1 and have tried different xerces versions. With
xerces 2.0.0 and higher, the sax parser seems not to validate at all.
xerces 1.4.4 do validate but doesn't find the included schemas.
here is the java code:
SAXParser saxParser = new SAXParser();
saxParser.setContentHandler(handler);
saxParser.setErrorHandler(handler);
InputStream ioStream =null;
try
{
saxParser.setFeature
("http://xml.org/sax/features/validation",true);
saxParser.setFeature
("http://apache.org/xml/features/validation/schema", true);
saxParser.setFeature
("http://apache.org/xml/features/validation/schema-full-checking",
true);
InputStreamReader inputstream = new
InputStreamReader(m_oStream,"UTF-8");
InputSource inputsource = new InputSource(inputstream);
saxParser.parse(inputsource);
heres a fragment of the including schema (Reply.xsd) (against this an
xml file is validated)
<xs:schema targetNamespace="www.interface.de" xmlns="www.interface.de"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="./KOM.xsd"/>
<xs:include schemaLocation="./Ort.xsd"/>
<xs:element name="Reply">
<xs:complexType name="reply">
<xs:choice>
<xs:sequence>
<xs:element name="AKOM" type="auditkom" minOccurs="0"/>
<xs:element name="AOrt" type="auditort" minOccurs="0"/>
......
these to schemas (KOM, Ort) were not found, when the parser validates
an xml file. all schemas are in the same dirctory (an other then the
application directory). and the absolut path to the Reply.xsd (which
is found) is given in the xml file.
can't sax from xerces handle "include" from xml-schema? or is there a
version wich can?
Thanks & Regards,
Sascha
My problem is that i parse an xml-document and validate it against a
schema. but the schema has multiple other schemas included (i'm using
"include" not "import" because all schemas using the same namespace).
and the sax parser (from xerces) can't find these schemas, because he
is obviously searching in the wrong directory - in fact in the
dirctory of the application, not in the directory of the including
schema. the path, within the "include" attribute is given relativ to
the including schema.
i'm using java 1.3.1 and have tried different xerces versions. With
xerces 2.0.0 and higher, the sax parser seems not to validate at all.
xerces 1.4.4 do validate but doesn't find the included schemas.
here is the java code:
SAXParser saxParser = new SAXParser();
saxParser.setContentHandler(handler);
saxParser.setErrorHandler(handler);
InputStream ioStream =null;
try
{
saxParser.setFeature
("http://xml.org/sax/features/validation",true);
saxParser.setFeature
("http://apache.org/xml/features/validation/schema", true);
saxParser.setFeature
("http://apache.org/xml/features/validation/schema-full-checking",
true);
InputStreamReader inputstream = new
InputStreamReader(m_oStream,"UTF-8");
InputSource inputsource = new InputSource(inputstream);
saxParser.parse(inputsource);
heres a fragment of the including schema (Reply.xsd) (against this an
xml file is validated)
<xs:schema targetNamespace="www.interface.de" xmlns="www.interface.de"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="./KOM.xsd"/>
<xs:include schemaLocation="./Ort.xsd"/>
<xs:element name="Reply">
<xs:complexType name="reply">
<xs:choice>
<xs:sequence>
<xs:element name="AKOM" type="auditkom" minOccurs="0"/>
<xs:element name="AOrt" type="auditort" minOccurs="0"/>
......
these to schemas (KOM, Ort) were not found, when the parser validates
an xml file. all schemas are in the same dirctory (an other then the
application directory). and the absolut path to the Reply.xsd (which
is found) is given in the xml file.
can't sax from xerces handle "include" from xml-schema? or is there a
version wich can?
Thanks & Regards,
Sascha