xsl-list
[Top] [All Lists]

RE: [xsl] rephrased: passing parameters to generic templates

2006-04-12 09:06:58
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
http://www.saxonica.com/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--