This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Passing a variable number of parameters to a named-template
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Passing a variable number of parameters to a named-template
- From: Chris Gow <cgow at digitalfairway dot com>
- Date: Thu, 18 Jan 2001 19:20:02 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
What I would like to do is duplicate what programming languages have: pass
a number of parameters (or some similar mechanism) to a template without
knowing how many parameters were actually passed. For example, JavaScript
has the arguments array and Java allows you to pass an array of
objects. Can I implement something similar in XSL? I did a search in the
archives and didn't find anything along the same lines as what I am looking
for (which is surprising, I think).
What kind of want is:
<!-- create the 'array' -->
<xsl:variable name="parameter">
<sometag>value</sometag>
<sometag>value1</sometag>
<sometag>value2</sometag>
<sometag>value3</sometag>
<sometag>value4</sometag>
<sometag>value5</sometag>
</xsl:variable>
<xsl:call-template name="VariableNumberOfValues">
<!--pass the 'array' -->
<xsl:with-param name="param"><xsl:value-of
select="$parameter"/></xsl:with-param>
</xsl:call-template>
<xsl:template name="VariableNumberOfValues">
<!-- iterate over the 'array' -->
<xsl:param name="param"/>
<xsl:for-each select ="$param/*">
<!--process each element in param -->
</xsl:for-each>
</xsl:template>
Or something along the lines above?
Thanks
Chris
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list