Microsoft Office Tutorials and References
In Depth Information
The next several lines of code identify the basic element in the schema (often named Root )
and indicate what structure the data will take.
<element name="Root">
<complexType>
<sequence>
<element name="Supplier” maxOccurs="unbounded">
</element>
</sequence>
</complexType>
</element>
The <complexType> tag in this XML schema code indicates that the Root element is complex ,
meaning it’s allowed to contain multiple subelements. If you refer back to Figure 26-4, you
can see that the Root element does indeed have subelements, the first of which is Supplier . The
<sequence> tag indicates that the subelements will always appear in the same order, which is to
be expected when you generate an XML data file from a spreadsheet or database table.
There is something new in the Supplier element declaration: the maxOccurs="unbounded”
parameter setting. This parameter tells the XML interpreter that there can be more than one
Supplier element in any XML data file that follows this schema. If you leave this parameter
out, the interpreter knows to expect a single occurrence of the element, which is handy if you
want to add information regarding the document author, the department, or the project
code at the beginning of the data file.
You should think of XML elements as being similar to objects with properties. For example,
the following abbreviated code sample shows some of the properties associated with a supplier:
<element name="SupplierID” type="positiveInteger"/>
<element name="MailingAddress">
<complexType>
<sequence>
<element name="Address” type="string"/>
<element name="City” type="string"/>
<element name="Region” type="string"/>
<element name="PostalCode” type="string"/>
<element name="Country” type="string"/>
</sequence>
</complexType>
</element>
You should remember that any simple element (that is, an element with a single value asso­
ciated with it) is enclosed within a single tag that ends with /> . In addition to the name of the
element, the element tag also contains a type parameter, which indicates the data type the ele­
ment must contain. The two types used in the sample are positiveInteger and string , which are
self-explanatory.
To save your schema as an XML schema file, follow these steps in Notepad:
1 Click File, Save.
Search JabSto ::




Custom Search