[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Hopefully not a terribly silly question

Subject: Re: Hopefully not a terribly silly question
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Thu, 03 Jan 2002 18:27:40 +0000
morgan goeller
Hi Morgan,

Morgan Goeller wrote:


Unfortunately, I get a the literal string result of the concat() function, instead of the actual data value. Is there some sort of eval() function that I need to use? Am I approaching this incorrectly?


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.