XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Interesting (and useful) tidbits about the ID datatype

All pretty well-known problems, all caused by the desire of the XML
designers to be bug-compatible with SGML.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Costello, Roger L. [mailto:costello@mitre.org] 
> Sent: 23 January 2009 16:11
> To: 'xml-dev@lists.xml.org'
> Subject: [xml-dev] Interesting (and useful) tidbits about the 
> ID datatype
> 
> 
> Hi Folks,
> 
> 1. For every primitive datatype you can "fix" the value of 
> the element/attribute, e.g.,
> 
>     <element name="Greeting" type="string" fixed="Hello World" />
> 
> The string element Greeting has a fixed (constant) value, 
> "Hello World"
> 
> But .... there is one datatype that you can't fix: the ID 
> datatype. Thus, this is illegal:
> 
>     <attribute name="Food" type="ID" fixed="Popcorn" />
> 
> 
> 2. You can create an element with multiple attributes, each 
> with the same datatype, e.g., 
> 
>     <element name="Conference">
>         <complexType>
>             <sequence />
>             <attribute name="Start" type="date" />
>             <attribute name="Finish" type="date" />
>         </complexType>
>     </element>
> 
> The Conference element has two attributes, each of type date.
> 
> But .... an element can have only one ID attribute. Thus, 
> this is illegal:
> 
>     <element name="Widget">
>         <complexType>
>             <sequence />
>             <attribute name="SKU" type="ID" /> 
>             <attribute name="Model-Num" type="ID" /> 
>         </complexType>
>     </element>
> 
> 
> 3. Q: In the real world, what are typical identifiers? 
> 
>    A: SSN, ISBN, part number, model number, SKU number, and others.
> 
>    Q: What do each of them begin with? 
> 
>    A: A digit.
> 
> The purpose of the ID datatype is to use it as an identifier. 
> But .... an ID value cannot begin with a digit!
> 
> So, if you declare this:
> 
>     <element name="Book">
>         <complexType>
>             <sequence />
>             <attribute name="isbn" type="ID" />
>         </complexType>
>     </element>
> 
> Then, this is an invalid value for isbn:
> 
>     <Book isbn="0-4390-39402" />
> 
> An ID value can only begin with a letter of the alphabet or a dash.
> 
> 
> 4. Lastly, the ID datatype can only be used with attributes, 
> not elements.
> 
> 
> RECAP:
> 
> 1. An ID value must begin with a letter of the alphabet or a dash.
> 
> 2. The ID datatype can only be used with attributes, not elements.
> 
> 3. An element cannot have more than one attribute of type ID
> 
> 4. An ID attribute cannot have its value fixed.
> 
> /Roger
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS