Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate attribute in XSL for-each
    text
    copied!<p>At work I've been given the fun task of generating PDFs with XSL. The XML structure I'm working with is similar to</p> <pre><code>&lt;records&gt; &lt;topLevel&gt; &lt;topLevelID&gt;&lt;/topLevelID&gt; &lt;secondLevel&gt; &lt;secondLevelID&gt;&lt;/secondLevelID&gt; &lt;thirdLevel&gt; &lt;/thirdLevel&gt; &lt;thirdLevel&gt; &lt;/thirdLevel&gt; &lt;/secondLevel&gt; &lt;/topLevel&gt; &lt;topLevel&gt; &lt;topLevelID&gt;&lt;/topLevelID&gt; &lt;secondLevel&gt; &lt;secondLevelID&gt;&lt;/secondLevelID&gt; &lt;thirdLevel&gt; &lt;/thirdLevel&gt; &lt;thirdLevel&gt; &lt;/thirdLevel&gt; &lt;/secondLevel&gt; &lt;/topLevel&gt; &lt;/records&gt; </code></pre> <p>I would try to give a more meaningful example of the XML, but I don't feel like approaching any legal boundaries that may exist. With that XML structure, I have to output a block of text in the PDF for every <code>thirdLevel</code> node. The XSL I have so far is like</p> <pre><code>&lt;xsl:for-each select ="topLevel"&gt; &lt;xsl:variable name="topID" select="topLevelID"/&gt; &lt;xsl:for-each select ="secondLevel"&gt; &lt;xsl:variable name="secondID" select="secondLevelID"/&gt; &lt;xsl:for-each select="thirdLevel"&gt; &lt;fo:block-container position="absolute" height="12.8pt" width="220.8pt" left="160pt" display-align="auto"&gt; &lt;xsl:attribute name="top"&gt; &lt;xsl:value-of select="concat(193 + [whatshouldgohere]), 'pt')"/&gt; &lt;/xsl:attribute&gt; &lt;fo:block font-size="7pt"&gt; &lt;xsl:call-template name="insertThirdLevel"/&gt; &lt;/fo:block&gt; &lt;/fo:block-container&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; </code></pre> <p>Basically, I need to add some value to the top attribute to make the text for each <code>thirdLevel</code> node appear on its own line. I've tried using combinations of adding/multiplying by the ID (starts at 1 and increases by 1 for each set) and <code>position()</code>, but I can't seem to get it right.</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