Alex B
Alex B

Reputation: 1019

Why doesn't XSL match this statement?

I have an attribute that I match against. It will match 2 XSL templates but one is more specific than the other. However, unless I put the 'simpler' (predicate is less specific) one above the other in the stylesheet it will match the simpler one. From http://www.w3.org/TR/xslt/#conflict and other questions I can see that if it matches 2 templates it will use the most specific and then if they are the same it will match the last one in the stylesheet.

Template 1:

<xsl:template match="@audit[contains($tier,'tier_3')][((starts-with(.,'approve') and contains(.,'CM')) or (contains(.,'ReviewRequested') and not(contains(.,'CM') or contains(.,'BM') or contains(.,'ME'))))]" mode="action">

Template 2:

<xsl:template match="@audit[contains($tier,'tier_3')]" mode="action">

What rule am I unaware of that is causing this to happen?

I change the match to have 1 set of square brackets instead of 2 by changing to:

    <xsl:template match="@audit[contains($tier,'tier_3') and ((starts-with(.,'approve') and contains(.,'CM')) or (contains(.,'ReviewRequested') and not(contains(.,'CM') or contains(.,'BM') or contains(.,'ME'))))]" mode="action">

But the same result.

I know it matches both because if I comment out the simple one, it matches against Template 1.

Any ideas?

Upvotes: 0

Views: 167

Answers (1)

Ben
Ben

Reputation: 35613

They are all equally specific because they all have the same path @audit and they all have a node test.

The complexity of the node test itself is not analysed for the purposes of resolution. This is all made quite explicit in the document you linked - did you actually read it?

If you want a specific order, either order the templates or use the priority attribute on the template rule.

Upvotes: 2

Related Questions