[Home] [By Thread] [By Date] [Recent Entries]
At 2008-08-09 23:05 -0500, Bordeman, Chris wrote:
Not quite what I want, need a little more logic. I've ALMOST got it now. I've figured out that I can just use a normal untyped parameter, pass it as a set, such as: Then just build the return sequence or the return values incrementally for each item. Below is an example where I inspect each item and treat them differently, with attention to the last item. I've copied the same logic in both functions ... you could just as well have the concat function call the sequence function using string-join(). I hope this helps. . . . . . . . . Ken T:\ftemp>type chris.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xsd"
xmlns:c="urn:x-Chris"
version="2.0"><xsl:output method="text"/> <xsl:template match="/">
<xsl:value-of select="c:mysequence(('abc', '123', 'def'))"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="c:myconcat(('abc', '123', 'def'))"/>
</xsl:template><xsl:function name="c:mysequence"> <xsl:param name="args"/> <xsl:for-each select="$args">
<xsl:choose>
<xsl:when test=". castable as xsd:decimal">
<xsl:sequence select="xsd:decimal(.) * 2"/>
</xsl:when>
<xsl:when test="position()=last()">
<xsl:sequence select="concat(.,.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:function><xsl:function name="c:myconcat"> <xsl:param name="args"/> <xsl:for-each select="$args">
<xsl:choose>
<xsl:when test=". castable as xsd:decimal">
<xsl:value-of select="xsd:decimal(.) * 2"/>
</xsl:when>
<xsl:when test="position()=last()">
<xsl:value-of select="concat(.,.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:function></xsl:stylesheet> T:\ftemp>xslt2 chris.xsl chris.xsl con abc 246 defdef abc246defdef T:\ftemp>
|

Cart



