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

Re: Problems with schemas - is it me, or xerces-j?

From: Eddie Robertsson <eddie@allette.com.au>
Date: Tue, 04 Sep 2001 09:44:00 +1000
Message-ID: <3B9415C0.5CF8EF36@allette.com.au>
To: johnsnelson@decisionsoft.com
CC: xmlschema-dev@w3.org
Hi John,

> I am trying to write a schema for a data format, and am using xerces-j
> to validate a document, as this is the target application. I have come
> accross a couple of problems, and I don't know whether xerces-j is
> wrong, or my understanding of XML Schema is wrong. I wonder if anyone
> can put me straight on this...

Both your schemas look correct to me and I believe this is a bug in
Xerces-j. I also tested this in XML Spy which also fails by saying that
the first example below is valid. The command line version of XSV (XSV
1.202/1.105 of 2001/08/30 16:12:04) correctly fail the first example and
finds no errors in the second example. This result is also seen in MSXML4.

Cheers,
/Eddie

>
>
> Thank you in advance,
>
> John
>
> Problem 1:
> ---------
>
> I am sure that this document should fail the schema, but it does not.
>
> bug1.xml:
>
> <?xml version='1.0'?>
>
> <blah xmlns="blah.com"
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
>       xsi:schemaLocation='blah.com bug1.xsd'>
>
>   <fredHolder name="holder1">
>     <fredHolder name="holder5"/>
>   </fredHolder>
>
>   <fredRef ref="holder3"/>
>
> </blah>
>
> bug1.xsd:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsd:schema
>  attributeFormDefault="unqualified"
>  elementFormDefault="qualified"
>  targetNamespace="blah.com"
>  xmlns="blah.com"
>  xmlns:blah="blah.com"
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >
>
> <xsd:element name="fredHolder">
>   <xsd:complexType>
>     <xsd:sequence>
>       <xsd:element ref="fredHolder" minOccurs="0"/>
>     </xsd:sequence>
>     <xsd:attribute name="name" type="xsd:string" use="required"/>
>   </xsd:complexType>
>
>   <xsd:unique name="myUnique">
>     <xsd:selector xpath="."/>
>     <xsd:field xpath="@name"/>
>   </xsd:unique>
> </xsd:element>
>
> <xsd:element name="blah">
>   <xsd:complexType>
>     <xsd:sequence>
>       <xsd:element ref="fredHolder"/>
>       <xsd:element name="fredRef">
>         <xsd:complexType>
>           <xsd:attribute name="ref" type="xsd:string"/>
>         </xsd:complexType>
>       </xsd:element>
>     </xsd:sequence>
>   </xsd:complexType>
>
>   <xsd:keyref name="myRef" refer="myKey">
>     <xsd:selector xpath="blah:fredRef"/>
>     <xsd:field xpath="@ref"/>
>   </xsd:keyref>
>
>   <xsd:key name="myKey">
>     <xsd:selector xpath=".//blah:fredHolder"/>
>     <xsd:field xpath="@name"/>
>   </xsd:key>
> </xsd:element>
>
> </xsd:schema>
>
> Problem 2:
> ---------
>
> I am sure that this document should pass, but it does not.
>
> bug2.xml:
>
> <?xml version='1.0'?>
>
> <fredHolder xmlns="blah.com"
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
>     xsi:schemaLocation='blah.com bug2.xsd'>
>   <fred name="alfred"/>
>   <fredHolder>
>     <fred name="alfred"/>
>   </fredHolder>
> </fredHolder>
>
> bug2.xsd:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsd:schema
>  attributeFormDefault="unqualified"
>  elementFormDefault="qualified"
>  targetNamespace="blah.com"
>  xmlns="blah.com"
>  xmlns:blah="blah.com"
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >
>
> <xsd:element name="fredHolder">
>   <xsd:complexType>
>     <xsd:choice maxOccurs="2">
>       <xsd:element name="fred">
>         <xsd:complexType>
>           <xsd:attribute name="name"/>
>         </xsd:complexType>
>       </xsd:element>
>       <xsd:element ref="fredHolder"/>
>     </xsd:choice>
>   </xsd:complexType>
>
>   <xsd:unique name="myUnique">
>     <xsd:selector xpath="./blah:fred"/>
>     <xsd:field xpath="@name"/>
>   </xsd:unique>
> </xsd:element>
>
> </xsd:schema>
>
> --
> John Snelson, Software Engineer       DecisionSoft Ltd.
> Telephone: +44-1865-203192            http://www.decisionsoft.com
Received on Wednesday, 3 October 2001 19:38:19 GMT

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