Subject: Re: format-number() for a phone number? From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 25 May 1999 23:31:42 +0100 (BST) |
You don't need to go to java extensions to do this, you can do it within XSLT. the following inserts - into strings of digits, you should be able to modify it easily enough to insert () as well. David <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0" result-ns=""> <xsl:template match="ssn"> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="1"/> <xsl:param name="left" expr="."/> </xsl:call-template> </xsl:template> <xsl:template name="ssn-dash" > <xsl:param-variable name="count"/> <xsl:param-variable name="left"/> <xsl:if test="($count=4) or ($count=6)">-</xsl:if> <xsl:choose> <xsl:when test="$count=6"> <xsl:value-of select="$left"/> </xsl:when> <xsl:when test="starts-with($left,'0')"> <xsl:text>0</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'0')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'1')"> <xsl:text>1</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'1')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'2')"> <xsl:text>2</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'2')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'3')"> <xsl:text>3</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'3')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'4')"> <xsl:text>4</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'4')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'5')"> <xsl:text>5</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'5')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'6')"> <xsl:text>6</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'6')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'7')"> <xsl:text>7</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'7')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'8')"> <xsl:text>8</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'8')"/> </xsl:call-template> </xsl:when> <xsl:when test="starts-with($left,'9')"> <xsl:text>9</xsl:text> <xsl:call-template name="ssn-dash"> <xsl:param name="count" expr="$count+1"/> <xsl:param name="left" expr="substring-after($left,'9')"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
format-number() for a phone number?, Mike Brown | Thread | Re: format-number() for a phone num, Liam R. E. Quin |
RE: <br>, Jonathan Marsh | Date | ANNOUNCE: WWW8 Trip Report on WDVL, Sall, Ken |
Month |