Re: [xsl] Strict sequential identity rule?

Subject: Re: [xsl] Strict sequential identity rule?
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Thu, 22 Sep 2005 09:14:09 +0100
Evan,

Can your reporting system tell when one template has been chosen oven
another purely on import precendence, even though it has a higher
priority?

For example:

<xsl:import href="one.xsl"/>
<xsl:import href="two.xsl"/>

one.xsl contains:
<xsl:template match="elem" priority="10">

two.xsl contains:
<xsl:template match="elem">

The "elem" matching template in two.xsl will always be chosen over any
"elem" matching template in any stylesheet that is imported before it,
regardless of priority.  This currently all happens silently and can
be a nightmare to discover.

I would've hoped for the usual "ambiguous rule match", but that
happens later in conflict resolution.  The very first conflict
resolution rule is:

"1. First, only the matching template rule or rules with the highest
import precedence are considered. Other matching template rules with
lower precedence are eliminated from consideration."

So that means the "elem" matching template with priority 10 in one.xsl
is disregarded purely because one.xsl is imported before two.xsl.  I
would've expected the ordering of items in the stylesheet the be the
very last technique for conflict resolution, just like it is for
templates.

However it's not, but it would be really helpful to offer a warning
such as "A template with a higher priority conflicts with a template
with a higher import precendence" for when that happens, and then
usual ambiguous rule match for when the templates are equal priority.

I've mentioned this a few times before and it did touch on the idea of
the ability to make templates "final" (in java terms) to ensure anyone
importing your stylesheet module can't easily break it.  You certainly
can't give it a massive priority, as the real priority is decided by
whoever orders the import statements...

Current Thread