xs:complexType使用方法比较:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://mynamespace/schema"><xs:element name="书本">
<xs:complexType>
<xs:attribute name="名称" type="xs:string"/>
<xs:attribute name="作者" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<书本 xmlns="http://mynamespace/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mynamespace/schema file:///C:/Documents%20and%20Settings/Administrator/%e6%a1%8c%e9%9d%a2/Untitled1.xsd" 名称="书籍" 作者="hehe"/>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="element" type="myElementType"/>
<xs:complexType name="myElementType">
<xs:attributeGroup ref="myAttributeGroup"/>
</xs:complexType>
<xs:attributeGroup name="myAttributeGroup">
<xs:attribute name="someattribute1" type="xs:integer" use="required"/>
<xs:attribute name="someattribute2" type="xs:string"/>
</xs:attributeGroup>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/Documents%20and%20Settings/Administrator/%e6%a1%8c%e9%9d%a2/Untitled1.xsd" someattribute1="4"/>