XML模式如何通过枚举限制属性

前端之家收集整理的这篇文章主要介绍了XML模式如何通过枚举限制属性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下XML标签
<price currency="euros">20000.00</price>

如何将currency属性限制为以下之一:

>欧元
>磅
>美元

和价格到双?

我只是得到一个错误,当我尝试两种类型,这里是我到目前为止:

<xs:element name="price">
    <xs:complexType>
        <xs:attribute name="currency" type="xs:string">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="pounds" />
                    <xs:enumeration value="euros" />
                    <xs:enumeration value="dollars" />
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
</xs:element>
您的价格定义中似乎缺少数值。
尝试以下操作:
<xs:simpleType name="curr">
  <xs:restriction base="xs:string">
    <xs:enumeration value="pounds" />
    <xs:enumeration value="euros" />
    <xs:enumeration value="dollars" />
  </xs:restriction>
</xs:simpleType>



<xs:element name="price">
        <xs:complexType>
            <xs:extension base="xs:decimal">
              <xs:attribute name="currency" type="curr"/>
            </xs:extension>
        </xs:complexType>
</xs:element>
原文链接:https://www.f2er.com/xml/294015.html

猜你在找的XML相关文章