xsl-list
[Top] [All Lists]

Re: [xsl] Using outer context node inside for-each

2009-07-08 13:43:46
At 2009-07-08 18:31 +0100, Richard Lewis wrote:
Hi there,

Here is an abstraction of my problem template:

 <xsl:template match="record">
   <xsl:param name="show-fields" />
   <xsl:variable name="this" select="." />

   <xsl:for-each select="str:tokenize($show-fields)">
<xsl:message><xsl:value-of select="$this/field[(_at_)name=(_dot_)]" /></xsl:message>

Inside the predicate "." refers to the node found by the node test.

You want [(_at_)name=current()] to address the context item that is at the start of the XPath expression.

Though I see Martin has taken the problem away with a more compact solution ... still, you wanted to know why yours wasn't working.

I hope this helps.

. . . . . . . . Ken


--
Possible July/August XSLT/XQuery/XSL-FO training in Oakland/CA/USA
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
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>
--~--