When I try to parse this xml file:
<?xml version="1.0" encoding="UTF-8"?>
<myns:BOGUS xmlns:myns="http://www.bogus.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bogus.com file://C:/xml/bogus.xsd">
<myns:FOO>
Yada yada yada
</myns:FOO>
</myns:BOGUS>
with this schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.bogus.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:myns="http://www.bogus.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="BOGUS">
<xs:complexType>
<xs:sequence>
<xs:element name="FOO" maxOccurs="unbounded">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="80"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
in Xerces 2.6.0 using these features:
org.apache.xerces.parsers.SAXParser saxParser;
...
saxParser.setFeature("http://xml.org/sax/features/validation", true);
saxParser.setFeature("http://xml.org/sax/features/validation/schema",
true);
...
I get this error:
Exception class: org.xml.sax.SAXParseException
Message: Document is invalid: no grammar found.
Line: 2
Column: 12
Any idea why? It works with other validating parsers, and has no problems if
the validation feature is turned off.
Thanks,
Thomas Cox
|