[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: calling template with name passed in a variable
Hi Piotr,
At 11:12 AM 12/19/2009, you wrote: Let's say someone needs to handle a new type some day. He asks me how to do this and then I would like to avoid having to explain how code that is concerned with matching and applying his new template works. He doesn't have to know this, he probably doesn't even care. He doesn't need to know this if he doesn't need to code XSLT, true, but if he does, maybe he's better off knowing this. :-) I wish I could just say add your template anywhere and name it the same as the type it handles. Wouldn't that be cleaner? It would seem cleaner, yes. But it would only hide the dirt. This example is not the best one to illustrate the above situation because matching in this case is really simple but we could imagine much more complex matching logic involving many templates not just one. Those of us who have done it (and yes, these techniques have been tried) know that template matching scales very well. It's also, for reasons explained earlier, more robust. So far the best argument you have given for not using the mechanism proposed is "it's confusing to people who don't know the language and can't be bothered to learn it". I admit this is sometimes a problem, but I'm not sure it's a problem with XSLT. As my output is a source code I prefer fatal errors to producing invalid output. There are certainly ways to trap these errors besides generating a complile-time error in your XSLT. :-) Note that the XSLT language is designed so that the processor knows all possible call requests and all possible callable templates at compile time. It can do optimization and rewriting based on this knowledge, which cannot be done if the call were dynamically resolved. This is a creative approach. But if it were me, I admit I would just document how they should write the actual XSLT (which isn't that different, I think), and hope that they would either do that correctly without complaint, or be inspired to learn enough about XSLT that they were content with it. There is also the remote possibility that you get a user who actually knows enough XSLT to be suspicious about writing new templates that can't possibly be called from modules they haven't written.... Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
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
|