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

Re: Enclosing sequence items in single quotes

Subject: Re: Enclosing sequence items in single quotes
From: cknell@xxxxxxxxxx
Date: Fri, 19 Oct 2007 10:55:55 -0400
Re:  Enclosing sequence items in single quotes
Thanks to Andrew and David.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Andrew Welch <andrew.j.welch@xxxxxxxxx>
Sent:     Fri, 19 Oct 2007 15:54:02 +0100
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re:  Enclosing sequence items in single quotes

On 19/10/2007, cknell@xxxxxxxxxx <cknell@xxxxxxxxxx> wrote:
> I need some help in constructing a string from a sequence. Consider this template:
>
> <xsl:template match="/">
>     <xsl:variable name='pf-codes'><xsl:value-of select="position-translation/position/code[@pf='pf']"/></xsl:variable>
>     <xsl:variable name="pf-codes-string" select="for $s in $pf-codes return $s"/>
>      <xsl:value-of select="$pf-codes-string"/>
> </xsl:template>
>
> This produces output like this:
>
> AA BB CC DD EE FF GG ...
>
> I need output like this:
>
> 'AA','BB','CC','DD','EE','FF','GG', ..., 'ZZ'
>
> Note that the last item is not followed by a comma.
>
> I haven't moved on to the question of using position()=last() to bring about this last requirement.
>
> I'm having trouble constructing an expression that will enclose each item in the sequence in quotes (single).
>
> Please point me in the right direction. Thanks

select="string-join($pf-codes/concat('''', ., ''''), ',')"


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.