W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

Re: Problems with Simple XML Validation

From: Rahul Srivastava <Rahul.Srivastava@sun.com>
Date: Wed, 5 Dec 2001 13:31:22 +0000 (Asia/Calcutta)
Message-Id: <200112050804.fB584wh07293@blr-root.India.Sun.COM>
To: JKim@orbitz.com, eddie@allette.com.au
Cc: xmlschema-dev@w3.org, Rahul.Srivastava@sun.com, Ravin.Shah@morganstanley.com, ychiu@orbitz.com, wshort@orbitz.com
> Eddie Robertsson wrote...
>
> > JKim wrote...
> > 
> > I have added a default namespace so that my xsd file now looks like this:
> >
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > targetNamespace="AnotherTestSpace"
> > xmlns="AnotherTestSpace"
> > elementFormDefault="qualified"
> > >

Check the namespace you are using for prefix xsd. My guess is it should be 
"http://www.w3.org/2000/10/XMLSchema" instead of 
"http://www.w3.org/2001/XMLSchema" for xerces-j-1.3.0

Hope this helps.

Cheers,
Rahul.

> >
> > <xsd:element name="shipOrder" type="order"/>
> > <xsd:complexType name="shipAddress">
> > <xsd:sequence>
> > <xsd:element   name="name"      type="xsd:string"/>
> > <xsd:element   name="street"    type="xsd:string"/>
> > <xsd:element   name="address"   type="xsd:string"/>
> > <xsd:element   name="country"   type="xsd:string"/>
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > <xsd:complexType name="cdItem">
> > <xsd:sequence>
> > <xsd:element   name="title"     type="xsd:string"/>
> > <xsd:element   name="quantity"  type="xsd:positiveInteger"/>
> > <xsd:element   name="price"     type="xsd:decimal"/>
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > <xsd:complexType name="cdItems">
> > <xsd:sequence>
> > <xsd:element   name="item"      type="cdItem"/>
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > <xsd:complexType name="order">
> > <xsd:sequence>
> > <xsd:element   name="shipTo"    type="shipAddress"/>
> > <xsd:element   name="items"     type="cdItems"/>
> > </xsd:sequence>
> > </xsd:complexType>
> > </xsd:schema>
> 
> Looks good!
> 
> > Here are my two attempts at modifying my xml file:
> >
> > Attempt 1:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <foo:shipOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="AnotherTestSpace order_schema.xsd"
> > xmlns:foo="AnotherTestSpace"
> > >
> > <shipTo>
> > <name>Tove Svendson</name>
> > <street>Ragnhildvei 2</street>
> > <address>4000 Stavanger</address>
> > etc...
> 
> No, this won't work. Since you have elementFormDefault="qualified" in your 
schema all
> elements in the instance document will have to be qualified with a namespace. 
In the
> above its only the shipOrder element that is qualified and the rest of the 
elements
> are unqualified.
> 
> > Attempt 2:
> > <?xml version="1.0" encoding="UTF-8"?>
> > <shipOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="AnotherTestSpace order_schema.xsd"
> > xmlns="AnotherTestSpace"
> > >
> > <shipTo>
> > <name>Tove Svendson</name>
> > <street>Ragnhildvei 2</street>
> > <address>4000 Stavanger</address>
> > etc...
> 
> This should work though. It works fine in all the validators I've tested with 
(XML
> Spy, XSV and Xerces 2 beta).
> 
> > In each case I get the following error:
> >
> > [Error] simple.xml:5:2: General Schema Error: Grammar with uri 2:
> > AnotherTestSpace , can not found.
> >
> > In addition I still get the other errors from before:
> >
> > [Error] simple.xml:5:2: Element type "shipOrder" must be declared.
> > [Error] simple.xml:6:9: Element type "shipTo" must be declared.
> > etc...
> >
> > I am using Xerces 1.3.0's SAXCount parser.
> > I verified that the xsd file is in fact named order_schema.xsd,
> > and that it exists in the same directory as my xml file.  I must be missing
> > something fundamental which I don't know about.
> 
> I'd say it's a bug in Xerces 1.3.0.
> 
> Cheers,
> /Eddie
> 
> 
Received on Wednesday, 5 December 2001 03:05:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT