"." changes its meaning inside square brackets. Try [(_at_)name=current()].
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Richard Lewis [mailto:richard(_dot_)lewis(_at_)gold(_dot_)ac(_dot_)uk]
Sent: 08 July 2009 18:31
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Using outer context node inside for-each
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>
</xsl:for-each>
</xsl:template>
So <record> elements have child elements called <field> which
each have a @name attribute.
The given template should accept a parameter which is a list
of field names, and emit an <xsl:message> of each <field>
element whose @name is in that list.
I'm pretty sure that using the $this variable as a node set
isn't the problem, because the following works fine:
<xsl:message><xsl:value-of
select="$this/field[(_at_)name='some-field']" /></xsl:message>
I'm also pretty sure that the current node (.) inside the
for-each is the field name from the list. But I'm pretty
certain that the problem is something to do with testing
@name against . in that XPath predicate.
I'm using libxslt 1.1.24 (and its str:tokenize implementation).
Any ideas?
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
ISMS, Computing
Goldsmiths, University of London
Tel: +44 (0)20 7078 5134
Skype: richardjlewis
JID: ironchicken(_at_)jabber(_dot_)earth(_dot_)li
http://www.richard-lewis.me.uk/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+-------------------------------------------------------+
|Please avoid sending me Word or PowerPoint attachments.|
|http://www.gnu.org/philosophy/no-word-attachments.html |
+-------------------------------------------------------+
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--