1

I have the below XML.

<?xml version="1.0" encoding="utf-8" ?>
<Items>
    <Item type="none" attNone1="test" attNone2="test3" />
    <Item type="action" attAction1="test" attAction2="test2" />
</Items>

I need to create an XSD based on some rules:

1) the attribute "type" is required.

2) If the attribute value should be "none" or "action"

3) If the attribute value is "none" I should have two other required attribute, "attNone1" and "attNone2". I should not accept "attAction1" or "attAction2"

4) If the attribute value is "action" I should have two other required attribute, "attAction1" and "attAction2". I should not accept "attNone1" or "attNone2"

Any idea how to do this XSD?

Thanks in advance,

Regards,

4

1 回答 1

1

XSD 1.0 不允许一个属性的类型取决于另一个属性的值的“共现约束”。

在 XSD 1.1 中,您可以使用为此目的而发明的“条件类型分配”。Xerces 和 Saxon 目前支持 XSD 1.1。

于 2013-07-25T14:02:50.423 回答