【发布时间】:2012-03-27 14:53:42
【问题描述】:
我有一个 XSD 文件,它有两个独立的复杂类型元素(比如 elemOne 和 elemTwo ),可以存储类型为 xs:string 的公共元素(比如 elementRefer )。但我希望我的 XML 将公共元素 elementRefer 存储在两个复杂类型元素中的一个或两者中,前提是它们都指向相同的 elementRefer 值。
如何在 XSD 中进行这种限制?有人可以帮我解决这个问题吗..
<root>
<sample1>
<name>johnson</name>
<city>california</city> <!-- optional occurence element-->
</sample1>
<sample2>
<name>andrew</name>
<age>19</age>
<city>california</city> <!-- optional occurence element-->
</sample2>
</root>
现在我想在 XSD 中创建一个约束,以便出现标签 city
在 sample1 或 sample2 或两者下,只要它们具有相同的值。
【问题讨论】: