Re: [xsl] Inserting a separator only between non-empty strings (XSLT 2)

Subject: Re: [xsl] Inserting a separator only between non-empty strings (XSLT 2)
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 18 May 2007 19:18:46 +0200
Michael Kay wrote:

Suggestion:


<xsl:variable name="result" select="string-join((string($a), string($b), string($c))[.], '|')"/>

Another suggestion


<xsl:value-of select="($a, $b, $c)[.]" separator="|" />

if content contains nodes, including empty ones which you don't want output, you can change it to:

<xsl:value-of select="($a, $b, $c)[string(.)]" separator="|" />

if you do not want relevant whitespace-only nodes to appear (you can also use strip-space or) :

<xsl:value-of select="($a, $b, $c)[normalize-space(.)]" separator="|" />


Cheers, -- Abel Braaksma

Current Thread