XML Schema:根据父元素的属性值限制子元素? [英] XML Schema: Restrict child element based on attribute value of parent element?

查看:40
本文介绍了XML Schema:根据父元素的属性值限制子元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以根据 XML Schema 中父元素的属性值来限制 XML 元素的子元素的使用?架构必须是什么样子的?

Is there any way to restrict the use of an XML element's sub elements, depending on the attribute value of the parent element in XML Schema? How does the schema have to look like?

<option name="mike" value="excset">
  <excludingsets>
    <excludingset>
      <option name="hd"/>
    </excludingset>
  </excludingsets>
</option>
<option name="mike" value="args">
  <arguments>
    <argument name="kjk" validatortype="regex">
      <regex value="dkas"/>
    </argument>
  </arguments>
</option>

正如你在这个例子中看到的,元素 应该只在 的属性值为 value= 时才有效"excset",以及元素 如果它有 value="args".

As you can see in this example, the element <excludingset> should only be valid if the attribute value of <option> is value="excset", and the element <arguments> if it has value="args".

提前致谢.

推荐答案

不在 W3C XML Schema 1.0 中.你可以在 ISO RelaxNG 中,我相信,在 W3C XML 模式 1.1.

Not in W3C XML Schema 1.0. You can in ISO RelaxNG and, I believe, in W3C XML Schema 1.1.

这篇关于XML Schema:根据父元素的属性值限制子元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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