Hi,
I have a little problem, which I assume is connected with the values I'm
after being converted to results tree fragments. I have tried various
things, but nothing seems to work. Also, as I'm using Sablotron, I
cannot use extensions such as node-set() to solve this problem.
I'm trying to get the values of all the parameters without referencing
each one explicitly.
Here's the code. [I have replaced document("") with document("this.xsl")
because of a Sablotron bug].
<?xml version='1.0' encoding='iso-8859-1'?>
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method='text'/>
<xsl:param name='p1' select='"red"'/>
<xsl:param name='p2' select='"blue"'/>
<xsl:param name='p3' select='"green"'/>
<xsl:template match='/'>
<!-- THIS IS THE RESULT I AM AFTER - 'red, blue, green' -->
<xsl:value-of select='$p1'/>, <xsl:value-of select='$p2'/>,
<xsl:value-of select='$p3'/>
<xsl:text>
</xsl:text>
<!-- THIS WAS MY FIRST ATTEMPT AT GETTING THE VALUES OF THE
PARAMETERS WITHOUT REFERENCING THEM EXPLICITLY - I GET THE RESULT ', , ' -->
<xsl:for-each
select='document("this.xsl")/xsl:stylesheet/xsl:param'>
<xsl:value-of select='.'/><xsl:if
test='position()!=last()'>, </xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
<!-- THIS WAS MY SECOND ATTEMPT. INSTEAD OF THE VALUES, I GET
THE RESULTS TREE FRAGMENTS - '$p1, $p2, $p3' -->
<xsl:for-each
select='document("this.xsl")/xsl:stylesheet/xsl:param'>
<xsl:variable name='params' select='concat("$p",position())'/>
<xsl:value-of select='$params'/><xsl:if
test='position()!=last()'>, </xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
And here's the output:
red, blue, green
, ,
$p1, $p2, $p3
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list