Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to cast from XRTreeFrag into XNodeSet
    primarykey
    data
    text
    <p>I have the following test code... I am trying to pass a node-set as a param. After many hours, i finally was able to pass it to my template.</p> <p>How I pass my node-set to the template:</p> <pre><code>&lt;xsl:call-template name="listing"&gt; &lt;xsl:with-param name="customData"&gt; &lt;xsl:apply-templates select="exslt:node-set($data)"/&gt; &lt;/xsl:with-param&gt; &lt;/xsl:call-template&gt; </code></pre> <p>How my template receives it: </p> <pre><code>&lt;xsl:template name="listing"&gt; &lt;xsl:param name="customData" select="/.."/&gt; &lt;xsl:variable name="data"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="not($customData)"&gt; &lt;xsl:value-of select="/data"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$customData"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:variable&gt; &lt;textarea&gt;&lt;xsl:copy-of select="$data"&gt;&lt;/xsl:copy-of&gt;&lt;/textarea&gt; &lt;/xsl:call-template&gt; </code></pre> <p>If I set the parameters with a one liner, then it would not complain... example:</p> <pre><code>&lt;xsl:variable name="data" select="$customData"/&gt; </code></pre> <p>But as soon as I try to set it like this, it breaks:</p> <pre><code>&lt;xsl:variable name="data"&gt; &lt;xsl:value-of select="$customData"/&gt; &lt;/xsl:variable&gt; </code></pre> <p>Getting this error message: <strong>org.apache.xpath.objects.XRTreeFrag cannot be cast to org.apache.xpath.objects.XNodeSet</strong></p> <p>I was only been able to find another thread dated back in 2000, talk about this similar issue... I need to re-nodeset it back using something like node-set($customData)/* but I tried that, and it was a no go.</p> <p><strong>EDIT:</strong> OK, I can confirm that I successfully passed the node-set inside my template. But I'm still unable to copy it over to my variable... It kept saying that it is still a RTF.</p> <pre><code>&lt;xsl:template name="listing"&gt; &lt;xsl:param name="customData" as="node-set"/&gt; &lt;!--&lt;xsl:variable name="data" select="/data"/&gt;--&gt; &lt;xsl:variable name="data"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="count($customData) != 0"&gt; &lt;xsl:copy-of select="$customData"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="/data"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:variable&gt; &lt;textarea&gt;&lt;xsl:value-of select="$customData/record[1]"/&gt;&lt;/textarea&gt; &lt;textarea&gt;&lt;xsl:value-of select="/data/record[1]"/&gt;&lt;/textarea&gt; &lt;textarea&gt;&lt;xsl:value-of select="$data/record[1]"/&gt;&lt;/textarea&gt; &lt;/xsl:template&gt; </code></pre> <p>The above test, shows that I can access $customData and the original /data without any problem, they both show the record... but $data is messed up. So that means the copy from $customData to $data wasn't working...</p> <p>I tried the following ways, none of them work:</p> <pre><code>&lt;xsl:copy-of select="$customData"/&gt; &lt;xsl:value-of select="$customData"/&gt; &lt;xsl:apply-templates select="exslt:node-set($customData)"/&gt; &lt;xsl:apply-templates select="exslt:node-set($customData)/data"/&gt; </code></pre> <p>Any idea...?</p>
    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.
 

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