Subject: Re: [xsl] Peculiar Problem in .xsl file From: Gunther Schadow <gunther@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 06 Dec 2002 10:44:40 -0500 |
that way you avoid the potentially buggy type casting behavior of your XSLT processor to become manifest. Just leave the values you compare both strings at all times (it's probably slightly faster that way anyway :-). That way you are sure to hold on to the leading zero.
In fact I wonder if it's really buggy type casting? It seem to be reasonable for this machinery to cast the second operand to of the = relation to the data type of the first operand. That would cast the number 1 to a string, which would be '1', then you compare '01'='1' and the answer is correctly false. XSLT spec might make a ruling that clarifies that, but it's a subtle problem, so, I'd expect that to go wrong somewhere. Luckily your workaround is straight-forward.
regards, -Gunther
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>
<xsl:when test='$month=02'>
<xsl:text>February </xsl:text>
</xsl:when>
<xsl:when test='$month=03'>
<xsl:text>March </xsl:text>
</xsl:when>
<xsl:when test='$month=04'>
<xsl:text>April </xsl:text>
</xsl:when>
<xsl:when test='$month=05'>
<xsl:text>May </xsl:text>
</xsl:when>
<xsl:when test='$month=06'>
<xsl:text>June </xsl:text>
</xsl:when>
<xsl:when test='$month=07'>
<xsl:text>July </xsl:text>
</xsl:when>
<xsl:when test='$month=08'>
<xsl:text>August </xsl:text>
</xsl:when>
<xsl:when test='$month=09'>
<xsl:text>September </xsl:text>
</xsl:when>
<xsl:when test='$month=10'>
<xsl:text>October </xsl:text>
</xsl:when>
<xsl:when test='$month=11'>
<xsl:text>November </xsl:text>
</xsl:when>
<xsl:when test='$month=12'>
<xsl:text>December </xsl:text>
</xsl:when>
</xsl:choose>
When valuepassed into the date variable is 20020516, I don't get a month. Infact if the month is from 01 to 09, I dont get a month in words. If the month is 10 to 12, I get a month displayed. Very very peculiar. I am unable to find the solution. I tried and printed out the value of the month variable. It seems to take the 2 digits correctly. However it doesn't go into the appropraite month code when the month starts with 0!! For example, if the month is 05, it doesnt go into this part of the code:
<xsl:when test='$month=05'>
<xsl:text>May </xsl:text>
</xsl:when>
If the month were 10, 11 or 12, the code works fine.
Can anyone guess what the problem is...
Thanks in advance,
Chandra
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
-- Gunther Schadow, M.D., Ph.D. gschadow@xxxxxxxxxxxxxxx Medical Information Scientist Regenstrief Institute for Health Care Adjunct Assistant Professor Indiana University School of Medicine tel:1(317)630-7960 http://aurora.regenstrief.org
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Peculiar Problem in .xsl , David Carlisle | Thread | the joy of breaking out from proced, Gunther Schadow |
RE: [xsl] Locating Things Relative , bryan | Date | RE: [xsl] Locating Things Relative , Michael Kay |
Month |