<?xml version="1.0" encoding="utf-8"?> <info> <student> <name>Lucy</name> <age>18</age> </student> <teacher> <name>Brun</name> <age>40</age> </teacher> </info>
<?xml version="1.0" encoding="utf-8"?> <student:info xmlns:student="https://www.student.net" xmlns:teacher="https://www.teacher.net"> <student:studentInfo student:id="001"> <student:name>Lucy</student:name> <student:age>18</student:age> </studentInfo> <teacher:teacherInfo> <teacher:name>Brun</teacher:name> <teacher:age>40</teacher:age> </teacher:teacherInfo> </student:info>
<?xml version="1.0" encoding="utf-8"?> <info xmlns="https://wwww.default.net" xmlns:teacher="https://www.teacher.net"> <studentInfo id="001"> <name>Lucy</name> <age>18</age> </studentInfo> <teacher:teacherInfo> <teacher:name>Brun</teacher:name> <teacher:age>40</teacher:age> </teacher:teacherInfo> </info>
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="someURI"> <!-- XML Schema文档中元素及属性 --> <xs:element name="xxx" type="yyy"/> ... </xs:schema>
<xs:simpleType> <xs:restriction base="xs:xxx"> <xs:数据类型细节描述 value="value"> ... </xs:restriction> <xs:simpleType>
<xs:complexType> <xs:某个限定作用的元素> <xs:element name="xxx_1" type="xs:yyy_1"/> <xs:element name="xxx_2" type="xs:yyy_2"/> </xs:某个限定作用的元素> </xs:complexType>
<xs:element name="xxx"> <xs:complexType> <xs:某个限定作用的元素> <xs:element name="xxx_1" type="xs:yyy_1"/> <xs:element name="xxx_2" type="xs:yyy_2"/> </xs:某个限定作用的元素> </xs:complexType> </xs:element>
第二种:
<xs:element name="xxx" type="someType"/> <xs:complexType name="someType"> <xs:摸个限定作用的元素> <xs:element name="xxx_1" type="xs:yyy_1"/> <xs:element name="xxx_2" type="xs:yyy_2"/> </xs:摸个限定作用的元素> </xs:complexType>
<xs:group name="GroupName"> <xs:Order>(Order指示器在定义group时必须定义) ...(元素组中的元素) </xs:Order> </xs:group>
attributeGroup 属性组
<xs:attributeGroup name="属性组名"> ...(属性组中包含的各个属性的定义) </xs:attributeGroup>
any元素
<xs:any/>;通过未被 schema 规定的元素来拓展 XML 文档
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <person> <firstname>David</firstname> <lastname>Smith</lastname> <children> <childname>mike</childname> </children> </person>
anyAttribute元素
<xs:anyAttribute/> : 通过未被 schema 规定的属性来扩展 XML 文档
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> <xs:anyAttribute/> </xs:complexType> </xs:element> <person gender="male"> <firstname>David</firstname> <lastname>Smith</lastname> </person>
原文:https://www.cnblogs.com/lnlin/p/9575693.html