xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From crueg...@speakeasy.net
Subject problem using XML schema w/ Xerces 2
Date Mon, 04 Nov 2002 16:07:30 GMT

Situation:
I'm using Xerces 2.0 and trying to parse/validate
an XML document against a schema. Here are the xml and
schema files:

foo.xsd:
--------
<?xml version="1.0"?>
<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified">

<xsd:element name="request" type="requestType" />

<xsd:simpleType name="TF">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="T" />
    <xsd:enumeration value="F" />
  </xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="requestType">
  <xsd:sequence>
    <xsd:element name="clientID" type="xsd:string"/>
    <xsd:element name="password" type="xsd:string"/>
    <xsd:element name="flag"     type="TF"/>
  </xsd:sequence>
</xsd:complexType>
</xsd:schema>

foo.xml:
-------
<?xml version="1.0" encoding="UTF-8"?>
<request
  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:noNamespaceSchemaLocation='foo.xsd'>

<clientID>ABD</clientID>
<password>ABD</password>
<flag>Green</flag>
</request>

I create the Parser using JAXP, and the document handler interface:

SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
parserFactory.setValidating(true);
SAXParser theParser = parserFactory.newSAXParser();

I call parse passing an InputSource created from "foo.xml"
and and a class implementing the DefaultHandler interface.

Here is the eror I get:

error() LINE: 1
org.xml.sax.SAXParseException: Document is invalid: no grammar found.
error() LINE: 1
org.xml.sax.SAXParseException: Document root element "request", must match DOCTYPE root "null".

Any ideas what I am doing wrong?
Thanks




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Mime
View raw message