【发布时间】:2013-12-20 22:31:26
【问题描述】:
我想问一下是否可以在 XML xsd 模式中声明依赖属性...
例子:
<xsd:simpleType name="packCategories">
<xsd:restriction base="xsd:byte">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="4"/>
</xsd:restriction>
</xsd:simpleType>
<xs:element name="pack">
<xs:complexType>
<!-- elements go here -->
<xs:attribute type="packCategories" name="category" use="required"/>
<xs:attribute type="xs:string" name="explanation" use="optional"/>
</xs:complexType>
</xs:element>
这里一切似乎都很好,但是,如果类别属性等于 4,我希望说明属性是强制性的。这可能吗?或许还有元素呢?
【问题讨论】: