xsl-list
[Top] [All Lists]

Re: applying a predicate to a sorted sequence

2005-04-29 11:46:52
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[(_at_)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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>