Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it correct that an XSLT will not process child nodes of the current node unless apply-templates is explicity called?
    primarykey
    data
    text
    <p>I think I know the answer to this, but I just want confirmation I'm understanding this correctly.</p> <p>When an XSLT template matches and executes, <em>the children of the current node (the node current having a matching template executed) are not processed by default.</em> You must call "apply-templates" to get the processor to traverse down into the child nodes of the current (matched) node.</p> <p>Consider this XML:</p> <pre><code>&lt;person&gt; &lt;firstName&gt;Deane&lt;/firstName&gt; &lt;lastName&gt;Barker&lt;/lastName&gt; &lt;/person&gt; </code></pre> <p>During the transform, the XSLT processor starts at the "person" element. If it finds a template for that, it will execute it, but then will not descend into the "firstName" and "lastName" elements to look for templates for those. It will only do this if "apply-templates" is explicitly called in the template for "person".</p> <p>Consider this XSL:</p> <pre><code>&lt;!-- Template #1 --&gt; &lt;xsl:template match="person"&gt; I found a "person" element &lt;/xsl:template&gt; &lt;!-- Template #2 --&gt; &lt;xsl:template match="firstName"&gt; I found a "firstName" element &lt;/xsl:template&gt; </code></pre> <p>In this case, Template #2 will not be run, correct? The traversal of the XML document will hit the "person" element, find Template #1, execute it, then never descend into the children of "person."</p> <p>If I change the first template to this --</p> <pre><code>&lt;!-- Template #1 --&gt; &lt;xsl:template match="person"&gt; I found a "person" element &lt;xsl:apply-templates select="firstName"/&gt; &lt;/xsl:template&gt; </code></pre> <p>Only then will Template #2 run. Am I understanding this correctly?</p>
    singulars
    1. This table or related slice is empty.
    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. 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