roy said:
Martin said:
(e-mail address removed) wrote:
<xsl:value-of select="
$myblahs/blah[/xpath1/xpath2/someintegervalue]/yada
"/>
$myblahs/blah
[/xpath1/xpath2/someintegervalue=position()]/yada
Hmmm, that's not working for me. If I put in a "1" or a
"2" it works, but not with the "variable".
Your example is awfully vague. For better results, provide
a sample XML and a minimum XSLT demonstrating your problem.
Roy,
Here's an example of what I'm referring to. The "does not work"
comment shows what I'm trying to do. The "this does work" shows where
I'm able to hit the nodeset by hardcoding the parameter.
Thanks,
Eric
<page>
<contents>
<ratessummary rec_count="3">
<rate>
<ratecode>1</ratecode>
<myrate>1.1</myrate>
</rate>
<rate>
<ratecode>2</ratecode>
<myrate>1.2</myrate>
</rate>
<rate>
<ratecode>3</ratecode>
<myrate>1.3</myrate>
</rate>
</ratessummary>
<thingsummary rec_count="3">
<thing>
<short_description>Jim</short_description>
<description>James</description>
<thingcode>1</thingcode>
</thing>
<thing>
<short_description>Rick</short_description>
<description>Richard</description>
<thingcode>2</thingcode>
</thing>
<thing>
<short_description>Fred</short_description>
<description>Frederick</description>
<thingcode>3</thingcode>
</thing>
</thingsummary>
</contents>
</page>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<html>
<head></head>
<body>
<xsl:apply-templates select="page/contents"></xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="contents">
<table>
<tr>
<td class="data">
<xsl:apply-templates select="thingsummary">
<xsl:with-param name="rates"
select="/page/contents/ratessummary"></xsl:with-param>
</xsl:apply-templates>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="thingsummary">
<xsl
aram name="rates"/>
<xsl:value-of select="$rates/rate[1]/org_id"/>
<table>
<xsl:apply-templates select="thing[(position() mod 2)=1]">
<xsl:with-param name="rates" select="$rates"></xsl:with-param>
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="thing[(position() mod 2)=1]">
<xsl
aram name="rates"/>
<tr>
<td>
<xsl:value-of select="short_description"/>-<xsl:value-of
select="thingcode"/>-<xsl:value-of select="$rates/rate[1]/org_id"/>
<!-- This does not work-->
test1<xsl:value-of select="$rates/rate[position()=thingcode
]/myrate"/>
<!-- This works-->
test2<xsl:value-of select="$rates/rate[position()=1]/myrate"/>
</td>
<xsl:apply-templates select="following-sibling::thing[1]">
<xsl:with-param name="rates" select="$rates"></xsl:with-param>
</xsl:apply-templates>
</tr>
</xsl:template>
<xsl:template match="thing[(position() mod 2)=0]">
<xsl
aram name="rates"/>
<td>
<xsl:value-of select="short_description"/>-<xsl:value-of
select="thingcode"/><xsl:value-of select="$rates/rate[1]/org_id"/>
<!-- This does not work-->
test1<xsl:value-of select="$rates/rate[position()=thingcode
]/myrate"/>
<!-- This works-->
test2<xsl:value-of select="$rates/rate[1]/myrate"/>
</td>
</xsl:template>
</xsl:stylesheet>