Wrapping results in a new element : output « XQuery « XML

Wrapping results in a new element

File: Data.xml

  <car model="ACC">
    <name language="en">name 1</name>
  <car model="BCC">
    <name language="en">name 2</name>
  <car model="BCC">
    <name language="en">name 3</name>
File: Query.xquery

  for $car in doc("Data.xml")/order/car
  where $car/@model='ACC'
  order by $car/name
  return $car/name


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


Related examples in the same category

1.Constructing elements using XML-like syntax
2.Adding attributes to results
3.Adding an attribute to an element
4.Removing a child from an element
5.Turning content into markup