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

RE: rephrased: passing parameters to generic templates

Subject: RE: rephrased: passing parameters to generic templates
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 12 Apr 2006 17:06:14 +0100
axis parameter
> At 07:59 AM 4/12/2006, Andrew wrote:
> >If I were using 2.0 I would use a tunnelled parameter that 
> was created
> >at the <para> matching template and then read in the <a> matching
> >template, but the OP didnt day whether they could use 2.0 or not....
> What would the advantage of this be over the old-fashioned way?
> Would we save a few microseconds?
> Isn't the direct approach easier to maintain?

I think there have been four approaches proposed:

(a) use a global variable

(b) pass parameters down through each level of template call

(c) find your way up to the required node using the ancestor axis

(d) use a tunnel parameter.

Using a global variable is straightforward, but it does have one
disadvantage: if you decide you need to modify the stylesheet to process N
input documents rather than only one, then it won't work, because a global
variable can only have one value.

Passing parameters through each level of template call is definitely not
easy to maintain. If you add an extra element to the source document, you'll
have to remember to pass the parameter, and if you forget, you'll have a bug
that's difficult to diagnose.

I can't see many disadvantages with the approach of finding your way up the
tree using the ancestor axis. But it only works in cases where you know the
data is all in one tree. If the chapters in a book are in different
documents and were fetched using the document() function, then this approach
won't work.

Tunnel parameters look like a reasonable solution if the disadvantages of
the other three give you cause for concern. But I think my first choice
would be (c).

Michael Kay

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.