有没有办法指定XSD中需要2个属性中的一个?
例如,我有这样的定义:
<xs:attribute name="Name" type="xs:string" use="optional" />
<xs:attribute name="Id" type="xs:string" use="optional" />
Run Code Online (Sandbox Code Playgroud)
我希望能够定义至少需要其中一个.那可能吗?
jer*_*ahn 23
XSD 1.1将允许您使用断言执行此操作.
<xsd:element name="remove">
<xsd:complexType>
<xsd:attribute name="ref" use="optional"/>
<xsd:attribute name="uri" use="optional"/>
<xsd:assert test="(@ref and not(@uri)) or (not(@ref) and @uri)"/>
</xsd:complexType>
</xsd:element>
Run Code Online (Sandbox Code Playgroud)