Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>The problem with the provided code is here:</strong></p> <blockquote> <pre><code>&lt;xsl:value-of select="$Content1"/&gt; </code></pre> </blockquote> <p>This will output either the concatenation of all text-nodes descendents of the top node of <code>$Content1</code> (if it contains a document) or the string value of its first element or text child (if it is an XML fragment).</p> <p><strong>You need to use</strong> </p> <p><code>&lt;xsl:copy-of select='$pContent1'&gt;</code> </p> <p><strong>instead of</strong> </p> <p><code>&lt;xsl:value-of select='$pContent1'&gt;</code>. </p> <p>This correctly copies all children nodes of <code>$pContent1</code></p> <p><strong>Below is a corrected transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/"&gt; &lt;xsl:call-template name="MainMasterPage"&gt; &lt;xsl:with-param name="pContent1"&gt; &lt;h1&gt;Title&lt;/h1&gt; &lt;p&gt;More Content&lt;/p&gt; &lt;xsl:call-template name="SomeOtherTemplate"/&gt; &lt;/xsl:with-param&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; &lt;xsl:template name="MainMasterPage"&gt; &lt;xsl:param name="pContent1"/&gt; &lt;html&gt; &lt;!-- bunch of stuff here --&gt; &lt;xsl:copy-of select="$pContent1"/&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template name="SomeOtherTemplate"&gt; &lt;h2&gt;Hello, World!&lt;/h2&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on any XML document (not used), the wanted, correct result is produced</strong>:</p> <pre><code>&lt;html&gt; &lt;h1&gt;Title&lt;/h1&gt; &lt;p&gt;More Content&lt;/p&gt; &lt;h2&gt;Hello, World!&lt;/h2&gt; &lt;/html&gt; </code></pre>
 

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