W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2005

Re: XML-Schema keyref & namespaces ??!

From: Kasimier Buchcik <K.Buchcik@4commerce.de>
Date: Fri, 11 Nov 2005 12:50:36 +0100
To: ezarakan@hsr.ch
Cc: ML-xml-schema-dev <xmlschema-dev@w3.org>
Message-Id: <1131709836.1272.20.camel@librax>

Hi,

On Fri, 2005-11-11 at 11:47 +0100, ezarakan@hsr.ch wrote:
> hallo everyone
> 
> my knowledge of xml is advanced, but not concerning namespaces.
> 
> 
> i've got the following error when validating the xml instance document against its schema.
> 
> i think it's got to do with the namespaces...

I think it's probably related to the simple type of the attribute
"linkIDRef", which defaults to xs:anySimpleType. If I recall correctly,
then comparison of values of xs:anySimpleType with other simple type
values was left to be implementation-defined. So xmlSpy's schema
processor might produce negative results for such a comparison.
It doesn't work either with XSV 2.10-1, Xerces-J 2.7.1,
MSXML 4.0 SP2 and Libxml2; only Saxon seems to find a match for "L4".

Try to set the type of the attribute decalaration "linkIDRef" to
xs:string.

By the way, XSV 2.10-1 reports errors like:

<invalid 
  char="9" code="cvc-identity-constraint.2.2.3" line="17"
  resource="file:///p:/libxml2-lab/tests/2005-11-11/keyref.xml">
duplicate key L1 for
{http://plirosost.ethz.ch/Ontology/Schema}LinkIDKey,
first appearance was in unnamed entity at line 17 char 9 of
file:///p:/libxml2-lab/tests/2005-11-11/keyref.xml
</invalid>

This looks like the union in the XPath expression
".//ont:Link | .//ont:Link" is confusing XSV's
IDC resolution mechanism.

Regards,

Kasimier



> thank you for your time and effort
> greetings elly
> 
> 
> ps: im using altova xmlSpy, enterprise edition 2005 rel. 3
> 
> 
> <!-- ERROR of xml instance document **************************************** -->
> 
> 
> line: 50
> This file is not valid: the value 'L4' matched by the <keyref> identity constraint
> 'ont:KeyIDRefLink' was not matched by the referenced key 'ont:LinkIDKey' within
> the scope of element 'ont:NewDataSet'.
> 
> 
> line: 55
> This file is not valid: the value 'L5' matched by the <keyref> identity constraint
> 'ont:KeyIDRefLink' was not matched by the referenced key 'ont:LinkIDKey' within
> the scope of element 'ont:NewDataSet'.
> 
> 
> <!-- Schema **************************************** -->
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema
>     targetNamespace="http://plirosost.ethz.ch/Ontology/Schema"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:ont="http://plirosost.ethz.ch/Ontology/Schema"
>     elementFormDefault="qualified"
>     attributeFormDefault="qualified">
>     <!--  -->
> 
>   
>    <xs:element name="Link">
>        <xs:complexType>
>            <xs:simpleContent>
>                <xs:extension base="xs:string">
>                    <xs:attribute name="linkIDKey" type="xs:string" use="required"/>
>                </xs:extension>
>            </xs:simpleContent>
>        </xs:complexType>
>    </xs:element>
>       
>     
>   <!--  -->
>   <xs:element name="NewDataSet">
>     <xs:complexType>
>       <xs:choice maxOccurs="unbounded">
>         <!--  -->
>           <xs:element name="Customers">
>             <xs:complexType>
>               <xs:sequence>
>                 <xs:element name="CustomerID">
>                   <xs:simpleType>
>                     <xs:restriction base="xs:string">
>                       <xs:pattern value="c\d+"/>
>                     </xs:restriction>
>                   </xs:simpleType>
>                 </xs:element>
>                 <xs:element name="CompanyName" type="xs:string"/>
>                 <xs:element name="ContactName" type="xs:string" minOccurs="0"/>
>                 <xs:element name="ContactTitle" type="xs:string" minOccurs="0"/>
>                 <xs:element name="Address" type="xs:string" minOccurs="0"/>
>                 <xs:element name="City" type="xs:string" minOccurs="0"/>
>                 <xs:element name="Region" type="xs:string" minOccurs="0"/>
>                 <xs:element name="PostalCode" type="xs:string" minOccurs="0"/>
>                  <xs:element ref="ont:Link"/>
>                  <xs:element name="Label" type="xs:string"/>
>               </xs:sequence>
>             </xs:complexType>
>           </xs:element>
>                 <!--  -->
>         <xs:element name="Orders">
>             <xs:complexType>
>                 <xs:sequence>
>                     <xs:element name="OrderID">
>                         <xs:simpleType>
>                             <xs:restriction base="xs:string">
>                                 <xs:pattern value="o\d+"/>
>                             </xs:restriction>
>                         </xs:simpleType>
>                     </xs:element>
>                     <xs:element name="CustomerID" type="xs:string"/>
>                     <xs:element name="OrderDate" type="xs:string" minOccurs="0"/>
>                     <xs:element ref="ont:Link"/>
>                 </xs:sequence>
>                 <xs:attribute name="label" type="xs:string"/>
>             </xs:complexType>
>         </xs:element>
>         <!--  -->
>         <xs:element name="Blabla">
>             <xs:complexType>
>                 <xs:sequence>
>                     <xs:element name="orderLink" type="xs:string"/>
>                 </xs:sequence>
>                 <xs:attribute name="linkIDRef" use="required"/>
>             </xs:complexType>
>         </xs:element>
>                 <!--  -->
>             </xs:choice>
>         </xs:complexType>
>       
>       <!--  -->
>       <xs:unique name="UniqueLinkID">
>           <xs:selector xpath=".//ont:Link | .//ont:Link"/>
>           <xs:field xpath="@ont:linkIDKey"/>
>       </xs:unique>
>     
>       <xs:key name="LinkIDKey">
>           <xs:selector xpath=".//ont:Link | .//ont:Link"/>
>           <xs:field xpath="@ont:linkIDKey"/>
>       </xs:key>
>       <xs:keyref name="KeyIDRefLink" refer="ont:LinkIDKey">
>           <xs:selector xpath=".//ont:Blabla"/>
>           <xs:field xpath="@ont:linkIDRef"/>
>       </xs:keyref>
>       <!--  -->
>     
>     </xs:element>
> </xs:schema>
> 
> 
> <!-- xml-instance **************************************** -->
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <ont:NewDataSet xmlns="http://plirosost.ethz.ch/Ontology/Schema"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:ont="http://plirosost.ethz.ch/Ontology/Schema"
>     xsi:schemaLocation="http://plirosost.ethz.ch/Ontology/Schema
> 
> file:/D:/SA1_OntologyBuilder/XML/meineBsp/customer3_Namespace.xsd">
>   
>     <Customers>
>         <CustomerID>c666</CustomerID>
>         <CompanyName>HSR</CompanyName>
>         <ContactName>Elly</ContactName>
>         <ContactTitle>Frau</ContactTitle>
>         <Address>blabla</Address>
>         <City>Zürich</City>
>         <Region>CH</Region>
>         <PostalCode>8041</PostalCode>
>         <Link ont:linkIDKey="L1"></Link>
>         <Label>label1</Label>
>     </Customers>
>   
>     <Customers>
>         <CustomerID>c333</CustomerID>
>         <CompanyName>Herisau</CompanyName>
>         <ContactName>Claudio</ContactName>
>         <ContactTitle>Frau</ContactTitle>
>         <Address>blabla</Address>
>         <City>Zürich</City>
>         <Region>CH</Region>
>         <PostalCode>7777</PostalCode>
>         <Link ont:linkIDKey="L2">aa</Link>
>         <Label>label2</Label>
>     </Customers>
>       
>     <Orders ont:label="label1">
>         <OrderID>o333</OrderID>
>         <CustomerID>c666</CustomerID>
>         <OrderDate>23.07.77</OrderDate>
>         <Link  ont:linkIDKey="L3">b</Link>
>     </Orders>
>   
>     <Orders ont:label="label1">
>         <OrderID>o777</OrderID>
>         <CustomerID>c666</CustomerID>
>         <OrderDate>23.07.77</OrderDate>
>         <Link ont:linkIDKey="L4">bb</Link>
>     </Orders>
>   
> 
> 
>     <Blabla ont:linkIDRef="L4">      <!-- ***line50*** l4sollte keinen error geben, tut es aber !!!!! -->
>         <orderLink>bb</orderLink>
>     </Blabla>
>   
>   
>     <Blabla ont:linkIDRef="L5">      <!-- ***line55 ***TODO l5 sollte error geben, tut aber nicht !!!!! ev.
> 
> folgefehler von oben!-->
>         <orderLink>bb</orderLink>
>     </Blabla>
>      
> </ont:NewDataSet> 
> 
>  
> 
> 
Received on Friday, 11 November 2005 11:50:43 GMT

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