RE: [xsl] How do I compare all similar type nodes?

Subject: RE: [xsl] How do I compare all similar type nodes?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 18 Dec 2001 12:45:50 -0500
David,

At 12:13 PM 12/18/01, you wrote:
I have handled this by defining a key from the space normalized value of the
element plus the document position of its parent (to duplicate the
preceding-sibling behaviour) and then checking if the context node is the
first in its key group, but wondered if there was some combination of
preceding-sibling and normalize-space that would do what I mean.

No, there isn't, in XSLT 1.0, for exactly the reason you said (normalize-space() operates on a string, not a node set). In later versions the ability to create node sets will help for this kind of thing. (You'll be able to set up a normalized node set as a variable. Do this now with an extension function.)


The key() solution, however, is a good way to do it. The reason you didn't find it in your research is that this solution (i.e. Muenchian grouping) is usually applied within the context of grouping as such, which necessarily entails de-duplicating (to avoid processing each group over again for each of its members) -- and grouping is so much more a FAQ than de-duplicating, that it may have been missed that the problems are actually separate (though related). Keys turn out to be a good way of doing a number of things that you might ordinarily want to create a node set for.

I did find this in the archive - which seems to indicate that there isn't,
yet, any way to do this -
http://www.biglist.com/lists/xsl-list/archives/199912/msg00336.html

Oh, I'm not sure that you can set too much by a message written back in 1999 -- before alot of sneaky techniques (including the various applications of keys) were devised by resourceful XSLT coders to solve problems that on their face, are fairly intractable. XSLT has come a good way since then -- not least because people have tried -- with surprising success! -- to do all kinds of things with it that its original designers may not have envisioned as important use cases.


Cheers,
Wendell

======================================================================
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
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread