I have an XQUERY 3.0 as follows on an XML file with 3 Purchase Order recs with 5 items:
for $PurchaseOrder in doc("C:\Users\thebluephantom\Desktop\order.xml")//PurchaseOrder
order by xs:integer($PurchaseOrder/Item/Quantity) ascending
return $PurchaseOrder/Items/Item/Quantity
that does not return the results as I want. It has a typical nested structure e.g.
<PurchaseOrders>
<PurchaseOrder PurchaseOrderNumber="99503" OrderDate="1999-10-20">
<Address Type="Shipping">
<Name>Ellen Adams</Name>
...
</Address>
<Address Type="Billing">
<Name>Tai Yee</Name>
<Street>8 Oak Avenue</Street>
...
</Address>
<DeliveryNotes>Please leave packages in shed by driveway. </DeliveryNotes>
<Items>
<Item PartNumber="872-AA">
<ProductName>Lawnmower</ProductName>
<Quantity>100</Quantity>
<USPrice>148.95</USPrice>
<Comment>Confirm this is electric</Comment>
</Item>
<Item PartNumber="926-AA">
<ProductName>Baby Monitor</ProductName>
<Quantity>20</Quantity>
<USPrice>39.98</USPrice>
<ShipDate>1999-05-21</ShipDate>
</Item>
</Items>
</PurchaseOrder>
<PurchaseOrder PurchaseOrderNumber="99505" OrderDate="1999-10-22">
...
I get the result on 3 POs and 5 Order Items:
<Quantity>100</Quantity>
<Quantity>20</Quantity>
<Quantity>1</Quantity>
<Quantity>1000</Quantity>
<Quantity>1</Quantity>
Looking at a number of tutorials on groupings etc. I am not able to find out if this is in fact possible.