265
Distributed Objects and the Enterprise
<?xml version=”1.0” encoding=”utf-8”?>
<xs:schema targetNamespace=”http://ootp.org/invoice.xsd”
elementFormDefault=”qualified”
xmlns=”http://ootp.org/invoice.xsd” xmlns:mstns=”http://ootp.org/invoice.xsd”
xmlns:xs=”http://www.w3.org/2001/XMLSchema”>
<xs:element name=”Invoice”>
<xs:complexType>
<xs:sequence>
<xs:element name=”Address” minOccurs=”1”>
<xs:complexType>
<xs:sequence />
<xs:attribute name=”Street” type=”xs:string” />
<xs:attribute name=”City” type=”xs:string” />
<xs:attribute name=”State” type=”xs:string” />
<xs:attribute name=”Zip” type=”xs:int” />
<xs:attribute name=”Country” type=”xs:string” />
</xs:complexType>
</xs:element>
<xs:element name=”Package”>
<xs:complexType>
<xs:sequence />
<xs:attribute name=”Description” type=”xs:string” />
<xs:attribute name=”Weight” type=”xs:short” />
<xs:attribute name=”Priority” type=”xs:boolean” />
<xs:attribute name=”Insured” type=”xs:boolean” />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name=”name” type=”xs:string” />
</xs:complexType>
</xs:element>
</xs:schema>
The Invoice.xsd file describes how an invoice is structured and how applications must
conform to its definitions.This file is, in effect, a schema in the same way that a schema is
used in a database system. Note that, per this Invoice.xsd file, an invoice is comprised of
an Address and Package. Further, the Address and Package are built of attributes like
Description, Weight, etc. Finally, these attributes are declared as specific data types like,
string, short, etc. Figure 13.12 shows graphically what this relationship looks like.
In this example, while the Invoice.xsd file describes how the data is structured, the
mwsoap.xml file represents what the data is.An application, written in a language like C#
.NET,VB .NET,ASP.NET or Java, uses the Invoice.xsd file to construct valid XML files
that are then sent to other applications over the network.These applications would use
the same Invoice.xsd file to deconstruct the mwsoap.xml file for use its use. In many
ways, you can think of the Invoice.xsd file as a sort of contract, in a similar way to the