[xsl] length of string from a set of nodes.

Subject: [xsl] length of string from a set of nodes.
From: Fred Christian <fredc@xxxxxxxxxx>
Date: Fri, 27 Mar 2009 10:46:13 -0700
I was able to get this to work, but while reading about it, I see all these little tips and recommendations regarding being efficient and not creating nodes when you only need strings.

In this code my goal was meet of deciding if the length of all the text concatenated together is greater than 30.
<xsl:variable name="strings" as="xs:string"><xsl:value-of select="answers"/></xsl:variable>
<xsl:variable name="slen" as="xs:integer"><xsl:sequence select="string-length($strings)"/></xsl:variable>
<xsl:for-each select="answers">
<xsl:choose>
<xsl:when test="$slen gt 30">
etc...


I tried various combinations of using the <<concat()>> function, <<xsl:sequence>>, and <<xsl:value-of>>. This is what ended up working.

Is there a "better" way to do this?
Thanks

Current Thread