I need to make create local variables within a fo:table-body to filter for-each created fo:table-rows. I cannot insert an fo:block as a child of the table-body. Is there any other way I make these Variables 'local' besides using a Block and which would be compatible with the fo:table-body's permitted children? Any help very much appreciated!
I had started by inserting the Variables as children of the xsl:for-each, within which I generate the fo:table-row (see below). I hoped the variables would remain local within each row but the absence of an fo:block means these variables are being applied globally (at the table level).
I need the variables to be local to each $trajectoryPoint to apply to subsequent for-each filtering.
I also tried using a template but the param's are treated the same way, I guess due to the absence of a Block between table-body and the for-each.
<fo:table-body>
<xsl:for-each select="$trajectoryPoint">
<xsl:variable name="dist1" select="./distance1"/>
<xsl:variable name="dist2" select="./distance2"/>
<xsl:table-row>
<fo:table-cell>
<fo:block>
<xsl:text>REGULAR ROW INFO</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="otherNodeSet[/Distance >= $dist1 and /Distance < $dist2]">
<xsl:table-row>
<fo:table-cell>
<fo:block>
<xsl:text>SPECIAL ROW INFO</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:for-each>
</fo:table-body>
Change:
to:
When
$trajectoryPointcontains multiple nodes, thexsl:for-eachprocesses each of them separately, but each time, you are setting$dist1and$dist2to all of thedistance1children anddistance2children, respectively, of all of the nodes in$trajectoryPoint.Each time that
xsl:for-eachprocesses an item, it sets the context item (.in XPath) to that item. (See https://www.w3.org/TR/xslt-30/#element-for-each) Using.instead of$trajectoryPointgets you thedistance1anddistance2children of just the context item instead of all of them.