xml - XPath - determine the element position -
I want to create an index for each table (determine the position in XML) but the problem is that tables are different Depth I am planning to process XML with XSLT conversion for FO. How do I have any ideas?
@Tormark's solution is not completely correct And when there are nested tables, present the wrong result in the case. The reason for this is that XPath Returns the desired number one The correct XPath expression is: Then, use : Sample XML
& lt; Document & gt; & Lt; Table & gt; ... & lt; / Table & gt; & Lt; Section & gt; & Lt; Table & gt; ... & lt; / Table & gt; & Lt; Sub-section & gt; & Lt; Table & gt; ... & lt; / Table & gt; & Lt; / Sub-section & gt; & Lt; / Section & gt; & Lt; / Documents & gt;
predecessor and
ancestor axis are non-overlapping
count (ancestor :: table | preceding :: table) + 1
& lt; Xsl: template match = "table" & gt; & Lt; Table id = "tbl_ {count (ancestor :: table | preceding :: table) + 1}" & gt; & Lt ;! - Further processing - & gt; & Lt; / Table & gt; & Lt; / XSL: Templates & gt;
Comments
Post a Comment