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

Re: Passing parameters to an indirectly called templat

Subject: Re: Passing parameters to an indirectly called template after matching.
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 17 Apr 2008 13:54:04 +0200
Re:  Passing parameters to an indirectly called templat
Kannan wrote:
Can I pass parameters like this.

Calling_Point => A_Named_Template, do apply-templates => {One or more
matching Templates } => A_Named_Template.

I tried to do this by passing parameters along with apply-templates,
and then passing it again from all matched templates to a named
template where I finally need it, it ended up in infinite loop. When I
just taken out the parameter passing and used global variables it
worked fine.

That you turned into an infinite loop has to do with a bug in your programming logic, not the passing itself. And probably you mean that the recursion went too deeply nested (but this may feel like a "loop"). In XSLT 1.0, the method of programming is certainly viable. But as soon as a new step is required between one and another template, you must remember to pass on the parameters again (which can become a maintenance nightmare)


What you are after is what Michael Kay suggested: the XSLT 2.0 feature of tunneling parameters which can be defined once and will be passed on until it matches a template that defines these parameters (where you must also specify that they are tunneled).

If you have to stick to XSLT 1.0, using global parameters may be the easiest way to go. If you want to modularize or "hide" the variables, you can use an imported stylesheet which defines its own "global" parameters (variables).

Cheers,
-- Abel Braaksma

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.