Appendix A. Understanding XML Schemas

At the heart of a BizTalk specification is something known as XML schema. At the highest level, XML schemas provide a means for defining the structure, content, and semantics of XML documents. To make this more meaningful, take a look at Listing A.1, a typical XML document.

Listing A.1. An XML Document—Transactions.xml
<?xml version="1.0"?>
<Transactions location="Federal Credit Union" type="checking">
 <Transaction id="ABCD-01234" date="02/02/2001">
  <Amount currency="usd">-41.50</Amount>
  <Type>ATM Withdrawal</Type>
  <Facility>ATM # VA555555</Facility>
  <Location>
   <Name>VA55555 Jans Grocery</Name>
   <Address>555 Main Street</Address>
  </Location>
 </Transaction>
<Transaction id="ABCD-00123" date="02/01/2001">
  <Amount currency="usd">-23.99</Amount>
  <Type>POS Withdrawal</Type>
  <Facility>POS # A3457CD CGI</Facility>
  <Location>
   <Name>Joes Pizza Parlor</Name>
   <Address>560 Main Street</Address>
  </Location>
 </Transaction>
</Transactions>

This XML instance describes a number of banking transactions processed through a financial institution. A schema can be used to define this document so that others—for example, a trading partner or paying customer—can enable their applications to process this document correctly. Several different schema languages are available—XDR, XSD, and DTDs to name three. Listing A.2 displays the XML Data Reduced version of the schema for this file.

Listing A.2. The Transaction XML XDR Schema
<?xml version="1.0"?>
<!-- Generated by using BizTalk Editor on Sat, Nov 17 2001 06:00:49 PM -->
<!-- Copyright  Microsoft Corporation. All rights reserved. -->
<Schema xmlns="urn:schemas-microsoft-com:xml-data" name="Transaction" xmlns:d="urn
:schemas-microsoft-com:datatypes"> <ElementType name="Type" content="textOnly"
 model="closed" d:type="string">
</ElementType><ElementType name="Transaction" content="eltOnly" model="closed">
<element type="Amount" maxOccurs="1" minOccurs="0"/>
<element type="Type" maxOccurs="1" minOccurs="0"/>
<element type="Facility" maxOccurs="1" minOccurs="0"/>
<element type="Location" maxOccurs="1" minOccurs="1"/>
</ElementType><ElementType name="Name" content="textOnly" model="closed" d:type="string">
</ElementType><ElementType name="Location" content="eltOnly" model="closed">
<element type="Name" maxOccurs="1" minOccurs="0"/>
<element type="Address" maxOccurs="1" minOccurs="0"/>
</ElementType><ElementType name="Facility" content="textOnly" model="closed" d:type="string">
</ElementType><ElementType name="Amount" content="textOnly" model="closed" d:type="float">
</ElementType><ElementType name="Address" content="textOnly" model="closed" d:type="string">
</ElementType></Schema>

Listing A.3 displays the XSD schema describing the same XML transaction document.

Listing A.3. The Transaction XML XSD Schema
<?xml version="1.0" encoding="UTF-16"?>
<!--
  [XDR-XSD] This schema automatically updated from an IE5-compatible XDR schema to W3C
  XML Schema by xdr-xsd-converter.xslt 1.5, available from Microsoft.
  See http://msdn.microsoft.com/xml.

  Note: if a local copy of XMLSchema.dtd and datatypes.dtd are not
  available, use the official location of "http://www.w3.org/2000/10/XMLSchema.dtd"
  for the system id.
-->
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:annotation>
        <xs:documentation>Schema name: Transaction</xs:documentation>
    </xs:annotation>
    <!-- [XDR-XSD] "Type" element  -->
    <xs:element name="Type" type="xs:string">
    </xs:element>
    <!-- [XDR-XSD] "Transaction" element  -->
    <xs:element name="Transaction">
        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="Amount" minOccurs="0"/>
                <xs:element ref="Type" minOccurs="0"/>
                <xs:element ref="Facility" minOccurs="0"/>
                <xs:element ref="Location"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>
    <!-- [XDR-XSD] "Name" element  -->
    <xs:element name="Name" type="xs:string">
    </xs:element>
    <!-- [XDR-XSD] "Location" element  -->
    <xs:element name="Location">
        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="Name" minOccurs="0"/>
                <xs:element ref="Address" minOccurs="0"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>
    <!-- [XDR-XSD] "Facility" element  -->
    <xs:element name="Facility" type="xs:string">
    </xs:element>
    <!-- [XDR-XSD] "Amount" element  -->
    <xs:element name="Amount" type="xs:float">
    </xs:element>
    <!-- [XDR-XSD] "Address" element  -->
    <xs:element name="Address" type="xs:string">
    </xs:element>
    <!-- [XDR-XSD] XDR datatype derivations -->
</xs:schema>

Note

BizTalk Server currently supports a subset of the recently ratified XML Schema language (XSD) named XML Data Reduced (XDR). It is important to understand that there is a fundamental difference between XML schemas and the XML Schema language. XML schemas define the structure of an XML document using an XML Schema language. The XSD Schema language (XSD) will be supported in future versions of BizTalk Server. Presently, Microsoft BizTalk Server supports XSD documents using an XDR to XSD command-line utility.


Before we begin to discuss the technical specifics of XML schema languages let's take a look at the history behind them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset