Variable insertion repeated over and over in footer

Here should go questions about transforming XML with XSLT and FOP.
GabrielleScott
Posts: 4
Joined: Wed Oct 04, 2017 5:58 pm

Variable insertion repeated over and over in footer

Post by GabrielleScott »

I created a custom PDF plugin. One of the customizations inserts a Document ID in the footer of the PDF, using booknumber/bookpartno (for bookmaps) and othermetaname/othermetacontent (for maps).


When we transform a bookmap, the Document ID appears once in each footer, as expected.

When we transform a map, the Document ID repeats over and over again in each footer. It repeats 10 times on the cover page, and 15 times on body pages. How can I fix this?

Code: Select all

<!--  Document ID variable -->

<xsl:variable name="DocumentID">
<xsl:variable name="booknumber" select="(/*/opentopic:map//*[contains(@class, ' bookmap/booknumber ')])[1]"/>
<xsl:variable name="bookpartno" select="(/*/opentopic:map//*[contains(@class, ' bookmap/bookpartno ')])[1]"/>
<xsl:variable name="othermetaname" select="(/*/opentopic:map//*[contains(@class, ' topic/othermeta ')])/@name"/>
<xsl:variable name="othermetacontent" select="(/*/opentopic:map//*[contains(@class, ' topic/othermeta ')])/@content"/>
<xsl:choose>
<xsl:when test="exists($booknumber)">
<xsl:value-of select="$booknumber"/>
</xsl:when>
<xsl:when test="exists($bookpartno)">
<xsl:value-of select="$bookpartno"/>
</xsl:when>
<xsl:when test="exists($othermetaname)">
<xsl:value-of select="$othermetaname"/>
<xsl:value-of select="$othermetacontent"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'DocumentID'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

Code: Select all

  <xsl:template name="insertBodyOddFooter">

<fo:static-content flow-name="odd-body-footer">
<fo:block xsl:use-attribute-sets="__body__odd__footer__legal">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Body odd footer legal'"/>
<!-- <xsl:with-param name="params">
<heading>
<fo:inline xsl:use-attribute-sets="__body__odd__footer__heading">
<fo:retrieve-marker retrieve-class-name="current-header"/>
</fo:inline>
</heading>
<pagenum>
<fo:inline xsl:use-attribute-sets="__body__odd__footer__pagenum">
<fo:page-number/>
</fo:inline>
</pagenum>
</xsl:with-param> -->
</xsl:call-template>
</fo:block>
<fo:block xsl:use-attribute-sets="__body__odd__footer__addr">
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Body odd footer addr'"/>
<xsl:with-param name="params">
<!-- Adding Document ID variable -->
<DocumentID>
<xsl:value-of select="$DocumentID"/>
</DocumentID>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:static-content>

</xsl:template>