XML 模式 - 依赖于可选属性存在的子元素 [英] XML Schema - child elements dependent on existence of optional attribute
本文介绍了XML 模式 - 依赖于可选属性存在的子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 XSD 中定义以下场景:
Is it possible to define in XSD the following scenario:
父元素有一个属性
Parent element has an attribute that
是可选的.
如果属性不是
present in XML, at least one child
element must exists.
如果
If the
attribute is present, there can be
zero or more child elements.
示例:
有效
<parent externel-source="some_name" />
<parent externel-source="some_name">
<child>some value</child>
</parent>
<parent>
<child> some value</child>
</parent>
无效
<parent />
推荐答案
不,我不这么认为.
这篇关于XML 模式 - 依赖于可选属性存在的子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文