FW: use of xml:lang

> Jeni,
> 
> First of all, let me thanks you for your reply yesterday re: key and
> keyref of payroll/depts/xxx@location and employees questions.
> 
> 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>

>  
> 
> -----Original Message-----
> From:	Jeni Tennison [SMTP:jeni@jenitennison.com]
> Sent:	Friday, November 23, 2001 12:49 PM
> To:	Guillaume Rousse
> Cc:	xmlschema-dev@w3.org
> Subject:	Re: use of xml:lang
> 
> Hi Guillaume,
> 
> > I'm currently thinking of a key to ensure unicity, but is it not
> > overkill ?
> 
> No, I think that will work quite well. Using the second XML structure,
> you need to define the key within the element declaration for the name
> element, as follows:
> 
>   <xs:element name="name">
>     ...
>     <xs:key name="languageKey">
>       <xs:selector xpath="language" />
>       <xs:field xpath="@xml:lang" />
>     </xs:key>
>   </xs:element>
> 
> This says "within every name element, each language element has a
> unique value for its xml:lang attribute".
> 
> Using the first XML structure, you need to define the key on the
> country element, as follows:
> 
>   <xs:element name="country">
>     ...
>     <xs:key name="languageKey">
>       <xs:selector xpath="name" />
>       <xs:field xpath="@xml:lang" />
>     </xs:key>
>   </xs:element>
> 
> This says "within every country element, each name element has a
> unique value for its xml:lang attribute".
> 
> > And i doubt it will allow a default value (without xml:lang
> > attribute) in either case.
> 
> You're right that xs:key will object if a language element doesn't
> have an xml:lang attribute. I suggest that when you declare the
> language element, you give the xml:lang attribute a default, which
> will be assigned if the xml:lang attribute is missing, so that you can
> use the key, as follows:
> 
>   <xs:element name="language">
>     <xs:complexType>
>       ...
>       <xs:attribute ref="xml:lang" default="en" />
>     </xs:complexType>
>   </xs:element>
> 
> [I assume the default is 'en' since the ones lacking xml:lang seem to
> be in English! :)]
> 
> The other alternative is to use xs:unique rather than xs:key, but this
> will permit several language elements without xml:lang attributes,
> which you don't want.
> 
> I hope that helps,
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/

Received on Friday, 23 November 2001 14:51:14 UTC