[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: Thu, 1 Dec 2011 18:00:42 +0000
RE:  can a value of a parameter depends on a other valu
Thanks,



So both are good.

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 ?



Roelof



----------------------------------------
> Date: Thu, 1 Dec 2011 16:06:11 +0000
> From: davidc@xxxxxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  can a value of a parameter depends on a other value
>
> On 01/12/2011 15:51, Roelof Wobben wrote:
> >
> >
> > Hello,
> >
> >
> >
> > I did some investigation and found this script.
> >
> >
> >
> >
> > <xsl:variable name="foo">
> > <xsl:choose>
> > <xsl:when test="condition1">
> > ...value if condition1 is true
> > </xsl:when>
> > <xsl:otherwise>
> > ...value if condition1 is not true
> > </xsl:otherwise>
> > </xsl:choose>
> > </xsl:variable>
> >
> > <xsl:apply-templates select="/foo/bar">
> > <xsl:with-param name="foo" select="$foo"/>
> > </xsl:apply-templates>
> >
> >
> >
> >
> > Is this a good example of a condtional with-param ?
> >
>
> well working is good;-)
> as always, if you only use a variable once can (but don't have to)
> inline the definition, so here the global variable $foo is only used
> once so you could equivalently go
>
> <xsl:apply-templates select="/foo/bar">
> <xsl:with-param name="foo">
> <xsl:choose>
> <xsl:when test="condition1">
> ...value if condition1 is true
> </xsl:when>
> <xsl:otherwise>
> ...value if condition1 is not true
> </xsl:otherwise>
> </xsl:choose>
> </xsl:with-param>
> </xsl:apply-templates>
>
>
> But it probably compiles to more or less the same thing.
> One of the nice features of side-effect free languages is that the
> compiler has a lot of freedom to re-arrange the code, if you use the
> same subterm multiple times the compiler can reuse the value,
> effectively implictly making a variable, conversely if you only use a
> variable once it can inline the definition, effectively removing the
> variable.
>
> So use of variables or not often just amounts to personal coding style
> aesthetics.
>
> dDavid
>
>
>
>
>
> --
> google plus: https:/profiles.google.com/d.p.carlisle
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________

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.