[Home] [By Thread] [By Date] [Recent Entries]
On 4/26/06, andrew welch <andrew.j.welch@xxxxxxxxx> wrote:
And the so;ution I posted consumes all the stack :o) Here's one that survives this case: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:f="http://fxsl.sf.net/" exclude-result-prefixes="f xs"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:variable name="vStr" as="xs:string"
select="'aaaaaaaaaaa,aaaaaaaaaaaaaa,aaaaaaaaaaaaaaaaa,aaaaaaaaaaaaaaaaa
aaa,aaaaaaaaaaaaaaaaaaaaaa'"/>
<xsl:variable name="vLength" as="xs:integer"
select="10" /> <xsl:template match="/" name="initial">
<xsl:variable name="vcommaInds" as="xs:integer*"
select="0, index-of(for $i in 1 to string-length($vStr)
return substring($vStr,$i,1),
','
)"/>
<!--<xsl:value-of select="$vcommaInds"/> --><xsl:value-of select="f:strSplit($vStr, $vcommaInds, 10)" separator="|"/> </xsl:template> <xsl:function name="f:strSplit" as="xs:string*"> <xsl:param name="pStr" as="xs:string"/> <xsl:param name="pcommaIds" as="xs:integer*"/> <xsl:param name="pLength" as="xs:integer"/> <xsl:message>
$pcommaIds: <xsl:value-of select="$pcommaIds"/>
</xsl:message> <xsl:sequence select=
"if(not($pcommaIds[2]))
then substring($pStr, $pcommaIds[1]+1)
else
for $firstI in $pcommaIds[1],
$lastI in ($pcommaIds[2],
$pcommaIds[position() gt 1] [.-$firstI le
$pLength+1][last()]) [last()],
$lastIPos in index-of($pcommaIds, $lastI)
return
(substring($pStr, $firstI+1, $lastI - $firstI - 1),
f:strSplit($pStr,
subsequence($pcommaIds, $lastIPos),
$pLength
)
)
"
/></xsl:function> </xsl:stylesheet>
|

Cart



