本主题包含万维网联合会 (W3C) 订单示例。第一个示例是订单的架构。第二个示例是由该架构示例验证的实例文档。
以下示例说明定义订单的架构 po.xsd。该示例说明如何使用 element 以及 attribute 声明。该示例还说明 simpleType 和 complexType 定义。
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespacehttp://tempuri.org/po.xsd"
- xmlnselementFormDefaultqualified>
- annotation>
- documentation xml:langen>
- Purchase order schema for Example.com.
- Copyright 2000 Example.com. All rights reserved.
- </documentation>
- element namepurchaSEOrdertypePurchaSEOrderType/>
- commentxs:stringcomplexType sequence>
- shipToUSAddress/>
- billTorefminOccurs0items" Items/>
- attribute orderDatexs:date/>
- complexTypename" streetcitystatezip" xs:decimalcountryxs:NMTOKEN"
- fixedUSitemmaxOccursunbounded>
- >
- >
- productName/>
- quantity>
- simpleType>
- restriction basexs:positiveInteger>
- maxExclusive value100/>
- restrictionelementUSPriceshipDate/>
- partNumSKUuserequired/>
- >
- <!-- Stock Keeping Unit,a code for identifying products >
- simpleType pattern \d{3}-[A-Z]{2}>
- schema>
- >
示例:订单实例文档
以下示例说明一个订单架构的实例文档 po.xml,由前一个示例中的 po.xsd 进行验证。
- <?xml version1.0?>
- purchaseOrder orderDate1999-10-20shipTo countryname>Alice Smithstreet>123 Maple Streetcity>Mill Valleystate>CAzip>90952shipTobillTo >Robert Smith>8 Oak Avenue>Old Town>PA>95819billTocomment>Hurry,my lawn is going wild!itemsitem partNum872-AA>
- productName>Lawnmowerquantity>1USPrice>148.95>Confirm this is electricitem926-AA>Baby Monitor>39.98shipDate>1999-05-21>
- purchaseOrder>
本主题包含万维网联合会 (W3C) 订单示例。第一个示例是订单的架构。第二个示例是由该架构示例验证的实例文档。