Schema Examples


The sample schemas for the flat file examples are very similar to the CSV examples. The primary differences should be evident from examining the primary differences between the instance documents. In the CSV file representations all data is in a sequence of identically formatted Elements, each representing a single row in the CSV file. In the flat file representations the data is broken up into separate record formats, and the line item detail and description records are grouped together.

Invoice Schema (FlatInvoice.xsd)
 <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"     elementFormDefault="unqualified">   <xs:element name="FlatInvoice">     <xs:complexType>       <xs:sequence>         <xs:element name="Header">           <xs:complexType>             <xs:sequence>               <xs:element name="RecordID" type="xs:token"/>               <xs:element name="CustomerNumber" type="xs:token"/>               <xs:element name="InvoiceNumber" type="xs:token"/>               <xs:element name="InvoiceDate" type="xs:date"/>               <xs:element name="PONumber" type="xs:token"/>               <xs:element name="DueDate" type="xs:date"/>             </xs:sequence>           </xs:complexType>         </xs:element>         <xs:element name="ShipTo">           <xs:complexType>             <xs:sequence>               <xs:element name="RecordID" type="xs:token"/>               <xs:element name="ShipToName" type="xs:token"/>               <xs:element name="ShipToStreet1" type="xs:token"/>               <xs:element name="ShipToStreet2" type="xs:token"                   minOccurs="0"/>               <xs:element name="ShipToCity" type="xs:token"/>               <xs:element name="ShipToStateOrProvince"                   type="xs:token"/>               <xs:element name="ShipToPostalCode"                   type="xs:token"/>               <xs:element name="ShipToCountry" type="xs:token"                   minOccurs="0"/>             </xs:sequence>           </xs:complexType>         </xs:element>         <xs:element name="LineItemGroup" maxOccurs="unbounded">           <xs:complexType>             <xs:sequence>               <xs:element name="LineItem">                 <xs:complexType>                   <xs:sequence>                     <xs:element name="RecordID" type="xs:token"/>                     <xs:element name="ItemID" type="xs:token"/>                     <xs:element name="ItemQuantity"                         type="xs:decimal"/>                     <xs:element name="UnitPrice"                         type="xs:decimal"/>                     <xs:element name="ExtendedPrice"                         type="xs:decimal"/>                   </xs:sequence>                 </xs:complexType>               </xs:element>               <xs:element name="ItemDescription">                 <xs:complexType>                   <xs:sequence>                     <xs:element name="RecordID" type="xs:token"/>                     <xs:element name="Description"                         type="xs:token"/>                   </xs:sequence>                 </xs:complexType>               </xs:element>             </xs:sequence>           </xs:complexType>         </xs:element>         <xs:element name="Summary">           <xs:complexType>             <xs:sequence>               <xs:element name="RecordID" type="xs:token"                   minOccurs="0"/>               <xs:element name="TotalAmount" type="xs:decimal"/>               <xs:element name="NumberOfLines"                   type="xs:nonNegativeInteger" minOccurs="0"/>             </xs:sequence>           </xs:complexType>         </xs:element>       </xs:sequence>     </xs:complexType>   </xs:element> </xs:schema> 
Purchase Order Schema (FlatPurchaseOrder.xsd)
 <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"     elementFormDefault="unqualified">   <xs:element name="PurchaseOrder">     <xs:complexType>       <xs:sequence>         <xs:element name="Header">           <xs:complexType>             <xs:sequence>               <xs:element name="CustomerNumber" type="xs:token"/>               <xs:element name="PONumber" type="xs:token"/>               <xs:element name="PODate" type="xs:date"/>               <xs:element name="RequestedDeliveryDate"                   type="xs:date"/>             </xs:sequence>           </xs:complexType>         </xs:element>         <xs:element name="ShipTo">           <xs:complexType>             <xs:sequence>               <xs:element name="ShipToName" type="xs:string"/>               <xs:element name="ShipToStreet1" type="xs:string"/>               <xs:element name="ShipToStreet2" type="xs:string"                   minOccurs="0"/>               <xs:element name="ShipToCity" type="xs:string"/>               <xs:element name="ShipToStateOrProvince"                   type="xs:token"/>               <xs:element name="ShipToPostalCode"                   type="xs:string"/>               <xs:element name="ShipToCountry" type="xs:token"                   minOccurs="0"/>             </xs:sequence>           </xs:complexType>         </xs:element>         <xs:element name="LineItem" maxOccurs="unbounded">           <xs:complexType>             <xs:sequence>               <xs:element name="Item">                 <xs:complexType>                   <xs:sequence>                     <xs:element name="ItemID">                       <xs:simpleType>                         <xs:restriction base="xs:token">                           <xs:enumeration value="HCMIN"/>                           <xs:enumeration value="HCVAN"/>                           <xs:enumeration value="HCMOC"/>                           <xs:enumeration value="HCDUC"/>                         </xs:restriction>                       </xs:simpleType>                     </xs:element>                     <xs:element name="OrderedQty"                         type="xs:decimal"/>                     <xs:element name="UnitPrice"                         type="xs:decimal"/>                     <xs:element name="ExtendedAmount"                         type="xs:decimal" minOccurs="0"/>                   </xs:sequence>                 </xs:complexType>               </xs:element>               <xs:element name="ItemDescription" minOccurs="0">                 <xs:complexType>                   <xs:sequence>                     <xs:element name="Description"                         type="xs:string"/>                   </xs:sequence>                 </xs:complexType>               </xs:element>             </xs:sequence>           </xs:complexType>         </xs:element>       </xs:sequence>     </xs:complexType>   </xs:element> </xs:schema> 


Using XML with Legacy Business Applications
Using XML with Legacy Business Applications
ISBN: 0321154940
EAN: 2147483647
Year: 2003
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net