Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The full resolution process is described in <a href="http://www.w3.org/TR/xslt#conflict">section 5.5 of the XSLT spec</a>.</p> <p>In general, the following rules apply in order (e.g. a template eliminated from consideration due to lower import precedence is eliminated permanently, regardless of its priority):</p> <ol> <li>Imported templates have lower precedence than templates in the primary stylesheet</li> <li>Templates with a higher value in their <code>priority</code> attribute have higher precedence</li> <li>Templates without a <code>priority</code> attribute are assigned a default priority. Templates with more specific patterns take precedence.</li> <li>It's an error if the previous three steps leave more than one template in consideration, but XSLT processors can recover by defaulting to the last one in the file.</li> </ol> <p>In your specific case both templates have the same priority, so #4 above applies. To demonstrate:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match= "vehicle_details[preceding-sibling::vehicle_type = '4x4']/*"&gt; template1 &lt;/xsl:template&gt; &lt;xsl:template match="vehicle_details[descendant::color = 'red']/*"&gt; template2 &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Applied to this input (both templates match):</p> <pre><code>&lt;root&gt; &lt;vehicle_type&gt;4x4&lt;/vehicle_type&gt; &lt;vehicle_details&gt; &lt;color&gt;red&lt;/color&gt; &lt;/vehicle_details&gt; &lt;/root&gt; </code></pre> <p>Output:</p> <pre><code>template2 </code></pre> <p>But if we swap the order of the templates:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="vehicle_details[descendant::color = 'red']/*"&gt; template2 &lt;/xsl:template&gt; &lt;xsl:template match= "vehicle_details[preceding-sibling::vehicle_type = '4x4']/*"&gt; template1 &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Then the output is:</p> <pre><code>template1 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload