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

xml – 我们可以根据XSD中任何其他元素的值使元素成为可选元素或

发布时间:2020-12-16 22:43:29 所属栏目:百科 来源:网络整理
导读:在XSD中我有一个元素x取值(a,b) 还有另一个要素y 有没有办法使用XSD,这样我可以在x的值为b时将y设为必需,如果x的值为a,则可选 解决方法 看看 XML Schema Part 0: Primer Second Edition,第 2.2.1 Occurrence Constraints节. 它说: In general,an element is
在XSD中我有一个元素x取值(a,b)

还有另一个要素y

有没有办法使用XSD,这样我可以在x的值为b时将y设为必需,如果x的值为a,则可选

解决方法

看看 XML Schema Part 0: Primer Second Edition,第 2.2.1 Occurrence Constraints节.

它说:

In general,an element is required to appear when the value of minOccurs is 1 or more. The maximum number of times an element may appear is determined by the value of a maxOccurs attribute in its declaration. This value may be a positive integer such as 41,or the term unbounded to indicate there is no maximum number of occurrences. The default value for both the minOccurs and the maxOccurs attributes is 1.

由于无法从XML Schema中的其他模式内容推断出属性值,因此您无法实现(使用XML Schema).

(我不知道Relax NG是否可以这样做,但你可以调查它是否支持这种依赖于内容的定义.)

(编辑:李大同)

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

    推荐文章
      热点阅读