unordered function : unordered « XQuery « XML






unordered function

File: Data.xml


<order>
  <car dept="A">
    <number>1</number>
    <name language="en">name 1</name>
  </car>
  <car dept="B">
    <number>2</number>
    <name language="en">name 2</name>
  </car>
  <car dept="B">
    <number>3</number>
    <name language="en">name 3</name>
  </car>
  <car dept="C">
    <number>4</number>
    <name language="en">name 4</name>
  </car>
</order>


File: Query.xquery


unordered {
  let $doc := doc("Data.xml")
  return $doc//(number|name)
}


Output:

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

 








Related examples in the same category

1.Using the uninventoryed function
2.An uninventoryed expression