当前位置: 代码迷 >> XML/SOAP >> xsd中怎么根据一个boolean属性来决定另一个属性
  详细解决方案

xsd中怎么根据一个boolean属性来决定另一个属性

热度:540   发布时间:2012-02-07 17:45:37.0
xsd中如何根据一个boolean属性来决定另一个属性?
我想写个xsd,定义如下的xml 

XML code

<parent haschild="true">
   <child></child>
</parent> 



当haschild=true的时候,可以有child子节点,为false的时候不能有child子节点。
请问怎么写才能根据haschild的值来决定child节点的出现与否?

------解决方案--------------------
设计问题,这样做是多余的。当parent 有 child 时,本身就代表了 hasChild = true,当 parent 不含 child 时,就代表了 hasChild = false。
xsd 是用来验证结构的,不是用来执行逻辑判断的。
  相关解决方案