RE: [xsl] translate array delimiters in XSLT

Subject: RE: [xsl] translate array delimiters in XSLT
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Fri, 18 Mar 2005 16:47:20 +0000
Cas, search this list for references to Sal Mangano's "XSL Cookbook"; it contains templates for text-replace, split(), etc.

--A

From: Cas Tuyn <Cas.Tuyn@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] translate array delimiters in XSLT
Date: Fri, 18 Mar 2005 17:36:55 +0100

Hi,

To display a list of software releases with ", " delimited that are
mentioned in XML as ";" delimited:

<procedure software="3.3.7;3.3.8;3.3.9;3.4.0;3.4.2;3.4.4">

I had written in the perl function that cleans up the XML, this sinple
regular expression:

         if ( $line =~ /software=/ ) {
            $line =~ s#;#, #g ;
         }

Obviously this only worked for software values on the same line and not
for software values that spanned multiple lines, so I now want to
transfer this 'logic' from Perl to XSLT. I removed the 3 lines from the
Perl program, and changed this XSLT:

<xsl:for-each select="@software">
    <xsl:value-of select="."/>
</xsl:for-each>

to:

<xsl:for-each select="@software">
    <xsl:value-of select="."/>,
</xsl:for-each>

but that only produced one "," behind the last SW release, not inbetween.

Reading in Michael Kay's XSLT book on the translate() function made me
try this:

<xsl:for-each select="translate(@software,';',', ')">
    <xsl:value-of select="."/>
</xsl:for-each>

but that did not prove valid XSLT, even with string() around the array
@software.

Anyone has a tip to convert ";" to ", " without reverting to Perl?

Cas


--
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.



_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Current Thread