Re: Formatting a phone number using xsl

"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 UTC