Re: Identity constraint questions

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 UTC