<attribute name="属性名"
default="默认值" fixed="固定值" use="option|required" type="数据类型名">
e.g.
1 <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema"> 2 <xs:element name="name"> 3 <xs:complexType> 4 <xs:element name="first" type="xs:string" /> 5 <xs:attribute name="age" type="xs:integer" use="optional" /> 6 </xs:complexType> 7 </xs:element> 8 </xs:schema>
e.g.
<?xml version="1.0" encoding="utf-8"?> <xs:schema id="orders" targetNamespace="http://tempuri.org/orders.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/orders.xsd" xmlns:mstns="http://tempuri.org/orders.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:complexType name="t_order"> <xs:sequence> <xs:element name="name" type="xs:string" /> <xs:element name="number"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="1" /> <xs:maxInclusive value="99" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="city" type="xs:string" /> <xs:element name="zip"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:length value="6" /> <xs:pattern value="d{6}" /> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> <xs:attribute name="orderID"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="Ad{3}" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="orderDate" type="xs:date" /> </xs:complexType> <xs:element name="Orders"> <xs:complexType> <xs:sequence> <xs:element minOccurs="1" maxOccurs="unbounded" name="Order" type="t_order" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>