This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Testing type of a param
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] Testing type of a param
- From: Robin Meade <rmeade at outreach dot hawaii dot edu>
- Date: Tue, 15 May 2001 18:13:09 -1000
- Reply-To: xsl-list at lists dot mulberrytech dot com
A param's type can be any of
string, number, boolean, node-set
Within a called template I'd like to be able use <xsl:choose> to
branch based on whether a parameter is a node-set or not.
Is there a way to do this?
FYI, here is the template I'm trying to write; it is a general
purpose repeat function:
<!--
This template takes two parameters:
value - the thing to repeat.
n - the number of times to repeat it to the result tree.
If value is a node set, xsl:copy-of is used.
If value is a simple value, xsl:value-of is used.
-->
<xsl:template name="repeat">
<xsl:param name="value"/>
<xsl:param name="n"/>
<xsl:if test="$n != 0">
<xsl:choose>
<xsl:when test="?">
<!-- value is a node set, use copy-of -->
<xsl:copy-of select="$value"/>
</xsl:when>
<xsl:otherwise>
<!-- value is a simple type, use value-of -->
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="repeat">
<xsl:with-param name="n" select="$n - 1"/>
<xsl:with-param name="value" select="$value"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list