xsl-list
[Top] [All Lists]

RE: [xsl] Display numeric string of the form 01W or 02Y

2009-11-16 09:57:23

Thanks a ton.

-----Original Message-----
From: Syd Bauman [mailto:Syd_Bauman(_at_)Brown(_dot_)edu]
Sent: 16 November 2009 13:46
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Display numeric string of the form 01W or 02Y

This isn't working. I am using XSLT1.0

Right, there is no replace() in XPath 1.0 (and thus in XSLT 1.0).

Probably the right way to do this in XSLT 1.0 is to use <xsl:number>.
But, depending on your data, you might get away with just sticking a '0' in 
front of anything that is only 2 characters long:

  <xsl:variable name="formatted_in">
    <xsl:choose>
      <xsl:when test="string-length($in)=2">
        <xsl:text>0</xsl:text>
        <xsl:value-of select="$in"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$in"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--