[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

key and keyref

From: Chan, Philip <Philip.Chan@rbccm.com>
Date: Wed, 21 Nov 2001 12:06:12 -0500
Message-ID: <A2AB950B23E5D411B23C00805FA7BBC80195EF0B@TOTOMB04>
To: "'xmlschema-dev'" <xmlschema-dev@w3.org>
xsd constaints
Given an XML such as:
<payroll>
  <depts>
    <hr location="Toronto"> ... </hr>
    <hr location="London"> ... </hr>
    <finance location="Toronto"> ... </finance>
    <finance location="New York"> ... </finance>
  </depts>

  <employees>
    <name="xxx">
      <dept>
        <name>hr</name>
        <location>London</location>
      </dept>
    </name>
    <name="xxxx"> ... </name>
  </employees>
</payroll>

In the above XML, the number of depts are known and limited to not more than
20.

In the schema, I have defined unique constaints on both hr and finance and
for other depts, if any:
    <xsd:unique name="HRKey">
      <xsd:selector xpath="/payroll/depts/hr" />
      <xsd:field xpath="@location" />
    </xsd:unique>
    <xsd:unique name="FinanceKey">
      <xsd:selector xpath="/payroll/depts/finance" />
      <xsd:field xpath="@location" />
    </xsd:unique>

Now, is it possible to create a key and keyref constaints so that
/payroll/employees/name/dept/name and 
/payroll/employees/name/dept/location are only pointing to:
/payroll/"any node()" and /payroll/"the node()"@location?


I understand that life will be much easier if I could rewrite the XML to:
<payroll>
  <depts>
    <dept name="hr" location="Toronto"> ... </dept>
    <dept name="hr" location="London"> ... </dept>
    <dept name="finance" location="Toronto"> ... </dept>
    <dept name="finance" location="New York"> ... </dept>
  </depts>
...
but I couldn't.

Thanks
Philip
Received on Wednesday, 21 November 2001 12:06:53 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.