Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As pointed out, XSLT can create nodes on the target document at will (I didn't know this and this was the key part). Turns out that what I needed is a simple for-loop in XSLT. Once I realized this, a quick Google search yielded the following results:</p> <p><a href="http://quomon.com/question-How-to-make-a-for-loop-in-xslt-not-for-each-809.aspx" rel="nofollow">http://quomon.com/question-How-to-make-a-for-loop-in-xslt-not-for-each-809.aspx</a></p> <p><a href="http://snippets.dzone.com/posts/show/930" rel="nofollow">http://snippets.dzone.com/posts/show/930</a></p> <p>Another thing worth noting is that (as pointed out by the first link), XSLT is a functional language, not procedural, so sometimes you do have to resort to using recursion or an extension. This case is definitely one of those times since I couldn't use a careful selection of nodes using the select attribute on an xsl:for-each (since this filler data wasn't part of the source document).</p> <p>Specifically, for this case, what I did was:</p> <p>Add a Scripting functoid. Add two inputs:</p> <ul> <li>A constant with value "1" (this is the initial value of the i variable)</li> <li>The length of the loop (number of times to repeat the body of the loop)</li> </ul> <p>Paste the following XSLT template as an "Inline XSLT Call Template" script:</p> <pre><code>&lt;xsl:template name="ForLoop"&gt; &lt;xsl:param name="i" /&gt; &lt;!-- index counter, 1-based, will be incremented with every recursive call --&gt; &lt;xsl:param name="length" /&gt; &lt;!-- exit loop when i &gt;= length --&gt; &lt;!-- Output the desired node(s) if we're still looping --&gt; &lt;!-- The base case is when i &gt; length (in that case, do nothing) --&gt; &lt;xsl:if test="$i &amp;lt;= $length"&gt; &lt;Filler&gt; &lt;Padding&gt;999999&lt;/Padding&gt; &lt;/Filler&gt; &lt;/xsl:if&gt; &lt;!-- Call the ForLoop template recursively, incrementing i --&gt; &lt;xsl:if test="$i &amp;lt;= $length"&gt; &lt;xsl:call-template name="ForLoop"&gt; &lt;xsl:with-param name="i"&gt; &lt;xsl:value-of select="$i + 1"/&gt; &lt;/xsl:with-param&gt; &lt;xsl:with-param name="length"&gt; &lt;xsl:value-of select="$length"/&gt; &lt;/xsl:with-param&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;/xsl:template&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