Instead of using position()
, try using xsl:number.
Here's an example to get you started...
XML Input
<class>
<refclass>10</refclass>
<begin>6</begin>
<part>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
</part>
<part>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
</part>
<part>
<dados>
<nome>...</nome>
<idade>---</idade>
</dados>
</part>
</class>
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block/>
</fo:table-cell>
<fo:table-cell>
<fo:block>nome</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>idade</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:apply-templates select="part/dados"/>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="dados">
<xsl:variable name="level">
<xsl:number level="any"/>
</xsl:variable>
<fo:table-row>
<fo:table-cell>
<fo:block><xsl:value-of select="concat(/*/refclass,format-number(($level+/*/begin)-1,'00'))"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="nome"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="idade"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
XSL-FO Output
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block/>
</fo:table-cell>
<fo:table-cell>
<fo:block>nome</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>idade</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1006</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1007</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1008</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1009</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1010</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1011</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1012</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>1013</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>...</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>---</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
PDF Representation