[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Inserting a separator only between non-empty strin

Subject: RE: Inserting a separator only between non-empty strings (XSLT 2)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 18 May 2007 11:19:35 +0100
RE:  Inserting a separator only between non-empty strin
> I tried
> 
> <xsl:variable name="result">
>    <xsl:value-of separator="|">
>      <xsl:value-of select="$a"/>
>      <xsl:value-of select="$b"/>
>      <xsl:value-of select="$c"/>
>    </xsl:value-of>
> </xsl:variable>
> 
> but this does never insert a separator.

That's because of the rules for construction of simple content

http://www.w3.org/TR/xslt20/#constructing-simple-content

which say that adjacent text nodes are concatenated in step 2, before
atomization and insertion of separators. (This is necesary so that
instructions like xsl:attribute work the way they did in XSLT 1.0).

Suggestion:

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

Michael Kay
http://www.saxonica.com/


 Replacing 
> xsl:value-of with xsl:sequence for the variable references 
> always inserts the separator, even near empty strings which 
> is what I want to avoid.
> 
>    Yves

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.