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]
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]


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