[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Anyone can explain me this syntax?


Subject: Re: [xsl] Anyone can explain me this syntax?
From: Eliot Kimber <ekimber@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Jan 2004 09:39:36 -0600

Jaime Stuardo wrote:

Hi all...

From Muenchian method of grouping, I always use something like
this:

ROW[count(. | key('relacion_x_cobertura', REL_ID)[1]) = 1]


That always works, but I want to understand he reason of that syntax,
so that if I don't have the possibility of doing copy & paste from
other code, I could be able to write that expression by myself.

It took me a long time to understand what this pattern does, but it's really quite simple.


The key is realizing that "|" is the *union* operator.

That is, you are creating a *set* consisting of the current node (".") and the first member of the row from the key table (remember that key() lookups select node lists):

. | key('relacion_x_cobertura', REL_ID)[1]

Sets have the property that no nodes are duplicated, so if the current node and the first node of the selected key table entry are *the same* node, they will be collapsed in the set and the set will have exactly one member.

If the two nodes are not the same, the set will have two members.

Thus, you are selecting those rows that are the first entries in their corresponding key table entries.

This allows you to then select all of the *unique* rows in the document, since no row can be in two entries in the same key table.

Cheers,

Eliot
--
W. Eliot Kimber
Professional Services
Innodata Isogen
9030 Research Blvd, #410
Austin, TX 78758
(512) 372-8122

eliot@xxxxxxxxxxxxxxxxxxx
www.innodata-isogen.com


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




Current Thread