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

Re: initial template parameters

Subject: Re: initial template parameters
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Mar 2010 08:07:41 +0100
Re:  initial template parameters
At 2010-03-18 01:29 -0400, Max Toro wrote:
"Parameters passed to the transformation by the client application are
matched against stylesheet parameters (see 9.5 Global Variables and
Parameters), not against the template parameters declared within the
initial template. All template parameters within the initial template
to be executed will take their default values."

Why? :-(

Why not? It is quite flexible that way.


If you want to have parameters passed to the transformation to be accessed from within the initial template to be executed, then have the default values of the initial template use the global values:

  <xsl:param name="global-command-line"/>
  <xsl:template match="/">
    <xsl:param name="initial" select="$global-command-line"/>
    ...$initial...
  </xsl:template>

Because local variables shadow global variables you could have the following if you plan to invoke the initial template a number of times in the transform:

  <xsl:param name="x"/>
  <xsl:template match="/">
    <xsl:param name="x" select="$x"/>
    ...$x...
  </xsl:template>

Since global variables are visible to all templates, if you are only ever invoking the initial template once, then you don't need the parameter in the template because the global parameter is visible:

  <xsl:param name="x"/>
  <xsl:template match="/">
    ...$x...
  </xsl:template>

I think this flexibility is quite important.

In my XSLStyle documentation methodology for XSLT stylesheets I have a template rule for the root node that has parameters initialized when first invoked from the command line but passed with new values when the same template rule is invoked later in the transformation.

Can you express what concerns you about not having them passed?

I hope this helps.

. . . . . . . . . . Ken


-- XSLT/XQuery training: San Carlos, California 2010-04-26/30 Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03 XSLT/XQuery training: Ottawa, Canada 2010-05-10/14 XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.