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]
XML Schema Design: no local elements with anonymous types

Hi Folks,

Along the road to learning version 2.0 of XSLT/XPath, I learned this
about designing XML Schemas.
 
BAD: locally declared elements with anonymous types.
 
Example:  NumPages is BAD because it is locally declared and has an
anonymous type.
 
<element name="Book">
    <complexType>
        <sequence>
          <element name="NumPages">
               <simpleType>
                     <restriction base="positiveInteger">
                         <maxInclusive value="1200"/>
                     </restriction>
               </simpleType>
          </element>
        </sequence>
    </complexType>
</element>
 
GOOD: globally declared elements and/or elements with a named type.
 
Example: Now NumPages is GOOD because it is globally declared and has a
named type.
 
<element name="Book">
    <complexType> 
        <sequence>
          <element ref="bk:NumPages"/> 
        </sequence>
    </complexType>
</element>
 
<element name="NumPages" type="NumPagesType" />
 
<simpleType name="NumPagesType">
    <restriction base="positiveInteger">
        <maxInclusive value="1200"/>
    </restriction>
</simpleType>
 
 
Here's why: XSLT/XPath 2.0 is "schema-aware."  That is, in a 2.0
stylesheet you can take advantages of the type information in the
schema.  However, that's true only if the elements are declared
globally and/or with a named type.  So, to facilitate the use of type
information by a 2.0 stylesheet, design your XML Schemas such that
elements are declared globally and/or with a named type.

Summary: make the element global, or with a named type, or both.
 
/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