xml 模式中是否有任何方法可以让 xml 元素中的属性始终大于另一个属性? [英] Is there any way in xml schema to let an attribute always be greater than another one in an xml element?

查看:23
本文介绍了xml 模式中是否有任何方法可以让 xml 元素中的属性始终大于另一个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是xml:

<range from="100" to="200"/>

那么,如何写一个xsd来保证to属性总是大于from?

So, how to write an xsd to ensure that the attribute to is always larger than from?

推荐答案

以下示例展示了如何在您的案例中添加 XSD 1.1 断言:

Here is a sample to see how you can add an XSD 1.1 assert in your case:

<xs:complexType>
    <xs:attribute name="to" type="xs:integer"/>
    <xs:attribute name="from" type="xs:integer"/>
    <xs:assert test="@to > @from"/>
</xs:complexType>

在assert"元素的test"属性中,您可以引入 XPath 2.0 表达式.

In the "test" attribute from the "assert" element you can introduce an XPath 2.0 expression.

这篇关于xml 模式中是否有任何方法可以让 xml 元素中的属性始终大于另一个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆