HandsOn Examining the Contents of an XML Schema File

1. Open Windows Explorer and switch to the Learn_XML folder containing the files generated in Hands-On 29-1 (see Figure 29-3).

2. Use Windows Notepad to open the Shippers.xsd file located in the Learn_XML folder. Access displays the contents of the Shippers.xsd file as shown in Figure 29-5.

Part V

C Shippers - Notepad

He Edt Format View Help

<?xml version="1.0" encoding="UTF-8"?>

<xsd:5chema xm~l n 5: xs d=" ht t p://ww,w3. or g/2QG1/XML5Chema"

xml ns: od="urn:schemas -mi cr osof t -com: of f i cedat a" >

<xsd:element name~"dataroot">

<xsd:compl exType>


<xsd:element ref-"Shippers" minGccurs-"Q" maxoccurs-"unbounded"/> </xsd:sequence>

<xsd:attribute name-"generated" type="xsd:dateTime"/> </xsd:complexType> </xsd:element>

<xsd:element name="sh1ppers">



cod:index index-name="PrimaryKey" 1ndex-key="sh1pperED " prlmary="yes"

un1que="yes" c"lustered="no"/>




<xsd:element name="shipperlo" minoccurs»"!'" odTietType="autonumber" od:sgl SType-"int" odrautoUnique-"yes" od:nonMul1able-"yes" type-"xsd:int"/> <xsd:element name-"CompanyName" minoccurs-"!" od:jetType-"text"

odrsql5Type-"nvarchar" od rnonNullab1e-"yes"> <xsd:simpleTyp~

mpleType> <xsd:restriction base-"xsd:string"> <xsd:maxl_ength va1ue="40"/> </xsd:restrnetion> </xsd: simp!eType> </xsd: elements-

<xsd:element name="Phone" mlnoccurs^'o" od:jetType="text" od:sqlSType="nvarchar"> <xsd:s1mpletype>

<xsd:restrict Ion base="xsd:string">

<xsd:maxLength value="24"/>



</xsd t ccmplexType>

Figure 29-5: The schema file shown here defines the data in the Shippers.xml document.

If you take a look at the Shippers.xsd file currently open in Notepad, you will notice a number of XSD declarations and commands that begin with the <xsd> tag followed by a colon and the name of the command. You will also notice the names ofthe elements and attributes that are allowed in the Shippers.xml file as well as the data types for each element.

The names of the data types are preceded with the od prefix followed by a colon. For example:


Defines the JetData type for an element


Defines the Microsoft SQL Server data type for an element


Defines a Boolean data type for an auto-incremented identity column


Indicates whether or not a column can contain a Null value.

The schema file also specifies the number of times an element can be used in a document based on the schema. This is done via the minOccurs and maxOccurs attributes.

3. Close Notepad and the Shippers.xsd file.

Taking Your VBA Programming Skills to the Web o

0 0

Post a comment