Note that there are some explanatory texts on larger screens.

plurals
  1. POApply xsl:template not to all elements but to half
    primarykey
    data
    text
    <p>I have an XSL template which processes an XML document into a test in Gherkin. For every element in the XML I'm producing and Gherkin line such as </p> <pre><code>And I fill in the "check-temp" field with "23" </code></pre> <p>That's fine, but I want to only produce this line for the first 20 instances of , then do some other output, then pick up where I left off. Something like this, using imaginary syntax:</p> <pre><code>&lt;xsl:for-each select="formline" [0..20]&gt; ...other stuff... &lt;xsl:for-each select="formline" [21..40]&gt; </code></pre> <p>Related to this, can XSL "know" how many matches are found?</p> <p>SOLVED: Thanks for your contributions. Here's what I've done:</p> <pre><code># Fill in first 'half' of form &lt;xsl:for-each select="formline[not(position() &gt; 20)]"&gt; &lt;xsl:for-each select="formentrycontext"&gt;And I fill in "&lt;xsl:value-of select="formentry/@id"/&gt;" with "xxx" &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; # Check first 'half' of form &lt;xsl:for-each select="formline[not(position() &gt; 20)]"&gt; &lt;xsl:for-each select="formentrycontext"&gt;And the "&lt;xsl:value-of select="formentry/@id"/&gt;" field should contain "xxx" &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; # Fill in second 'half' of form &lt;xsl:for-each select="formline[position() &gt; 20 and not(position() &gt; last())]"&gt; &lt;xsl:for-each select="formentrycontext"&gt;And I fill in "&lt;xsl:value-of select="formentry/@id"/&gt;" with "xxx" &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; # Check second 'half' of form &lt;xsl:for-each select="formline[position() &gt; 20 and not(position() &gt; last())]"&gt; &lt;xsl:for-each select="formentrycontext"&gt;And I fill in "&lt;xsl:value-of select="formentry/@id"/&gt;" with "xxx" &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; </code></pre> <p>I'm not using the apply-templates as I want to apply one transform at one time and then another transform later to the same data. Maybe there is a way to do it but this works perfectly for me so far.</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.
    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