-- 作者:xml-linguist
-- 发布时间:11/13/2007 11:29:00 AM
-- 我问题一大堆
我相信认真的浏览一下schema部分的帖子,我的问题应该可以解决。但是现在时间比较匆忙,先提出急需解决的问题。 先看book.xml文件: <?xml version="1.0" encoding="GB2312"?> <booklist xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:noNamesapceSchemeLocation="book.xsd"> <book sales="Y"> <code>F3333</code> <title>书名一</title> <authorlst> <author>张三</author> </athorlst> <price>58</price> </book> <book sales="N"> <code>F444ode> <title>书名二</title> <authorlst> <author>李四</author> </athorlst> <price>55/price> </book> </booklist> 再看该xml文件的两个xsd文件: book.xsd (01) <?xml version="1.0" encoding="GB2312"?> <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <xsd:element name="booklist"> <xsd:complextType content="elementOnly"> <xsd:element name="book" type="bookType" minOccurs="1" maxOccurs="unbounded"/> </xsd:complexType> </xsd:element> <xsd:complexType name="bookBase"> <xsd:sequence> <xsd:element name="code" type="xsd:string"/> <xsd:element name="title" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="bookType" base="bookBase" derivedBy=“extension”> <xsd:sequence> <xsd:element name="authorlist" type="authorlistType"/> <xsd:element name="price" type="xsd:decimal"/> </xsd:sequence> <xsd:attribute name="sale" use="required"> <xsd:simpleType base="xsd:NMTOKEN"> <xsd:enumeration value="Y"/> <xsd:enumeration value="N"/> </xsd:simpleType> </xsd:attribute> </xsd:complexType> <xsd:complexType name="authorlistType" content="elementOnly"> <xsd:element name="author" type="xsd:string minOccurs="0" maxOccurs="1"/> </xsd:complexType> </xsd:schema> book.xsd (02) <?xml version="1.0" encoding="GB2312"?> <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <xsd:element name="booklist"> <xsd:complextType content="elementOnly"> <xsd:element name="book" type="bookType" minOccurs="1" maxOccurs="unbounded"/> </xsd:complexType> </xsd:element> <xsd:complexType name="authorBase"> <xsd:element name="author" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/> </xsd:complexType> <xsd:complexType name="authorType" base="authorBase" derivedBy="restriction“> <xsd:element name="author" type="xsd:string minOccurs="0" maxOccurs="1"/> </xsd:complexType> <xsd:complexType name="bookType" content="elementOnly"> <xsd:sequence> <xsd:element name="code" type="xsd:string"/> <xsd:element name="title" type="xsd:string"/> <xsd:element name="authorist" type="authorType"/> <xsd:element name="price" type="xsd:decimal"/> </xsd:sequence> </xsd:complexType> </xsd:schema> ============================== [face=楷体_GB2312][color=#0000FF]先在这里谢谢大家了![/color][/face]
|