[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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] |
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
|