XML Tutorial/XML Schema/Venetian Blind — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:26, 26 мая 2010
Venetian Blind Model
The Venetian Blind Model encourages the use of complexTypes rather than just the declaration of elements.
The idea behind types and the Venetian Blind Model is analogous to the notion of defining a class and using the class to create an object.
<?xml version = "1.0" ?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"
targetNamespace = "http://www.wbex.ru/Customers"
xmlns = "http://www.wbex.ru/Customers"
elementFormDefault = "qualified"
attributeFormDefault = "unqualified">
<xs:element name = "Customer" type = "NameType" />
<xs:complexType name = "NameType">
<xs:sequence>
<xs:element name = "FirstName" type = "xs:string" />
<xs:element name = "MiddleName" type = "xs:string"
minOccurs = "0" maxOccurs = "1" />
<xs:element name = "LastName" type = "xs:string" />
</xs:sequence>
<xs:attribute name = "customerID" type = " xs:integer"
use = "required" />
<xs:attribute name = "clubCardMember" type = "xs:boolean" />
</xs:complexType>
</xs:schema>
File: Data.xml
<?xml version = "1.0" ?>
<Customer xmlns = "http://www.wbex.ru/Customers"
xmlns:cust = "http://www.wbex.ru/Customers"
customerID = "2442"
clubCardMember = "true" >
<FirstName>first</FirstName>
<MiddleName>middle</MiddleName>
<LastName>last</LastName>
</Customer>