匹配以下内容的 XML 模式(“所有",具有无限的 maxOccurs?) [英] XML Schema to match the following ("all", with unbounded maxOccurs?)

查看:32

>

<xs:complexType><xs:choice maxOccurs="unbounded"><xs:element ref="B"/><xs:element ref="C"/></xs:choice></xs:complexType></xs:element>

非常酷!

Say I have an element, call it <A>. <A> can have children types of <B> and <C>. Now - here's the twist. Any number of <B> and <C> children can live in <A>, in any order.

For example:

<A>
  <C>
  <C>
  <B>
  <C>
  <B>
  <B>
  <C>
  ...
</A>

Is there a schema rule that fits this? Seems like "all" would work, if I could put maxOccurs="unbounded", but I guess that's not legal.

解决方案

Answering my own question -- looks like trang (http://www.thaiopensource.com/relaxng/trang.html) gave me the anwer:

<xs:element name="A">
  <xs:complexType>
    <xs:choice maxOccurs="unbounded">
      <xs:element ref="B"/>
      <xs:element ref="C"/>
    </xs:choice>
  </xs:complexType>
</xs:element>

Very cool!

这篇关于匹配以下内容的 XML 模式(“所有",具有无限的 maxOccurs?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆