You can get accumulating concat with just a little recursion if you look at node-set (as long as you can build an xpath to find node-set), so that you can add arbitrary bits and pieces to and from the stream it starts to get confused.
Try this for starters (also joins):
<xsl:template match="/"> <xsl:variable name="s"> <xsl:call-template name="stringbuilder"> <xsl:with-param name="data" select="*" /> </xsl:call-template> </xsl:variable> <xsl:value-of select="$s" /> </xsl:template> <xsl:template name="stringbuilder"> <xsl:param name="data"/> <xsl:param name="join" select="''"/> <xsl:for-each select="$data/*"> <xsl:choose> <xsl:when test="not(position()=1)"> <xsl:value-of select="concat($join,child::text())"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="child::text()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template>
All sorts of extensions may be required for this: perhaps you want to trim, perhaps you also want to tunnel through hierarchies. I'm not sure if there is a bulletproof general solution.
source share