Re: FW: use of xml:lang

Hi Philip,

> As Guillaume is not using keyref, should it be coded as below or it
> doesn't matter at all:
>
>         <xs:element name="name">
>             ...
>             <xs:unique name="languageKey">
>               <xs:selector xpath="language" />
>               <xs:field xpath="@xml:lang" />
>             </xs:unique>
>           </xs:element>

The only difference between key and unique is that all the elements
that you select with a key have to have values for the fields that you
use for the key. With a unique identity constraint, on the other hand,
you can have some of the elements that you select with no value for
the fields.

Note that whether you use key or unique makes no difference whatsoever
as to whether you can refer to the identity constraint using a keyref.

In this example, assuming that you didn't set a default on the
xml:lang attribute, using xs:unique as above would allow:

  <name>
    <language>brazil</language>
    <language>brésil</language>
    <language>brasil</language>
  </name>

whereas a key identity constraint would reject this example because
the language elements don't have xml:lang attributes. A key identity
constraint would likewise reject:

  <name>
    <language>brazil</language>
    <language xml:lang="fr">brésil</language>
    <language xml:lang="es">brasil</language>
  </name>

However, with the default set for xml:lang, I think that key and
unique would work in exactly the same way.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Saturday, 24 November 2001 10:06:07 UTC