好的初始查询是固定的,但我还是有些困惑,我很困惑。
这里是xml:
<?xml version="1.0" encoding="UTF-8"?>
<bookstore xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='schema.xsd'>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
<photo>http://puu.sh/gNzTB/258d022e33.jpg</photo>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
<photo>http://puu.sh/gNzV9/e27dfc1b55.jpg</photo>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
继承架构:
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<!-- define elements (elements with attributes or other elemens inside are complex) -->
<xsd:element name='author' type='xsd:string' />
<xsd:element name='year' type='xsd:gYear' />
<xsd:element name='price' type='xsd:decimal' />
<xsd:element name='photo' type='xsd:anyURI' />
<!-- define attributes -->
<xsd:attribute name='category' type='xsd:string'/>
<xsd:attribute name='lang' type='xsd:string'/>
<!-- structure -->
<xsd:element name='title'>
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base='xsd:string'>
<xsd:attribute ref='lang'/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name='book'>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref='title'/>
<xsd:element ref='author' maxOccurs='10'/>
<xsd:element ref='year'/>
<xsd:element ref='price'/>
<xsd:element ref='photo' minOccurs='0'/>
</xsd:sequence>
<xsd:attribute ref='category'/>
</xsd:complexType>
</xsd:element>
<xsd:element name='bookstore'>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref='book' maxOccurs='unbounded'/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
澄清我的意思是我遇到了错误:
<xsd:element name='author' type='xsd:string' maxOccurs='10'/>
但不是:
<xsd:element ref='author' maxOccurs='10'/>
感谢 - 你!