Hello! I have several html files with tables with different number of rows. I alternately open these tables and add them line by line to the general table. In my calculations you need to know how many lines at this stage have already been processed from previous files. That's just reassign the variable can not, and take all the lines from the previous files too late. My codec:

<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:template match="/"> <html> <table> <xsl:for-each select="html/body/table/tr"> <xsl:variable name="base" select="td[1]" /> <xsl:variable name="nameF" select="concat('table_',position(),'.html')" /> <xsl:for-each select="document($nameF)//table/tr"> <xsl:variable name="Nk" select="$Nk+count('document($nameF)//table/tr')" /> <tr> <td> <xsl:choose> <xsl:when test='position()=1'> <xsl:value-of select="$base" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="number(td[1])+$Nk" /> </xsl:otherwise> </xsl:choose> </td> <xsl:copy-of select="subsequence(td,2)" /> </tr> </xsl:for-each> </xsl:for-each> </table> </html> </xsl:template> </xsl:stylesheet> 

Input files have the form (differ in the number of lines):

 <html> <table> <tr> <td>0</td> <td>0</td> <td>0, 0.060, 0</td> <td>1, 0, 0</td> <td>0</td> <td>2</td> </tr> ......... <tr> <td>4</td> <td>1</td> <td>-0.075, -0.030, 0</td> <td>0, 0, 1</td> <td>-130</td> <td>130</td> </tr> </table> </html> 
  • Where do you need to know? Do you need to write Обработано Х строк in the output document? - Anton Shchyrov
  • To you on en.so in the comments suggested the option with xslt 2.0. It turned out to do? If yes, write the answer. - Alexander Petrov

0