You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Thomas Cox <Th...@sas.com> on 2003/12/19 16:21:41 UTC
Validation feature problems
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
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Validation feature problems
Posted by Michael Glavassevich <mr...@apache.org>.
Hello Thomas,
Try specifying your schema location as 'file:///C:/xml/bogus.xsd'. I
believe the URI you have now will cause the parser to try to connect
via FTP to a non-existent host called 'C:'. I doubt that's what you
intended.
Hope that helps.
On Fri, 19 Dec 2003, Thomas Cox wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org