<?xml version="1.0" encoding="UTF-8"?> <xsi:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/" xmlns:tns="http://www.w3.org/" elementFormDefault="qualified"> <xsi:element name="persons"> </xsi:element> </xsi:schema>
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/family" xmlns:tns="http://www.example.org/family" elementFormDefault="qualified"> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"></xs:element> <xs:element name="lastname" type="xs:string"></xs:element> </xs:sequence> <xs:anyAttribute/><!-- <anyAttribute> 元素使我们有能力通过未被 schema 规定的属性来扩展XML文档! --> </xs:complexType> </xs:element> </xs:schema>
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/children" xmlns:tns="http://www.example.org/children" elementFormDefault="qualified"> <xs:attribute name="sex"><!-- 创建属性名称为sex的属性 --> <xs:simpleType> <xs:restriction base="xs:string"><!-- 创建的约束条件 --> <xs:enumeration value="男"></xs:enumeration><!-- 规定属性值得范围 --> <xs:enumeration value="女"></xs:enumeration> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:schema>
<?xml version="1.0" encoding="UTF-8"?> <persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org" xmlns:fm="http://www.example.org/family" xmlns:ch="http://www.example.org/children" xsi:schemaLocation="http://www.w3.org per.xsd http://www.example.org/family family.xsd http://www.example.org/children children.xsd"> <fm:person ch:sex="男"> <fm:firstname></fm:firstname> <fm:lastname></fm:lastname> </fm:person> <fm:person ch:sex="女"> <fm:firstname></fm:firstname> <fm:lastname></fm:lastname> </fm:person> </persons>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。