我想写个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 是用来验证结构的,不是用来执行逻辑判断的。