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

Subject: Re: [xsl] Anyone can explain me this syntax?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Jan 2004 10:49:11 -0500
At 2004-01-13 11:58 -0400, Jaime Stuardo wrote:
>From Muenchian method of grouping, I always use something like this:

ROW[count(. | key('relacion_x_cobertura', REL_ID)[1]) = 1]
...
- Why the . (dot) is used?

It is a reference to the current node.


why if I omit it, it doesn't work (it returns all elements)?

Yes, because the key()[1] expression returns one node and you are asking if the count is 1.


- What's the meaning of the | (pipe)?

Union (this is a very basic XPath question ... what problems did you have looking for the definition?). A union of two node sets does not contain duplicates of the same node. If the union of the current node and another node is one, then the other node must be the current node.


- What's the meaning of [1]?

First in proximity order (for axis expressions) or document order (for path expressions). In this case it is requesting the first in document order. While redundant in XSLT 1.0 it is not redundant in XSLT 2.0.


I have always used things like [FIELD_NAME=some_value]. I understand that perfectly, but what about placing only that number in the brackets? I tried by using [2] and it worked too... or, perhaps I was lucky?

You were lucky. If any of your unique values had only one member, it would have returned the empty set, the count of the union would be one, and it would have triggered ... so it would have worked but not for the reason the expression was written.


I hope this helps.

............................. Ken


-- North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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



Current Thread