Processing Multiple Matching Template Rules

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Developer's Guide

Processing Multiple Matching Template Rules

If more than one template rule matches a given node in the source tree, MSXML gives the highest priority to the template rule that matches the most specific pattern. Specifically, the conflict is resolved as follows:

First, MSXML selects the pattern with the highest import precedence. An XSLT file can import other XSLT files, and the order in which the corresponding <xsl:import> elements appear in the original file determines the import precedence. If there is still more than one match after this step, proceed to the next step.

The second step is to assign a numeric priority to each conflicting pattern, as shown in the following table. Select the pattern with the highest priority. If there is still more than one match after this step, proceed to the next step.

Assign a priority of... If the match pattern...
0 (zero) Is an element or attribute name.

—Or—

Is a processing instruction with a specific target.

-0.25 Includes the wildcard character (*).
-0.5 Consists of only a node test, such as text(), for selecting nodes.
0.5 Does not match any of the other criteria.

Note   If the pattern contains a pipe symbol (|) that specifies alternate XPath expressions, treat each expression as if it were a separate match pattern.

Finally, if everything else is equal, the last matching pattern is used as default.

See Also

Processing Template Rules | Understanding the Built-in Template Rules