Topic: How in xslt to transform in advance unknown kol-in columns in the table?
Certainly on mind at once comes to use a cycle:
<xsl:for-each select = Expression </xsl:for-each>
For example, it is necessary to deduce the data on customers:
<customers> <customer> <name> Vanja </name> <phone> (812 123-4567 </phone> </customer> <customer> <name> Petja </name> <phone> (812 423-4537 </phone> </customer> </customers>
That it to make, it is necessary to organize here such classical cycle:
<xsl:for-each select = "customers/customer"> <TR> <TD> <xsl:value-of select = "name"/> </TD> <TD> <xsl:value-of select = "phone"/> </TD> </TR> </xsl:for-each>
As a result it is had necessary 2 columns:
Name Phone -------------------- (812 123-4567 Petja (812 423-4537
But it is all for an output of the unknown person in advance kol-va lines and if it is not known kol-in columns?
For example, it is necessary to count kol-in made these clients of orders for the period set in the parameter that was here so:
Name Phone K1 K2 K3 ---------------------------------- (812 123-4567 5 3 2 Petja (812 423-4537 2 4 7
In xslt I transfer as parameter kol-in columns, i.e. I know that this time them will be 3 (January, February and March). But how to write the universal code calculated for any value of this parameter?
Let's admit, columns in resultant , containing in orders on months will be named by a certain rule, for example so: QTY_1, QTY_2, QTY_3., QTY_N. And titles of columns in the total table too: 1, 2, 3..., N. (Where - kol-in columns, i.e. months, i.e. value transferred in xslt parameter).
How correctly to organize a cycle. It can be possible as that in a special way to use a tag colspan?