Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 February 2nd, 2007, 02:19 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl:if in xsl:while

Hallo again,

I have used a choose while check for my date type and now what I want to do is to check if the month has a valid value for example February cannot be 31 days. So it is something like that

mm = month variable
dd = day variable
<xsl:choose>
<xsl:when test ="number($mm)=1 or number($mm)=3 or number($mm)=5 or number($mm)=7 or number($mm)=8 or number($mm)=10 or number($mm)=12">
<xsl:if test ="number($dd)>31 or number($dd)<1">
<xsl:text>Invalid day value</xsl:text>
</xsl:if>
</xsl:when>
</xsl:choose>

I have another question. with mm variable I have many or connectives. Is there any other practical solution for it? It is quite long to write such a statement.

Your attitude determines your altitude
__________________
Your attitude determines your altitude
 
Old February 2nd, 2007, 02:26 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can cut the length a lot by putting number($mm) in a variable.

In XSLT 2.0 you can do $x=(1,3,5,7,8,10,12). But in 2.0 you've got date/time functions so you wouldn't need this logic anyway.

1.0 just tends to be verbose: live with it, or move to 2.0

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 2nd, 2007, 02:52 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Michael unfortunately I am no longer a Java Developer I am developing C# under VS 2005 with .NET2.0 That means I have to use XSLT 1.0

So my another question has not been yet answered. Can I use xsl:if in xsl:while in XSLT 1.0 like the example above?

Your attitude determines your altitude
 
Old February 2nd, 2007, 04:21 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Michael unfortunately I am no longer a Java Developer I am developing C# under VS 2005 with .NET2.0 That means I have to use XSLT 1.0

No, it doesn't: try Saxon for .NET.

>So my another question has not been yet answered. Can I use xsl:if in xsl:while in XSLT 1.0 like the example above?

There's no such instruction as xsl:while. If you mean can you use xsl:if within xsl:when, then yes, of course you can.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
differnce between xsl:apply-templates and xsl:call chandu.mca007 XSLT 2 June 12th, 2007 04:12 AM
xsl advise needed - Replacing UID through XSL Billyl XSLT 6 February 28th, 2006 05:46 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





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