<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Simple" xmlns:tns="http://www.example.org/Simple"
elementFormDefault="qualified">
<xs:complexType name="user" mixed="true">
<xs:sequence>
<xs:element name="name" type="xs:string" default="Eric001" />
<xs:element name="age" type="tns:age" default="30" />
<xs:element name="gender" type="tns:gender" default="Male" />
<xs:element name="password" type="tns:password" />
<xs:any maxOccurs="unbounded"></xs:any>
</xs:sequence>
<xs:attribute name="role" type="xs:string"/>
</xs:complexType>
<xs:simpleType name="gender">
<xs:restriction base="xs:string">
<xs:enumeration value="Male" />
<xs:enumeration value="Female" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="age">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1" />
<xs:maxInclusive value="120" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="letter">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z0-9]"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="password">
<xs:restriction base="xs:string">
<xs:pattern value="(([0-9]+[a-zA-Z]+)|([a-zA-Z]+[0-9]+))"></xs:pattern>
<xs:minLength value="5" />
<xs:maxLength value="8" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="amount">
<xs:restriction base="xs:decimal">
<xs:totalDigits value="2"></xs:totalDigits>
</xs:restriction>
</xs:simpleType>
<xs:element name="root">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any maxOccurs="unbounded"></xs:any>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="user" type="tns:user" >
</xs:element>
<xs:element name="cost" type="tns:amount" />
<xs:element name="title"></xs:element>
</xs:schema>
Following is the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<tns:root xmlns:tns="http://www.example.org/Simple" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Simple Simple.xsd ">
This is an user test
<tns:user role="admin">
<tns:name>tnsname1</tns:name>
<tns:age>18</tns:age>
<tns:gender>Male</tns:gender>
<tns:password>sfds3555</tns:password>
<tns:title/>
</tns:user>
<tns:user role="admin">
<tns:name>tnsname1</tns:name>
<tns:age>18</tns:age>
<tns:gender>Male</tns:gender>
<tns:password>sfds3555</tns:password>
<tns:title/>
</tns:user>
<tns:cost>0.22</tns:cost>
<tns:cost>0</tns:cost>
</tns:root>
Friday, September 19, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment