Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is an extension to the answer given by @Lego Stormtroopr. He suggests starting with two templates each matching one type:</p> <pre><code>&lt;xsl:template match="/data[admin/type='one']/detail"&gt; &lt;!-- Type one specific transform --&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/data[admin/type='two']/detail"&gt; &lt;!-- Type two specific transform --&gt; &lt;/xsl:template&gt; </code></pre> <p>Now for the <code>content to appear for ALL types</code>, here are two possibilities. If the part appearing for all types is about <em>content</em>, use a global variable and store it there:</p> <pre><code>&lt;xsl:variable name="var1"&gt; &lt;!--Content for all types--&gt; &lt;/xsl:variable&gt; &lt;xsl:template match="/data[admin/type='one']/detail"&gt; &lt;!-- content for ALL types example: --&gt; &lt;xsl:value-of select="$var1"/&gt; &lt;!-- Go on with type specific content --&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/data[admin/type='two']/detail"&gt; &lt;!-- content for ALL types example: --&gt; &lt;xsl:value-of select="$var1"/&gt; &lt;!-- Go on with type specific content --&gt; &lt;/xsl:template&gt; </code></pre> <p>If there are input elements inside <code>detail</code> that you need to catch, just define another template for them and let <code>apply-templates</code> find them.</p> <pre><code>&lt;xsl:template match="/data[admin/type='one']/detail"&gt; &lt;!-- content for ALL types example: --&gt; &lt;xsl:apply-templates/&gt; &lt;!-- Go on with type specific content --&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/data[admin/type='two']/detail"&gt; &lt;!-- content for ALL types example: --&gt; &lt;xsl:apply-templates/&gt; &lt;!-- Go on with type specific content --&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*[parent::detail]"&gt; &lt;!--template content--&gt; &lt;/xsl:template&gt; </code></pre>
    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.
    1. VO
      singulars
      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