[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Peculiar Problem in .xsl file

Subject: Re: Peculiar Problem in .xsl file
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 6 Dec 2002 00:01:05 -0700 (MST)
substring leading zero xsl
Chandra - wrote:
> Hi Guys,
>   I am trying to print out a html file with a date in words, given date in a 
> xml file in number format
> XSL file:
> <xsl:variable name='month' select='substring ($date, 5, 2)'/>
> 	<xsl:choose>
> 		<xsl:when test='$month=01'>
> 			<xsl:text>January </xsl:text>
> 		</xsl:when>

You're right, it ought to work.

Since =01 is the same as =1 (you didn't put the number in quotes, so it's a
number, not a string), there's no need for the leading zero.. perhaps you
meant "01" (with quotes). Shouldn't matter, though.. the string comparison
should not provide different results than the numeric comparison.

<xsl:value-of select="'01'=1"/>
and
<xsl:value-of select="'01'=01"/>
should both give you 'true' ... do they? If not, what XSLT processor are
you using? File a bug report!


Meanwhile, try this solution:

<xsl:variable name="months" select="'January  February March    April    May      June     July     August   SeptemberOctober  November December '"/>
<xsl:value-of select="concat(normalize-space(substring($months,1+9*(substring($date,5,2)-1),9)),' ')"/>


Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.