[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: rephrased: passing parameters to generic templates
> 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|