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

XML-Schema keyref & namespaces ??!

From: <ezarakan@hsr.ch>
Date: Fri, 11 Nov 2005 11:47:38 +0100
Message-ID: <9F6698CFCC9C4243AF0F83D86E4E8AA1320830@sid00061.hsr.ch>
To: <xmlschema-dev@w3.org>, <public-schemata-users@w3.org>





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...


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:55:36 GMT

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