I have the following XML:
<items>
<item min="1" max="3"> </item>
<item min="2" max="7"> </item>
<item min="1" max="2"> </item>
</items>
And I need to check for every item if min is always smaller than max. Expected output for this input would be false
as @min="2"
is not smaller than @max="2"
.
I've tried something similar to:
every $min,$max in //item/@min, //item/@max satisfies ...
But that's obviously not working. Any ideas?
You don't need to use satisfies
, just invert the condition and use not(...)
.
This query will return all @min
attributes that fulfill the condition:
//item/@min[not(. >= //item/@max)]
If you want to use satisfies
, use this query:
//item/@min[every $max in //item/@max satisfies . < $max]
If you want to know whether all elements fulfill the condition, check no elements do not fulfill it:
not(//item/@min[. >= //item/@max])
You could even do without a predicate (XPath/XQuery comparisons have a set-like semantic, this means true iff one @min
value that is equal or greater than one @max
value):
not(//item/@min >= //item/@max)
您没有非常清楚地表达您的要求,但听起来好像您希望最高@min小于最低@max,这将是
max(item/@min) lt min(item/@max)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.