Re: [xsl] Why are these two template rules ambiguous?

Subject: Re: [xsl] Why are these two template rules ambiguous?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Aug 2022 17:25:09 -0000
Firstly, it's not at all clear that one of these rules is "more specific". If
you draw the Venn diagram, the two patterns define two sets of elements,
neither of which is a subset of the other.

Secondly, XSLT does not say that the more specific rule wins. It says (see
https://www.w3.org/TR/xslt-30/#default-priority)

<quote>
In many cases this means that highly selective patterns have higher priority
than less selective patterns...

However, it is not invariably true that a more selective pattern has higher
priority than a less selective pattern. For example, the priority of the
pattern node()[self::*] is higher than that of the pattern salary. Similarly,
the patterns attribute(*, xs:decimal) and attribute(*, xs:short) have the same
priority, despite the fact that the latter pattern matches a subset of the
nodes matched by the former.
</quote>

Michael Kay
Saxonica

> On 23 Aug 2022, at 17:42, David Carlisle d.p.carlisle@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
>
> On Tue, 23 Aug 2022 at 17:35, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi Folks,
>
> I have these two template rules:
>
> <xsl:template match="procedureLeg[ancestor::airport]">
> <xsl:template match="*[child::*]">
>
> When the <procedureLeg> element is encountered in the instance document,
Saxon throws a warning, saying that it is ambiguous which rule to use.
>
> But, but, but, ...
>
> Clearly the first rule is more specific.
>
> "specific" isn't a defined term here though. They both have the same default
priority.
>
> Default priority is based on some simple rules on the structure (and both of
these have [..])
> it explicitly does not do logical analysis to determine "anything that
matches the first pattern must match the second", which is what  I guess you
mean by specific here.
>
> David
>
>
>
> I thought the XSLT specification says: the more specific rule wins. Right?
So why is Saxon throwing a warning message?
>
> I know that I can add "priority" to the first rule and then the warning will
go away, but I shouldn't have to do that, right?
>
> /Roger
>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)

Current Thread