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

Re: Identity constraint questions

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 21 Nov 2001 18:00:12 +0000
Message-ID: <144722650.20011121180012@jenitennison.com>
To: knoaman@ca.ibm.com
CC: xmlschema-dev@w3.org
what is an identity constraint
Hi Khaled,

> Does that mean that I cannot have two identity constraints with the
> same name within an XML Schema?

Yes. You cannot have two identity constraints with the same name
within an XML Schema.

> In the section titled 'Schema Component Constraint: Particle
> Restriction OK (Elt:Elt -- NameAndTypeOK)', the following is
> mentioned:
>
> For an element declaration particle to be a valid restriction of
> another element declaration particle all of the following must be
> true:
>
> 5 R's declaration's {identity-constraint definitions} is a subset of
>   B's declaration's {identity-constraint definitions}, if any.
>
> What exactly is meant by 'subset of'? Does it mean that I need to
> have the same identity constraint name in the derivation as the one
> in the base?

It means that you cannot define an identity constraint in R that
wasn't defined in B. I'm fairly sure that the identity constraints
themselves have to be exactly the same. So for example, if you have
the base definition:

<xs:complexType name="base">
  <xs:sequence>
    <xs:element name="foo" type="someType">
      <xs:key name="foo">
        <xs:selector xpath="bar" />
        <xs:field xpath="@baz" />
      </xs:key>
    </xs:element>
  </xs:sequence>
</xs:complexType>

Then it's legal to restrict it with the following because the identity
constraints are the same:

<xs:complexType name="base">
  <xs:restriction base="base">
    <xs:sequence>
      <xs:element name="foo" type="someType">
        <xs:key name="foo">
          <xs:selector xpath="bar" />
          <xs:field xpath="@baz" />
        </xs:key>
      </xs:element>
    </xs:sequence>
  </xs:restriction>
</xs:complexType>

or with the following because the identity constraint isn't applied:

<xs:complexType name="base">
  <xs:restriction base="base">
    <xs:sequence>
      <xs:element name="foo" type="someType" />
    </xs:sequence>
  </xs:restriction>
</xs:complexType>

But it's not possible to restrict it with the following because it's a
new identity constraint:

<xs:complexType name="base">
  <xs:restriction base="base">
    <xs:sequence>
      <xs:element name="foo" type="someType">
        <xs:key name="anotherKey">
          <xs:selector xpath="fred" />
          <xs:field xpath="@barney" />
        </xs:key>
      </xs:element>
    </xs:sequence>
  </xs:restriction>
</xs:complexType>

nor with the following because the identity constraint is different,
despite having the same name:

<xs:complexType name="base">
  <xs:restriction base="base">
    <xs:sequence>
      <xs:element name="foo" type="someType">
        <xs:key name="foo">
          <xs:selector xpath="fred" />
          <xs:field xpath="@barney" />
        </xs:key>
      </xs:element>
    </xs:sequence>
  </xs:restriction>
</xs:complexType>

I think that if you want the same identity constraint to apply for the
elements in the sequence in the restricted type as apply to the
elements in the sequence in the base type, then you have to include
the identity constraint in element declaration for the restricted
type. If you leave out the identity constraint from the element
declaration in the restricted type, then I don't think it applies.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 21 November 2001 13:00:15 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.