[xsl] xsl:import overriding template rules

Subject: [xsl] xsl:import overriding template rules
From: Boudewijn Bosgoed <bbosgoed@xxxxxxx>
Date: Mon, 21 Mar 2011 14:21:46 +0100
Hello,

In my xsl stylesheets I use the xsl:import element a lot. The templates in the
imported xsl files can be overridden by the templates in the xsl file which
does the import. So far everything goes fine.
I was assuming that this overriding rule, applies to templates with an equal
matching pattern.

An example:
file aa.xsl
file bb.xsl

some templates of file aa.xsl are:

<xsl:template match='*'>
	<root>
		<xsl:apply-templates match='elementA'/>
	</root>
</xsl:template>

<xsl:template match='*[local-name() = "SpecificElement"]'>
	<xsl:element name='{name()}'>
		<xsl:apply-templates match='@* | comment() | text()'/>
	</xsl:element>
</xsl:template>

file bb.xsl
This file imports file aa.xsl

<xsl:import href='aa.xsl'/>

<xsl:template match='*'>
	<root>
		<xsl:template match='elementB'/>
	</root>
</xsl:template>


xsl:template match='*'  in file bb.xsl, overrides the xsl:template match='*'
in file aa.xsl. This is what I want and suspected.
But.... it overrides also the xsl:template match='*[local-name() =
"SpecificElement"]' in file aa.xsl. This is what I was not suspecting and also
don't want.

My question is, is it correct that the template xsl:template
match='*[local-name() = "SpecificElement"]' in file aa.xsl, is overridden by
the template match='*' if file bb.xsl.

Regards,
Boudewijn

Current Thread