[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Hopefully not a terribly silly question
Hi Morgan,
Morgan Goeller wrote:
No, you don't need an eval() function (except in your approach) so yes, you are approaching it incorrectly - but you're very nearly there. The following does what you want: -- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:for-each select="/result/row"> <xsl:for-each select="./column"> <xsl:call-template name="print_name"/> </xsl:for-each> </xsl:for-each> </xsl:template> <xsl:template name="print_name"> <xsl:choose> <xsl:when test="@name">Name = <xsl:value-of select="@name"/> </xsl:when> <xsl:otherwise> <xsl:variable name="p" select="position()" /> Name <xsl:value-of select="position()"/>= <xsl:value-of select="/result/row[1]/column[position() = $p]/@name"/> </xsl:otherwise> </xsl:choose> Value <xsl:value-of select="position()"/>=<xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> -- as you can see, the main difference is that I've replaced your attempt to concat() and (implictly) eval() a dynamic (and therefore illegal) XPath expression by a static XPath expression which gets its dynamic value from a variable. In fact you could also use select="/result/row[1]/column[$p]/@name" though this is slghtly less clear. Hope this helps - Francis. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|