【问题标题】:XSD a node with a choice must exist with a specific type of node chosenXSD 具有选择的节点必须存在并选择特定类型的节点
【发布时间】:2012-09-28 12:10:12
【问题描述】:

所以我有以下 xsd 类型

    <xs:complexType name="nodeType">
        <xs:sequence>
            <xs:choice>
                <xs:element name="c0" type="c0type"/>
                <xs:element name="c1" type="c1type"/>
                <xs:element name="c2" type="c2type"/>
                <xs:element name="c3" type="c3type"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="root">
      <xs:complexType>
        <xs:sequence>
            <xs:element name="nodes">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="node" type="nodeType" minOccurs="1" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
  </xs:element>

现在我面临的问题是我需要“节点”元素在“根”元素中至少存在一次,并且选择的元素类型为“c0type”。

&lt;node&gt;&lt;c0 /&gt;&lt;/node&gt;...&lt;node&gt;&lt;c3 /&gt;&lt;/node&gt; 可以出现任意数量的组合,但必须至少存在 1 个&lt;node&gt;&lt;c0 /&gt;&lt;node&gt;

是否可以通过xsd来实现这个验证?

谢谢

基兰

【问题讨论】:

    标签: validation xsd schema choice


    【解决方案1】:

    无法使用 XSD 1.0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-26
      • 1970-01-01
      相关资源
      最近更新 更多