XML模式元素名称灵活性

时间:2013-07-11 21:08:20

标签: xml xsd xml-validation

我有xml可能是

<group>
  <location/>
  <persistent/>
</group>

<group>
  <ui-location/>
  <persistent/>
</group>

有没有办法为u-part设置通配符,或者是否有某种方式可以说出现在那里的元素可以是位置还是ui-location?

1 个答案:

答案 0 :(得分:1)

回答你问题的第二部分。您可以使用xsd:choice

  出现在那里的

元素可以是location或ui-location

<xsd:sequence>
    <xsd:choice minOccurs="1" maxOccurs="1">
        <xsd:element name="location" type="xsd:string"/>
        <xsd:element name="ui-location" type="xsd:string"/>
    </xsd:choice>
</xsd:sequence>