Subject: Re: [xsl] Onion-skin overriding stylesheet From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Wed, 7 Sep 2011 10:49:10 +0100 |
>> Taken to the extreme, you should also avoid xsl:value-of in favour of >> apply-templates with a text() matching template. > > Could you elaborate on the following with perhaps an example case. > Instead of: <xsl:template match="title"> (do some stuff) <xsl:value-of select="."/> </xsl:template> do: <xsl:template match="title"> (do some stuff) <xsl:apply-templates/> </xsl:template> as then if the requirement comes in to wrap the title in a <span class="foo"> for some customer, you can just add the follwing template in a new entry point stylesheet: <xsl:template match="title/text()"> <span class="foo"> <xsl:value-of select="."/> </span> </xsl:template> (when you know title only contains a string) If the template used value-of instead of the apply-templates then you would need to override the whole <title> matching template: <xsl:template match="title"> (do some stuff) <span class="foo"> <xsl:value-of select="."/> </span> </xsl:template> ...and duplicate the (do some stuff) code. That then means for any change to the code thats been duplicated you have to make the change in 2 places - both the hassle of making the same change twice, and remembering to do it in the first place. Alterntively you could just edit the existing code, maybe pass in a param and use a choose/when... that is a short road to a world of pain when the inevitable requests come in for more changes or more customers come along. cheers andrew -- Andrew Welch http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Onion-skin overriding sty, Alex Muir | Thread | Re: [xsl] Onion-skin overriding sty, Michael Kay |
Re: [xsl] Onion-skin overriding sty, Michael Kay | Date | Re: [xsl] Onion-skin overriding sty, Geert Bormans |
Month |