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

RE: XML Schema: enumeration 'value' subtyping

  • From: "Biron,Paul V" <Paul.V.Biron@k...>
  • To: "'Stefan.Keller@l...'" <Stefan.Keller@l...>
  • Date: Thu, 20 Jul 2000 14:01:53 -0700

xml schema enumeration
> -----Original Message-----
> From:	Stefan.Keller@l... [SMTP:Stefan.Keller@l...]
> Sent:	Wednesday, July 19, 2000 4:47 AM
> To:	xmlschema-dev@w...; www-xml-schema-comments@w...;
> xml-dev@x...
> Subject:	XML Schema: enumeration 'value' subtyping
> 
> I would like to hang in a new thread as a newbie. I understand that
> enumeration represents an enumerated type supported on attributes only.
> 
[Note: I removed xmlschema-dev from the address list, since that list is for
discussion of issues surrounding implementation of schema processors, not
general questions/issues about XML Schema as a language].

It's beside the point, but, it is true that in DTDs enumerations could only
specified for attributes, but in XML Schema enumeration is not limited to
attributes.  For example, given a schema fragment such as the following:

	<element name='building' type='languageCode'/>

and an instance fragment:

	<building>DE</building> <!-- valid -->
	<building>IT</building>   <!-- invalid -->

> My/our requirement is now *not* only the reduction of list of permitted
> values *but* to subtype one (ore more) specific enumeration values, like
> EN-us, EN-uk, EN-aus, ... meaning us-english, uk-english,
> australian-english, ... Here is an example:
> 
> <simpleType name="languageCode" base="string"> 
>   <enumeration value="DE"/> 
>   <enumeration value="EN"/> 
>   <enumeration value="FR"/> 
>   <enumeration value="ZW"/> 
> </simpleType> 
> 
There is a built-in datatype called language [1], whose value space is the
set of language codes provided for in RFC 1766, "Tags for the Identification
of Languages" [2]. 

> Example solution with a (very probably incorrect) syntax invented by
> myself:
> 
> <specializedType 
>  name="languageSubCode" source="simpleType" deriveBy="extension"> 
>   <group ref="EN"> 
>     <enumeration value="US"/ >    <!-- Remark: means EN-US -->
>     <enumeration value="EN-UK"/>  <!-- Remark: means EN-UK -->
>     ...
>   </group>
> </specializedType> 
> 
The language datatype has a basic structure (its actually more complex than
what follows, as described in detail in 1766) of:

	a 2 letter language code,
	optionally followed by "-" and a 2 letter country code

The 2 letter language code is interpreted according to ISO 639, "Code for
the representation of names of languages".  The 2 letter country codes are
interpreted as ISO 3166 alpha-2 country codes denoting the area in which the
language is used.

Thus, in the language datatype you have just what you need.  Granted, the
schema processor will not "understand" that "en-US" and "en-UK" are related,
but your application certainly can easily be made to understand that.

You can derive datatypes from language, using either enumeration or the
pattern facet, such as:

	<simpleType name='english' base='language'>
		<pattern value='en(-[a-zA-Z]{1,8})*'/>
	</simpleType>

(the country code can actually be a maximum of 8 chars, see RFC 1766 for
details, the 3-8 letter country codes could be, for instance, a locale, such
as "en-calif" or "en-cockney").

> We have quite some experience and practice with this type in a national
> geodata description and transfer standard, called 'INTERLIS'. The
> advantage
> is, that we can define object- and/or codelists at national/international
> level (i.e. landcover, vegetataion types, building or street classnames)
> and
> allow then cantons/admin.regions to make a (hierarchical) subdivision of
> this enumeration. This ensures compatibility trough structural
> polymorphism
> down to the data integration level.
> 
Does this help?

pvb

References
[1] http://www.w3.org/TR/xmlschema-2/#language
[2] http://www.ietf.org/rfc/rfc1766.txt 

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.