Wrox Programmer Forums
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2010, 09:40 AM
Registered User
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT

Hi everyone,
I have a very important question to ask any of you XSLT Champs out there!

Below is a piece of code:

<xsl:template name="RomanNum">
<xsl:param name="RStr" />
<xsl:variable name="RS" select="$RStr"/>
<xsl:choose>
<xsl:when test="$RS='I'">1</xsl:when>
<xsl:when test="$RS='II'">2</xsl:when>
<xsl:when test="$RS='III'">3</xsl:when>
<xsl:when test="$RS='IV'">4</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$RS"/>
</xsl:otherwise>
</xsl:choose>

</xsl:template>


When I execute this code the value of $RS and RSTR is "I" which should be converted to simple numeric value "1". This however is not converting. I also have another function in xslt which is the same coding but it works. Below is the code:

<xsl:template name="long_date">
<xsl:param name="date" />

<!-- Month -->
<xsl:variable name="month"
select="substring($date, 1, string-length(substring-before($date, ' ')))"/>
<xsl:choose>
<xsl:when test="$month='January'">01</xsl:when>
<xsl:when test="$month='February'">02</xsl:when>
<xsl:when test="$month='March'">03</xsl:when>
<xsl:when test="$month='April'">04</xsl:when>
<xsl:when test="$month='May'">05</xsl:when>
<xsl:when test="$month='June'">06</xsl:when>
<xsl:when test="$month='July'">07</xsl:when>
<xsl:when test="$month='August'">08</xsl:when>
<xsl:when test="$month='September'">09</xsl:when>
<xsl:when test="$month='October'">10</xsl:when>
<xsl:when test="$month='November'">11</xsl:when>
<xsl:when test="$month='December'">12</xsl:when>
<xsl:otherwise>INVALID MONTH</xsl:otherwise>
</xsl:choose>

This code above is working, but the one above it is not working. Can anyone help me?

Thanks
Swarup
(TL & Senior Programmer)
 
Old June 3rd, 2010, 09:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

See the first sticky post in this forum about posing questions.

The XSLT snippet looks okay so you need to post the XML and the rest of the XSLT, preferably in a short form, so we can see what else is happening.
__________________
Joe
http://joe.fawcett.name/
 
Old June 3rd, 2010, 09:54 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The code you have shown us looks correct. In other words, the problem is in the code you haven't shown us.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 4th, 2010, 05:56 AM
Registered User
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know it's a but stupid question but could it be that 'I' (uppercase i) will be confused with 'l' (lowercase L)? I can see the I (uppercase i) in your XSL but what about the XML? Or some other character like 'І' (CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I).





Similar Threads
Thread Thread Starter Forum Replies Last Post
Another question about generating XSLT with XSLT danblick XSLT 2 July 16th, 2009 08:40 PM
Generating XSLT with XSLT stonis XSLT 3 April 1st, 2008 08:17 PM
General XSLT Questions in the XSLT Forum jminatel BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 0 March 31st, 2008 07:50 PM
Can XSLT read DTD/schema and Generate XSLT.. ROCXY XSLT 1 November 6th, 2006 09:39 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.