order by clause demo : order by « XQuery « XML






order by clause demo



File: Data.xml
<order>
  <car model="A">
    <name language="en">name 1</name>
  </car>
  <car model="B">
    <name language="en">name 2</name>
  </car>
  <car model="B">
    <name language="en">name 3</name>
  </car>
</order>


File: Query.xquery
for $prod in doc("Data.xml")/order/car
where $prod/@model = "B"
order by $prod/name
return $prod/name

Output:

<?xml version="1.0" encoding="UTF-8"?>
<name language="en">name 2</name>
<name language="en">name 3</name>

 








Related examples in the same category

1.The order by clause
2.Using multiple inventorying specifications
3.Inadvertent resorting in document inventory
4.without inadvertent resorting
5.Using an inventory comparison
6.order by stateCt