xsl-list
[Top] [All Lists]

RE: Apply-templates - how to omit top level element tags?

2005-09-08 16:43:19
Why is using one inline in each place I need it more complicated than 
having to (and debug and maintain) separate templates in each and 
every
David Carlisle >> you could say same about C, why use functions when you
could inline everythng, or java, why bother with all those pesky objects
and classes. 

Yes, but are you familiar with the more advanced concept of anonymous
methods in C#?
http://www.theserverside.net/articles/showarticle.tss?id=AnonymousMethod
s

Essentially they are used for the same reason I'm using an "inline XSL",
because there's no value to pollute the namespace to create a name
function/class when it would only be used once.

There was a similar concept in Clipper called a CodeBlock for which I
wrote a chapter in my book (publishing in 1991):
http://www.amazon.com/exec/obidos/tg/detail/-/0201570181

I have found codeblocks/anon methods to be one of the least implemented
yet most useful language features I've ever used.  Of course it might be
I appreciate them so much because so few languages offer them, i.e. one
often only values what they cannot have. :)

If you have a lot of inlined long xpath selecting specficc
grandchildren then it's much harder to change to code if a revised input
format makes them children or great grandchildren, but if you just use
<xsl:apply-templates/> everywhere and go with the flow it's much easier
to make a stylesheet that can cope with wide variations in input
structure.

In my particular case, I had an element called <Name/> which by nature
would only every contain a short text naming something like a Guide, a
Section, a Product, a Vendor, etc.  But simply outputting text using
<xsl:value-of> did not allow authors to include what would in essence be
macros that would expand before output, such as <TrademarkSymbol/>,
<CopyrightSymbol/>, or even <AuthorsName/>.  

So I hear what you are saying, and I agree in other contexts, but I
don't think it applies in the context I needed.

-Mike






-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk] 
Sent: Thursday, September 08, 2005 7:33 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Apply-templates - how to omit top level element tags?


Why is using one inline in each place I need it more complicated than 
having to (and debug and maintain) separate templates in each and 
every

you could say same about C, why use functions when you could inline
everythng, or java, why bother with all those pesky objects and classes.

templates are the main (only) modularisation of code mechanism in xslt
and using them generakky makes for more easily freusable and
maintainable code. especially in the face of possibly changing input
format. If you have a lot of inlined long xpath selecting specficc
grandchildren then it's much harder to change to code if a revised input
format makes them children or great grandchildren, but if you just use
<xsl:apply-templates/> everywhere and go with the flow it's much easier
to make a stylesheet that can cope with wide variations in input
structure.

David
 

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. For more information on a proactive anti-virus
service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>