如何在以下XSD文档中声明这些属性?

时间:2017-02-05 16:04:53

标签: xml xsd

在这种情况下,如何在XSD文件中声明元素“book”的“coverimage”属性?我还想将“货币”属性限制为以下货币:美元,欧元,带枚举的磅,通过给出类型(xs:simpleType)定义。我怎么做?

这是我的XML:

<book coverimage="#">
  <title>Who cares</title>
  <autor>Doesn't Matter</autor>
  <price currency="euros">14.99</price>
  <year>1987</year>
</book>

这是我的XSD:

<xs:element name="book" minOccurs="0" maxOccurs="unbounded">
           <xs:complexType mixed="true">
             <xs:sequence>
                <xs:element name="title" type="xs:string"/>
                <xs:element name="autor" type="xs:string"/>
                <xs:element name="price">
                  <xs:complexType>
                    <xs:attribute name="currency" type="xs:string"/>
                  </xs:complexType>
                </xs:element>
                <xs:element name="year" type="xs:integer"/>

0 个答案:

没有答案
相关问题