schema举例一
schema举例一:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 3 targetNamespace="http://www.weshare.com.cn" 4 xmlns="http://www.weshare.com.cn" 5 elementFormDefault="qualified"> 6 7 <xs:element name="actionGroup"> 8 <xs:complexType> 9 <xs:sequence> 10 <xs:element name="action" maxOccurs="unbounded"> 11 <xs:complexType> 12 <xs:attributeGroup ref="attributeGroup"/> 13 </xs:complexType> 14 </xs:element> 15 </xs:sequence> 16 <xs:attribute name="id" type="xs:string" use="required"></xs:attribute> 17 </xs:complexType> 18 </xs:element> 19 20 <xs:attributeGroup name="attributeGroup"> 21 <xs:attribute name="id" type="xs:string" use="required"/> 22 <xs:attribute name="fun" type="xs:string" use="required"/> 23 <xs:attribute name="type" type="xs:string" use="required"/> 24 <xs:attribute name="param" type="xs:string" use="required"/> 25 </xs:attributeGroup> 26 27 </xs:schema>
XML范例:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <actionGroup id="3333" 3 xmlns="http://www.weshare.com.cn" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:noNamespaceSchemaLocation="file:///C:/workspace/Tools/UpdateProject/script_update_common/src/main/resources/schema/project/actionGroup.xsd"> 6 7 <action id="" fun="" type="" param=""/> 8 <action id="" fun="" type="" param=""/> 9 </actionGroup>
引用示例二:
1 <?xml version="1.0"?> 2 <note 3 xmlns="http://www.w3schools.com" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemaLocation="http://www.w3schools.com note.xsd"> 6 <to>Tove</to> 7 <from>Jani</from> 8 <heading>Reminder</heading> 9 <body>Don't forget me this weekend!</body> 10 </note>