I want to rearrange the Order tags in the input xml given below such that the nodes follow this sequence
BUY_ONLY, BOGO, GET_ONLY
This is my sample Orders.xml The Order tags have to be re arranged based on the OrderType tag inside them
(: XQuery Module :)
declare namespace functx = "http://www.functx.com";
for $order in doc("order.xml")/Orders/Order
let $buyOnly := $order[OrderType/text()="BUY_ONLY"]
let $getOnly := $order[OrderType/text()="GET_ONLY"]
let $bogo := $order[OrderType/text()="BOGO"]
return
<Orders>
{
if(exists($buyOnly) and exists($getOnly) and exists($bogo)) then
(
$buyOnly,
$getOnly,
$bogo
)
else ()
}
</Orders>
Can I rearrange the Order nodes without using FLWOR expressions?