Subject:attribute order in query result Author:Glen Gerstman Date:03 Sep 2004 04:01 PM
I'm new to XQUERY, actually I'm new even to XML.
I thought a simple test of xquery would be to order a file by an attribute.
The file contains several kinds elements(I hope is the right word), but all have a time attribute.
This is my attempt to sort all the elements by time.
for $v in /vehicleData/*
stable order by $v/@time
It seems to work, except the attributes in each element appear to be alphbetically sorted.
I would prefer that they kept their original order.
Is this done easily?
Subject:Re: attribute order in query result Author:Alberto Massari Date:03 Sep 2004 04:54 PM
At 16.03 03/09/2004 -0400, stylus-studio-xquery Listmanager wrote:
>It seems to work, except the attributes in each element appear to be
>I would prefer that they kept their original order.
>Is this done easily?
Unfortunately XML doesn't assign an order to attributes: as the XQuery
specs (XQuery and XPath Data Model, § 2.4 Document Order) say, "document
order" for attribute is
"attribute Nodes immediately follow the Namespace Nodes of the element with
which they are associated. The relative order of Attribute Nodes is stable
"stable" means that their relative order will not change for the entire
query execution; "implementation-dependent" means that every processor is
free to choose its own algorithm for sorting them.