wrote:
> On 29 Mai, 19:00, Joseph Kesselman <keshlam-nos...@comcast.net> wrote:
>> As Martin said, the simplest solution is to use the xsl:call-template
>> operation and give the template you want to call a name.
>>
>> Similar things can be accomplished with modes, but that would be
>> overkill for this simple case.
>>
>> --
>> Joe Kesselman / Beware the fury of a patient man. -- John Dryden
>
> I am really surprised that this cannot be done (easily).
>
> My structure is like this:
>
> <note role="para">
> I hope it works.
> </note>
>
> What I want is:
> 1. <xsl:template match="note[@role = 'para']"> is executed
> 2. <xsl:template match="note"> is executed
>
> Of course, for the same element.
>
> Background:
> I am trying to print additional letters, if role="para" without
> loosing the ability of "<xsl:template match="note">".
> My use case is not that simple. I use DocBook XSL and I wanna modify
> the output of a simple element ("note"), if I use a special role.
> However, the DocBook XSL rule for "note" must be executed as well.
>
If you can alter the first template to add a name attribute then you can go
<xsl:template match="note" name="foo">
....
<xsl:template match="note[@role = 'para']">
stuff
<xsl:call-template name="foo"/>
if you are in a position that you have write access to the second
template but not the first (because you are over-riding some public xslt
file for example) that is the exact use case for xsl:apply-imports as
others have mentioned.
in one file you have
<xsl:template match="note">
then in the file that imports this you have
<xsl:template match="note[@role = 'para']">
stuff
<xsl:apply-imports/>
If you are using xslt2 you can use <xsl:next-match/> instead of
<xsl:apply-imports/> which works (more or less) the same way, but
without the requirement that the templates are in separate files.
David
--
http://dpcarlisle.blogspot.com