W3C home > Mailing lists > Public > www-xsl-fo@w3.org > May 2002

Re: Formatting a phone number using xsl

From: Max Froumentin <mf@w3.org>
Date: Fri, 31 May 2002 17:12:41 +0200
To: "Tanguay, Lyne" <ltanguay@minacom.com>
Cc: "'www-xsl-fo@w3.org'" <www-xsl-fo@w3.org>
Message-ID: <86it54bbbq.fsf@sophia.inria.fr>

"Tanguay, Lyne" <ltanguay@minacom.com> writes:

> We have no choice but to use a "for-each" loop to display multiple 
> fields that compose the phone number.  
> We want the "-" to act as the separation character. 
> But when we do so, we get this result, for ex: 011-1-666-7777-
>
> How can we prevent from having the last "-".

Hi Lyne,

Something like this should work:

 <xsl:template match="phone">
    <xsl:for-each select="*">
       <xsl:value-of select="@value"/>
       <xsl:if test="position()!=last()">
         <xsl:text>-</xsl:text>
       </xsl:if>
    </xsl:for-each>
 </xsl:template>

Max.
Received on Friday, 31 May 2002 11:13:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:09 GMT