XML Schema minOccurs/maxOccurs 默认值 [英] XML Schema minOccurs / maxOccurs default values
问题描述
我想知道 XML Schema 规范如何处理这些情况:
I'm wondering how the XML Schema specification handles these cases:
<xsd:element minOccurs="1" name="asdf"/>
没有给出 maxOccurs -> 这是基数 [1..1] 吗?
No maxOccurs given -> Is this the cardinality [1..1]?
<xsd:element minOccurs="5" maxOccurs="2" name="asdf"/>
我认为这根本无效?
<xsd:element maxOccurs="2" name="asdf"/>
这是基数 [0..2] 还是 [1..2]?
Is this the cardinality [0..2] or [1..2]?
是否有关于 XML Schema 规范如何处理这些情况的官方"定义?
Is there an "official" definition on how the XML Schema spec handles these cases?
推荐答案
minOccurs
和 maxOccurs
的默认值为 1.因此:
The default values for minOccurs
and maxOccurs
are 1. Thus:
<xsd:element minOccurs="1" name="asdf"/>
基数为 [1-1] 注意:如果指定only minOccurs 属性,则它不能大于 1,因为 maxOccurs 的默认值为 1.
cardinality is [1-1] Note: if you specify only minOccurs attribute, it can't be greater than 1, because the default value for maxOccurs is 1.
<xsd:element minOccurs="5" maxOccurs="2" name="asdf"/>
无效
<xsd:element maxOccurs="2" name="asdf"/>
基数是[1-2] 注意:如果你指定only maxOccurs 属性,它不能小于1,因为minOccurs 的默认值是1.
cardinality is [1-2] Note: if you specify only maxOccurs attribute, it can't be smaller than 1, because the default value for minOccurs is 1.
<xsd:element minOccurs="0" maxOccurs="0"/>
是使元素被禁止的有效组合.
is a valid combination which makes the element prohibited.
有关更多信息,请参阅http://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints
这篇关于XML Schema minOccurs/maxOccurs 默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!