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

RE: can a value of a parameter depends on a other valu

Subject: RE: can a value of a parameter depends on a other value
From: Roelof Wobben <rwobben@xxxxxxxxxxx>
Date: Fri, 2 Dec 2011 08:02:14 +0000
RE:  can a value of a parameter depends on a other valu

Bumping into a problem.

Im testing this script :

<xsl:param name="page" />
<xsl:variable name="hmm">
<xsl:when test="$page='1'">number(1+$page*2)</xsl:when>

before Im going to test Brandon scripts.

I was hoping I do this:

I have a month of 4 articles and I have 2 articles a page.  So there will be 2

Now I have to make 1 rule for every page.

I was hoping I could do this in 1 rule but it seems that the variable hmm is a
string instead of a number.

And converting it with number would not help.

Is there a way out. If not, then I have to make for every page a seperate when
and the website will contain some 80 when then.


> Date: Thu, 1 Dec 2011 18:58:01 -0500
> From: brandon.ibach@xxxxxxxxxxxxxxxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  can a value of a parameter depends on a other value
> On Thu, Dec 1, 2011 at 1:00 PM, Roelof Wobben <rwobben@xxxxxxxxxxx> wrote:
> > One question. If I have two variables which depends on the same condition
but will have other values do I have to write three seperate variable blocks
> In a functional language, like XSLT, which disallows side-effects like
> changing the value of a variable as execution proceeds, you can't use
> a familiar pattern like "if (a = b) then set c = 1, d = 2, e = 3".
> One pattern for accomplishing this is to set a temporary variable to a
> composite value, then split it up.
> This is easier and cleaner in XSLT 2.0, with support for sequences,
> better string functions, etc. However, it is still doable in XSLT 1.0
> for reasonably simple cases. I often find a little bit of ugliness
> like this is worth the increase in maintainability gained by not
> repeating the logic of the conditions.
> <xsl:param name="page"/>
> <xsl:variable name="labels">
> <xsl:choose>
> <xsl:when test="$page = 4">4,D;iv</xsl:when>
> <xsl:when test="$page = 3">3,C;iii</xsl:when>
> <xsl:when test="$page = 2">2,B;ii</xsl:when>
> <xsl:otherwise>1,A;i</xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
> <xsl:variable name="arabic" select="substring-before($labels, ',')"/>
> <xsl:variable name="alpha"
> select="substring-before(substring-after($labels, ','), ';')"/>
> <xsl:variable name="roman" select="substring-after($labels, ';')"/>
> -Brandon :)

Current Thread


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.
First Name
Last Name
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.