XML file:
<reference xmlns= "http://www.w3school.com.cn" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://www.w3school.com.cn j.xsd" ><author authorloc= "1" > Chen Luyao </author><title> The extraction and logical description of structure Trust mode of information document </title><type>J</type><publisher> Computer Application Research </publisher>< publish_year>2010</publish_year><volumn_mark>27</volumn_mark><page_number>4624-4629 </page_number></reference>
Schema file (j.xsd):
<?xml version= "1.0" encoding= "GB2312"? ><xs:schema xmlns:xs= "Http://www.w3.org/2001/XMLSchema" xmlns= "http ://www.w3school.com.cn "targetnamespace=" http://www.w3school.com.cn "elementformdefault=" qualified "><XS: Element name= "Reference" ><xs:complextype><xs:sequence><xs:element name= "author" type= " Authorinfo "minoccurs=" 1 "maxoccurs=" 1 "/><xs:element name=" title "Type=" Xs:string "minoccurs=" 1 "maxOccurs=" 1 " /><xs:element name= "type" type= "xs:string" minoccurs= "1" maxoccurs= "1"/><xs:element name= "Publish" type= "Xs:string" minoccurs= "0" maxoccurs= "1"/><xs:element name= "publisher" Type= "Xs:string" minoccurs= "1" maxOccurs = "1"/><xs:element name= "Publish_year" type= "xs:string" minoccurs= "1" maxoccurs= "1"/><xs:element name= " Volumn_mark "type=" xs:string "minoccurs=" 1 "maxoccurs=" 1 "/><xs:element name=" Page_number "minOccurs=" 1 " maxoccurs= "1" ><xs:simpletype><xs:restriction base= "xs:string" ><xs:pattern value= "(\d{1,4}-)? \d{1,4} "/></xs:restriction></xs:simpletype></xs:element></xs:sequence> </xs:complextype></xs:element><xs:complextype name= "Authorinfo" ><xs:simpleContent>< Xs:extension base= "xs:string" ><xs:attribute name= "Authorloc" use= "Required" ><XS:SIMPLETYPE><XS: Restriction base= "Xs:integer" ><xs:enumeration value= "1"/></xs:restriction></xs:simpletype> </xs:attribute></xs:extension></xs:simpleContent></xs:complexType></xs:schema>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
An example of a complete schema validation xml