At 2008-08-21 14:31 -0500, Mattoo, Utpal wrote:
What is the difference between the following 2 lines (Line 1 vs Line 2)
(I know what these lines do, but i dont know HOW. Please find related
XML at the end of the file )----
Line 1
<xsl:apply-templates select="*[(_at_)partNum and
generate-id(.)=generate-id(key('parts', @partNum))]" />
That checks only those child elements that have a partNum attribute
and then checks to see if the child element is the first in the key
table named 'parts' with a lookup value being the partNum attribute
(presumably because the elements were loaded having partNum
attributes but that doesn't have to be the case).
Line 2
<xsl:apply-templates select="*[generate-id(.)=generate-id(key('parts',
@partNum))]" />
That checks *all* child elements using their partNum attribute for
the lookup ... this is assuming that every element has a partNum
attribute, otherwise the lookup value will be the empty string.
ALSO what does this line do
-- generate-id(.)=generate-id(key('parts', @partNum)) ---
Suitable for XSLT 1.0 but not XSLT 2.0 the above will check the
current node as being the first node in the key table using the
node's partNum attribute as a lookup value. In XSLT 2.0 this will
throw an error if there is more than one node in the key table with
the associated lookup value.
probably retrieves a part number only once but I don't understand
how...
BUT how is the line different from
-- generate-id(.)=generate-id(key('parts', @partNum)[1]) ---
Suitable for both XSLT 1.0 and 2.0 the above will do the same thing.
Using generate-id() for node identity relies on the guaranteed
principle that every node of every tree used in a single
transformation will have a unique generated identifier. The value is
opaque and should be used without inspecting how it is comprised.
I hope this helps.
. . . . . . . . . . Ken
--
Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
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>
--~--