The conversion is obtained from two files. The first is the input, which contains the values that need to be inserted in the right places of the second file. Let the input file be:
<tr><td>5, 6</td><td>-6,-5</td></tr> The second file is opened in the conversion template using document('имяФайла.xml') and it needs to be copied to the output document by changing the values of the max attributes. New values are taken from the input document from <td> elements. The second file is:
<a id="id1" min="0,5" max="0,3"/> <b id="id2" min="-1,0" max="-3,1"/> Replacements are made accordingly, i.e. the first element id='id1' gets the value from the first <td> element in the attribute, and the second element id='id2' gets the values from the second <td> element. After all the replacements should have the following.
A generic template is required, i.e. the number of <a>,<b>,<a>... and <td> elements in input documents is any.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:variable name="file" select="document('имяФайла.xml')"/> <xsl:template match="/"> <xsl:for-each select="node()"> <xsl:copy-of select="."/> <xsl:attribute name="max"> <xsl:value-of select="$file//tr/td[position()]"/> </xsl:attribute> </xsl:for-each> </xsl:template> </xsl:stylesheet>