Useful-function: between-inclusive
File: Data.xml
<order>
<car model="A">
<id>1</id>
<name language="en">name 1</name>
<colorChoices>navy black</colorChoices>
</car>
<car model="B">
<id>2</id>
<name language="en">name 2</name>
</car>
<car model="B">
<id>8</id>
<name language="en">name 3</name>
</car>
</order>
File: Query.xquery
declare namespace functx = "http://www.java2s.com";
declare function functx:between-inclusive
($value as xs:anyAtomicType, $minValue as xs:anyAtomicType,$maxValue as xs:anyAtomicType) as xs:boolean {
$value >= $minValue and $value <= $maxValue
};
(: Example call :)
let $prod := doc("Data.xml")//car[1]
return functx:between-inclusive ($prod/id, 1, 5)
Related examples in the same category