I want to create an index (determine the position in the XML) for every table but the problem is that the tables are in different depth. I plan to process the XML with XSLT transformation to FO. I Any ideas how to do this?
Sample XML
<document>
<table> ... </table>
<section>
<table> ... </table>
<subsection>
<table> ... </table>
</subsection>
</section>
</document>
This will number your tables consecutively, starting from 1.
@Tomalak's solution isn't completely correct and will produce wrong result in the case when there are nested tables.
The reason for this is that the XPath
preceding
andancestor
axes are non-overlapping.One correct XPath expression that gives the wanted number is:
So, use: