N
news
Hi everyone
I am now trying to create a schema for the XML document which have the following structure:
In the XML document, there should be a element called book. And the sub-elements of book should be author or editor, title, publisher, year, and so on, which means, in the XML document, either author or editor must appear, but they can not both appear.And the sub-elements can be in any order.I try to use <xsd:all> and <xsd:choice> to solve the problem, but <xs:all> cannot be embedded within another compositor.So the following schema is invalid:
<xsd:complexType name="book_type">
<xsd:all>
<xsd:choice>
<xsd:element name="author"type="xsd:string"/>
<xsd:element name="editor"type="xsd:string"/>
</xsd:choice>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="publisher" type="xsd:string"/>
<xsd:element name="year" type="year_type"/>
</xsd:all>
</xsd:complexType>
Does anybody know how to describe a XML document with the above structure using schema? Any suggestion will be appreciated.
I am now trying to create a schema for the XML document which have the following structure:
In the XML document, there should be a element called book. And the sub-elements of book should be author or editor, title, publisher, year, and so on, which means, in the XML document, either author or editor must appear, but they can not both appear.And the sub-elements can be in any order.I try to use <xsd:all> and <xsd:choice> to solve the problem, but <xs:all> cannot be embedded within another compositor.So the following schema is invalid:
<xsd:complexType name="book_type">
<xsd:all>
<xsd:choice>
<xsd:element name="author"type="xsd:string"/>
<xsd:element name="editor"type="xsd:string"/>
</xsd:choice>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="publisher" type="xsd:string"/>
<xsd:element name="year" type="year_type"/>
</xsd:all>
</xsd:complexType>
Does anybody know how to describe a XML document with the above structure using schema? Any suggestion will be appreciated.