Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>There are a number of problems with your code</strong>:</p> <ol> <li><p><code>&lt;xsl:for-each select="//day[position() &gt; $firstPosToShow]"&gt;</code> . This will select every <code>day</code> element in the document that is at position <code>$firstPosToShow+1</code> or bigger in the set of <code>day</code> children <strong>of its parent</strong>! Most probably you want <code>(//day)[position() &gt;= $firstPosToShow]</code></p></li> <li><p><code>&lt;xsl:copy-of select=".|@*" /&gt;</code> . This copies the current element, but also copies its attributes. An attribute can be copied only when the parent is an element. This is not the case as the operations inside an untyped variable create a temporary tree (a document) and a document node cannot have attributes. The correct instruction is: <code>&lt;xsl:copy-of select="." /&gt;</code> </p></li> <li><p>List itemIn the following code:</p> <p> </p></li> </ol> <p>the expression <code>exsl:node-set($miniDays)</code> again is of type <code>document-node()</code> and the <code>&lt;xsl:for-each&gt;</code> selects just one (this) node. This explains the raised error, because <code>local:calculate-total-in-days(.)</code> expects an element-argument but is passed a document node.</p> <p><strong>The correct code is</strong>:</p> <pre><code>&lt;xsl:for-each select="exsl:node-set($miniDays)/*"&gt; &lt;xsl:variable name="in" select="local:calculate-total-in-days(.)" /&gt; &lt;!-- do some stuff with the var --&gt; &lt;/xsl:for-each&gt; </code></pre> <p>Also, <code>exslt:node:set()</code> is not required in XSLT 2.0, because there is no RTF type in XSLT 2.0, and in fact is not supported in Saxon 9.x. <strong>Therefore, the correct code will be</strong>:</p> <pre><code>&lt;xsl:for-each select="$miniDays/*"&gt; &lt;xsl:variable name="in" select="local:calculate-total-in-days(.)" /&gt; &lt;!-- do some stuff with the var --&gt; &lt;/xsl:for-each&gt; </code></pre> <p><strong>Alternatively</strong>, you may consider specifying the type of <code>$miniDays</code> explicitly as <code>element()*</code> and this will simplify the code -- it would not be necessary to use <code>$miniDays/*</code> -- just <code>$miniDays</code> </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