Webservice 笔记:
练习:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Orders"> <xs:complexType> <xs:sequence> <xs:element name="Order" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:group ref="ordergroup"/> <xs:attributeGroup ref="orderatt"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:group name="ordergroup"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="number" type="numbertype"/> <xs:element name="city" type="xs:string"/> <xs:element name="zip" type="ziptype" minOccurs="0"/> <xs:element name="phoneno" type="phonetype"/> </xs:sequence> </xs:group> <xs:simpleType name="numbertype"> <xs:restriction base="xs:positiveInteger"> <xs:minInclusive value="1"/> <xs:maxInclusive value="999"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="ziptype"> <xs:restriction base="xs:string"> <xs:pattern value="d{6}"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="phonetype"> <xs:restriction base="xs:string"> <xs:pattern value="d{4}-d{8}"/> </xs:restriction> </xs:simpleType> <xs:attributeGroup name="orderatt"> <xs:attribute name="orderID"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:length value="4"/> <xs:pattern value="[A]d{3}"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="orderDate"> <xs:simpleType> <xs:restriction base="xs:date"/> </xs:simpleType> </xs:attribute> </xs:attributeGroup> </xs:schema>
|
实例文件:
<?xml version="1.0" encoding="UTF-8"?> <Orders xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///F:/Record/webservice/Orders.xsd"> <Order orderID="A002" orderDate="2014-11-30"> <name>文具</name> <number>17</number> <city>青岛</city> <phoneno>0543-12345678</phoneno> </Order> <Order orderID="A003" orderDate="2014-11-28"> <name>书籍</name> <number>233</number> <city>滨州</city> <phoneno>0543-18363979</phoneno> </Order>
</Orders>
|