Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Key and KeyRefs

From: Jeev <Jeevan.Suresh@-----.--->
To: NULL
Date: 4/10/2008 9:35:00 AM
Hi,

I am trying to get the below scenario,

Root
  Categories
    Category 1
      ItemRef name=1
    Category 2
      ItemRef name=1
  Items
    Item name=1 Desc=
    Item name=2 Desc=

But my schema gives me a keyref cannot find key in scope error. Please
suggest what is wrong in my schema.

<?xml version="1.0" encoding="utf-8" ?>
<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-
technologies.com) -->
<xsd:schema xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="Root">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element minOccurs="1" maxOccurs="1" ref="Categories" />
        <xsd:element minOccurs="1" maxOccurs="1" ref="Items" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="Categories">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element minOccurs="0" maxOccurs="unbounded"
ref="Category" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="Items">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element minOccurs="0" maxOccurs="unbounded" ref="Item" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:key id="ItemReferenceKey1.key" name="ItemReferenceKey1">
      <xsd:selector xpath="Items/Item" />
      <xsd:field xpath="@ItemName" />
    </xsd:key>
    <xsd:keyref id="ItemReferenceKeyRef1.keyref"
name="ItemReferenceKeyRef1" refer="ItemReferenceKey1">
      <xsd:selector xpath="Categories/Category/ItemReference" />
      <xsd:field xpath="@ItemName" />
    </xsd:keyref>
  </xsd:element>
  <xsd:element name="Category">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element minOccurs="0" maxOccurs="unbounded"
ref="ItemReference" />
      </xsd:sequence>
      <xsd:attribute name="CategoryName" type="xsd:ID" use="required" /
>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="Item" type="Item" />
  <xsd:complexType name="Item">
    <xsd:sequence />
    <xsd:attribute name="ItemName" type="xsd:ID" use="required" />
    <xsd:attribute name="Type" type="xsd:string" />
    <xsd:attribute name="Identifier" type="xsd:string" />
    <xsd:attribute name="Assembly" type="xsd:string" />
  </xsd:complexType>
  <xsd:element name="ItemReference">
    <xsd:complexType>
      <xsd:sequence />
      <xsd:attribute name="ItemName" type="xsd:IDREF" use="required" /
>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent