Re: [xsl] R: [xsl] IQuestion about XSLT and Math Operations

Subject: Re: [xsl] R: [xsl] IQuestion about XSLT and Math Operations
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 05 Dec 2005 08:11:12 -0500
At 2005-12-05 13:09 +0100, drkm wrote:
"G. Ken Holman" wrote:
> At 2005-12-05 00:23 +0100, Villani Alessandro wrote:

> ><?xml version="1.0" encoding="utf-8"?>
> ><xsl:stylesheet
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> > version="1.0">
> >      <xsl:output method="xml"
> >        omit-xml-declaration="yes" indent="yes"/>
> >      <xsl:template match="parameters">
> >           <xsl:param name="r50">
> >...
> You can just do:
>    <c2><xsl:value-of select="r3 * r2"/></c2>

That's not the same things (it's an xsl:param, not an xsl:variable).

Some of my students come to class confused about this. Constructs defined by <xsl:param> and <xsl:variable> are used in *precisely* the same way once a value is bound. The sole difference between the two is how the value is bound: for a variable the value can only be the value declared, while for a parameter the value is the declared value only if it is not overridden when the template invoked with a <xsl:with-param>. Otherwise they are treated as exactly the same kind of thing.


In the author's example, the parameter is declared as a parameter of an unnamed template rule, thus the *only* way that a value other than the default value is bound to the parameter is through <xsl:with-param> as a child of <xsl:apply-templates>. Given that all of the information used is provided for in the source tree, I doubt that the template rule match was necessarily parameterized ... without more of the example code showing his use of <xsl:apply-templates> I made the assumption (and it was an assumption) that the author was using <xsl:param> unnecessarily and that <xsl:variable> was just as suitable.

Because as I said, except for how the value is bound, they are indeed the same thing when being used. There are no differences in reference and use.

I hope this is considered helpful.

. . . . . . . . . Ken


-- Upcoming XSLT/XSL-FO hands-on courses: Denver,CO March 13-17,2006 World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread