This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Retrieving named elements from separate tree


On Tuesday 19 March 2002 11:25, STEPHEN_R_FRIEDLAND@fleet.com 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]