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

FW: use of xml:lang

From: Chan, Philip <Philip.Chan@rbccm.com>
Date: Fri, 23 Nov 2001 14:50:42 -0500
Message-ID: <A2AB950B23E5D411B23C00805FA7BBC80195EF12@TOTOMB04>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
xml default 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 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.