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

Interesting (and useful) tidbits about the ID datatype

  • From: "Costello, Roger L." <costello@m...>
  • To: "'xml-dev@l...'" <xml-dev@l...>
  • Date: Fri, 23 Jan 2009 11:11:29 -0500

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


[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!

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.