开发者

XSD: same attribute's values restriction

I have XML like this:

...
<link from="a" to="b"/>
...

Is it possible to define XSD where I can prohibit loop-link开发者_如何学JAVAing, so @from never equal to @to?


With the version 1.1 of the W3C XML schema language (the version is still under development but Xerces and Saxon already implement some features) you can use e.g

<xs:element name="link">
  <xs:complexType>
    <xs:attribute name="from" type="xs:string"/>
    <xs:attribute name="to" type="xs:string"/>
    <xs:assert test="@from ne @to"/>
  </xs:complexType>
</xs:element>

See http://www.w3.org/TR/xmlschema11-1/#cAssertions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜