xsl-list
[Top] [All Lists]

Re: [xsl] Eliminating leading zeros

2006-08-21 06:54:30

Yes I am using XSLT2 (albeit very poorly understood). Will try your suggestion.
Thanks,
Mark

----- Original Message ----- From: "David Carlisle" <davidc(_at_)nag(_dot_)co(_dot_)uk>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, August 21, 2006 9:46 AM
Subject: Re: [xsl] Eliminating leading zeros



any chance you are using xslt2? in which case

select="replace(.,'^ *0*','')

would remove any leading spaces or zeros.

otherwise something tiresome like
<xsl:variable name="x" select="normalize-space(.)"/>
<xsl:choose>
 <xsl:when test="contains($x,' ')">
   <xsl:variable name="n" select="substring-before($x,' ')"/>
   <xsl:variable name="t" select="substring-after($x,' ')"/>
   <xsl:choose>
    <xsl:when test="number($n)=number($n)">
      <xsl:value-of select="number($n)"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$n"/>
    </>
  </>
 <xsl:text> </xsl:text>
 <xsl:value-of select="$t"/>
</>
<xsl:otherwise>
   <xsl:choose>
    <xsl:when test="number($x)=number($x)">
...

--~------------------------------------------------------------------
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>
--~--