[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: applying a predicate to a sorted sequence

Subject: Re: applying a predicate to a sorted sequence
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 29 Apr 2005 14:46:52 -0400
xpath sort sequence
Kevin,

The easy answer is "yes".

The more complete and correct answer is that you need to distinguish between XPath 2.0 and XPath 1.0 here. In 2.0 the result of a sort will be a sequence (presumably of nodes), which has an order. Filtering it with a predicate should not alter that. (There is a special case if the filtered expression is a step along a reverse XPath axis, but this shouldn't apply to your case as you're filtering a sequence bound to a variable. Although it does seem on reflection that the special case makes the whole thing perhaps worth testing in your implementation....)

In XPath 1.0 there is actually no such thing as a sequence; what you have is actually a node-set, and as such has no intrinsic order. Accordingly, the unordered set $variable, when filtered, gives an unordered set. When it needs an order, the usual rule in XSLT 1.0 is to refer to "document order". Naturally this would sort the filtered subset into the same order as it would sort the set.

Since you refer to xsl:perform-sort, I assume the XPath 2.0 reasoning is what applies to your case.

Cheers,
Wendell

At 12:45 PM 4/29/2005, you wrote:
If I've got a variable bound to the result of xsl:perform-sort and then
filter it with a predicate (e.g. select="$variable[@attribute='value']"),
is the order of the resulting sequence guaranteed to be stable with
respect to the original sorted sequence?

Thanks,
--
Kevin Rodgers


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.