This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Putting parameter into XPATH expression
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Putting parameter into XPATH expression
- From: "MacEwan, James (Information Services)" <James dot MacEwan at investorsgroup dot com>
- Date: Fri, 22 Jun 2001 14:23:32 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
In the code extract below, I always get the result "OneOneOne" instead of
"OneTwoThree" which I am expecting.
I found a work around (based on my previous experience writing compilers)
that gets XSL processor to do what I want: "<xsl:value-of
select="a/b[$Position + 0 ]/c"/>"
Can someone tell me a better (more correct) way to do this?
XML ------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b> <c>One</c> </b>
<b> <c>Two</c> </b>
<b> <c>Three</c> </b>
</a>
In my XSL, I do the following to write out the words One, Two and Three
---------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:call-template name="Jump">
<xsl:with-param name="Position"
select="'1'"/>
</xsl:call-template>
<xsl:call-template name="Jump">
<xsl:with-param name="Position"
select="'2'"/>
</xsl:call-template>
<xsl:call-template name="Jump">
<xsl:with-param name="Position"
select="'3'"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="Jump">
<xsl:param name="Position"/>
<xsl:value-of select="a/b[$Position ]/c"/>
</xsl:template>
Thanks,
-James MacEwan
Software Developer
Investors Group Inc.
mailto:James.MacEwan@investorsgroup.com
v: (204) 956-8515
f: (204) 943-3540
"I don't know, lad. It's like no cheese I've ever tasted." -- Wallace
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list