I have a several pages sequences in my xsl file. An xsl-template is called inside each page sequence. Inside each template I have a block that contains a variable that I need to be incremented if the block is executed....I tried to use a global variable but I found in many posts here we cannot increment a global variable in xsl-fo...Can SomeOne please guides me How to do that ?
My xsl-file is something like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"
xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
<xsl:output encoding="UTF-8" indent="yes" method="xml"
standalone="no" omit-xml-declaration="no" />
<xsl:template match="analyseData">
<fo:page-sequence master-reference="simpleA6">
<fo:flow flow-name="xsl-region-body" border-collapse="collapse">
<xsl:call-template name="template1" />
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="simpleA6">
<fo:flow flow-name="xsl-region-body" border-collapse="collapse">
<xsl:call-template name="template2" />
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="simpleA6">
<fo:flow flow-name="xsl-region-body" border-collapse="collapse">
<xsl:call-template name="template3" />
</fo:flow>
</fo:page-sequence>
</xsl:template>
Well, there is very limited information here but I could guess.
Nothing stops you from using XSL and an identity-transform to modify some interim result. So you could do what you are doing. Whenever you need to output this counter, why not write to the output <counter/>. Nothing more, just an empty tag that represents the counter.
Then write an identity-translate XSL that outputs the resulting file as is, except for a match on <counter>. This template would replace it with:
Note: you could maybe also use <xsl:number> here.
So you would do:
XML+XSL -> XSL FO with counters + XSL identity change counters -> XSL FO -> format with your formatter