加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 02:01:00 所属栏目:百科 来源:网络整理
导读:我有以下XML标签 price currency="euros"20000.00/price 如何将currency属性限制为以下之一: 欧元 磅 美元 和价格到双? 我只是得到一个错误,当我尝试两种类型,这里是我到目前为止: xs:element name="price" xs:complexType xs:attribute name="currency
我有以下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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读