XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Glen GerstmanSubject: 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.

<vehicleData>
{
for $v in /vehicleData/*
stable order by $v/@time
return $v
}
</vehicleData>

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?

Thanks,
Glen

Postnext
Alberto MassariSubject: Re: attribute order in query result
Author: Alberto Massari
Date: 03 Sep 2004 04:54 PM
Hi Glen,

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
>alphbetically sorted.
>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

but implementation-dependent"

"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.

Hope this helps,
Alberto


Posttop
Glen GerstmanSubject: Re: attribute order in query result
Author: Glen Gerstman
Date: 03 Sep 2004 05:53 PM
Yes, that answers my question.

Thank you,
Glen

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.