Re: [xsl] Tricky inclusion match

Subject: Re: [xsl] Tricky inclusion match
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 30 Mar 2005 13:02:10 -0500
I was looking at the post I just sent and realized it came out somewhat incoherently. (It must be an messed-up mail daemon somewhere.)

At 12:27 PM 3/30/2005, I wrote:
Expanded into long syntax the expression looks like this:

child::color[not(self::node() = preceding-sibling::color)][self::node() = $colors]

That is, it selects all the child 'color' elements, eliminates those whose values are the same as a preceding-sibling's value, and from those, keeps those whose values are equal to $colors.

The second predicate (bracketed expression) is a standard idiom for removing duplicates, and as such is simple enough. For large sets of siblings it's an expensive test (though it's the analogous test on the preceding:: axis that really gets expensive), which is why we often prefer key-retrieval techniques for de-duplication. (In this case the key-retrieval technique is cumbersome and doesn't gain us much.) You've seen this: it's central to Muenchian grouping.

This paragraph describes the test in the *first* predicate ... [not(. = preceding-sibling::*)] ... not the second.

Because of the way the equality operator works with node-sets (it returns true if the value of any node in the first set is equal to the value of any node in the second set), this has the result of keeping any color that is listed among the $colors.

This paragraph describes the test in the second predicate ... [.=$colors]

I hope that helps!


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 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