Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: More Key/Keyref Questions

From: George Cristian Bina <george@----.-->
To: Jim Stanley <JimS@--------------.--->
Date: 7/30/2004 2:27:00 PM
Hi Jim,

The simplest thing is to move all the keys and keyref in the element 
that include your activity and prodCategory elements. In this way you 
have the declarations in scope. Assuming all the elements must have an 
unique elemID and the parent of activity and prodCategory is an element 
named document then the following should define your keys and keyref:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

     <xs:element name="document">
         <xs:complexType>
             <xs:sequence>
                 <xs:element ref="prodCategory" maxOccurs="unbounded"/>
                 <xs:element ref="activity" maxOccurs="unbounded"/>
             </xs:sequence>
         </xs:complexType>

         <xs:key name="prodCategory.PK">
             <xs:selector xpath="prodCategory"/>
             <xs:field xpath="catName"/>
         </xs:key>
         <xs:key name="activityID.PK">
             <xs:selector xpath="activity"/>
             <xs:field xpath="activityID"/>
         </xs:key>
         <xs:key name="prodElement.PK">
             <xs:selector xpath="prodCategory/prodElement"/>
             <xs:field xpath="elemID"/>
         </xs:key>

         <xs:keyref name="elemRef.FK" refer="prodElement.PK">
             <xs:selector xpath="activity"/>
             <xs:field xpath="elemRef"/>
         </xs:keyref>
     </xs:element>


     <xs:element name="prodCategory" type="prodCategory"/>
     <xs:complexType name="prodCategory">
         <xs:sequence>
             <xs:element name="catName" type="xs:string"/>
             <xs:element ref="prodElement" maxOccurs="unbounded"/>
         </xs:sequence>
     </xs:complexType>

     <xs:element name="prodElement" type="prodElement"/>
     <xs:complexType name="prodElement">
         <xs:sequence>
             <xs:element name="elemID" type="xs:int"/>
             <xs:element name="elemName" type="xs:string"/>
             <xs:element name="elemOrder" type="xs:int"/>
             <xs:element name="elemQuantity" type="xs:int" default="1"/>
         </xs:sequence>
     </xs:complexType>

     <xs:element name="activity" type="activity"/>
     <xs:complexType name="activity">
         <xs:sequence>
             <xs:element name="activityID" type="xs:int"/>
             <xs:element name="elemRef" type="xs:int" 
maxOccurs="unbounded"/>
         </xs:sequence>
     </xs:complexType>
</xs:schema>


Hope that helps,
George
-----------------------------------------------
George Cristian Bina
<oXygen/> XML Editor & XSLT Editor/Debugger
www.---.com

From mhk@m...  Fri Jul 30 05:41:36 2004
Return-Path: <mhk@m...>
X-Original-To: xmlschema-dev@l


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