XML Tutorial/XML Schema/element — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:26, 26 мая 2010
An element may be named and defined globally.
<xsd:schema
targetNamespace=
"http://www.wbex.ru/namespace/employees"
xmlns="http://www.wbex.ru/namespace/employees"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:element name="employees">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="firstName"/>
<xsd:element ref="middleName"/>
<xsd:element ref="lastName"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="firstName" type="xsd:string"/>
<xsd:element name="middleName" type="xsd:string"/>
<xsd:element name="lastName" type="xsd:string"/>
</xsd:schema>
An element may be named and defined locally.
<xsd:schema
targetNamespace=
"http://www.wbex.ru/namespace/employees"
xmlns="http://www.wbex.ru/namespace/employees"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:element name="employees">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string"/>
<xsd:element name="middleName" type="xsd:string"/>
<xsd:element name="lastName" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Element Declarations
File: Schema.xsd
<?xml version = "1.0" ?>
<schema xmlns = "http://www.w3.org/2001/XMLSchema">
<element name = "Address">
<complexType>
<sequence>
<element name = "Street" type = "string" />
<element name = "Town" type = "string" />
<element name = "City" type = "string" />
<element name = "StateProvinceCounty" type = "string" />
<element name = "Country" type = "string" />
<element name = "ZipPostCode" type = "string" />
</sequence>
</complexType>
</element>
</schema>
File: Data.xml
<?xml version = "1.0" ?>
<Address>
<Street>10 Place</Street>
<Town>A</Town>
<City>B</City>
<StateProvinceCounty>C</StateProvinceCounty>
<Country>D</Country>
<ZipPostCode>2021</ZipPostCode>
</Address>