Re: [xsl] Retrieving named elements from separate tree

Subject: Re: [xsl] Retrieving named elements from separate tree
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Tue, 19 Mar 2002 12:52:48 -0800
On Tuesday 19 March 2002 11:25, STEPHEN_R_FRIEDLAND@xxxxxxxxx wrote:
> <xsl:template match="TradeEntry/*">
>  <td>   
>   <xsl:attribute name="align"><xsl:value-of
> select="//ColumnInfo/column[@colname='TradeId']/@align"/></xsl:attribute>
>   <xsl:value-of select="."/>
>  </td>
> </xsl:template>
>
> </xsl:stylesheet>
> --------------------------------------------------------------------
>
> I've declared an attribute for the <td> tag, which I'm trying to set to the
> current column's align attribute. If I hard-code the colname ('TradeId')
> then it works. What I would like to do is to replace [@colname='TradeId']
> with something like [@colname=name()]. This (and several variations I've
> tried) does not work.


When you do "//ColumnInfo/column[@colname=name()]", the name() function works 
with the current context node as seen from within the predicate, which in 
this case is "column".  You need to use the "current()" function to give the 
current context node of the template instead of the predicate:

<xsl:value-of select="//ColumnInfo/column[@colname = name(current())]"/>

-- 
Peter Davis
Money is truthful.  If a man speaks of his honor, make him pay cash.
		-- Lazarus Long

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


Current Thread