Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing a Node as an XSL Template Parameter
    text
    copied!<p>In an existing XSL stylesheet I was passing a string into a named template. Due to a requirements change, I now need to display four strings, the string I was displaying and its three siblings. Rather than pass the four separate strings into the named template, I'm trying to pass their parent element (PETrailingFund in the code below), </p> <pre><code> &lt;xsl:call-template name="row"&gt; &lt;xsl:with-param name="label"&gt;Price/Earnings Trailing&lt;/xsl:with-param&gt; &lt;xsl:with-param name="formatMarker"&gt;x&lt;/xsl:with-param&gt; &lt;xsl:with-param name="fund" select="PETrailingFund" /&gt; &lt;xsl:with-param name="benchmark"&gt; &lt;xsl:value-of select="benchmark/PETrailingBenchmark"/&gt; &lt;/xsl:with-param&gt; &lt;xsl:with-param name="benchmark2"&gt; &lt;xsl:value-of select="benchmark2/PETrailingBenchmark"/&gt; &lt;/xsl:with-param&gt; &lt;/xsl:call-template&gt; </code></pre> <p>but the transformation blows up when I try to work with the "fund" parameter in the named template:</p> <pre><code>&lt;xsl:template name="row"&gt; &lt;xsl:param name="label" /&gt; &lt;xsl:param name="fund" /&gt; &lt;xsl:param name="benchmark"&gt;NOT PROVIDED&lt;/xsl:param&gt; &lt;xsl:param name="benchmark2"&gt;NOT PROVIDED&lt;/xsl:param&gt; &lt;xsl:param name="formatMarker"&gt;&amp;#160;&lt;/xsl:param&gt; &lt;xsl:param name="useDecimalFormatter"&gt;yes&lt;/xsl:param&gt; &lt;tr&gt; &lt;td class="first popup"&gt; &lt;xsl:value-of select="$label" disable-output-escaping="yes"/&gt; &lt;/td&gt; &lt;td&gt; &lt;xsl:if test="$benchmark = 'NOT PROVIDED'"&gt; &lt;xsl:attribute name="class"&gt;last&lt;/xsl:attribute&gt; &lt;/xsl:if&gt; &lt;xsl:value-of select="$fund/child::*" /&gt; &lt;xsl:value-of select="$formatMarker"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/xsl:template&gt; </code></pre> <p>From what I've read, I'm not really passing in a node but a result tree fragment and I need to get it back to a node (or node-set). Is that accurate or am I doing something else wrong? How would I convert it (I'm working in a fairly stock PHP5 environment that I can't change).</p> <p>N.B., I trimmed a good bit of the named template for simplicity's sake.</p>
 

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