[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: 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@m...] > Sent: 23 January 2009 16:11 > To: 'xml-dev@l...' > Subject: 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@l... > subscribe: xml-dev-subscribe@l... 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] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|