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: Yves Forkl <Y.Forkl@xxxxxx>
Date: Fri, 18 May 2007 13:00:55 +0200
Thank you very much for your explanation, Michael. Now I understand better why things have to be this way.

The solution you suggested works perfectly for me. I am just a bit disappointed that XSLT 2 doesn't provide with me a more elegant construct that would make life even easier for me (like XSLT 2 already did in a lot of cases). :-)


mozer wrote:
and what about that ?

<xsl:variable name="concat">
<xsl:sequence>
 <xsl:value-of select="$a"/>
 <xsl:value-of select="$b"/>
 <xsl:value-of select="$c"/>
</xsl:sequence>
</xsl:variable>
<xsl:value-of separator="|" select="$concat[string-length(.) gt 0]"/>

Unfortunately, this won't work, as xsl:sequence only allows to use the select attribute here, not its element content. However, adapting it a little I get


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

which seems to work (but I am not sure). Anyway, I prefer Michael's solution.

Yves

Current Thread