I'm trying to set attributes dynamically, but I can't do it at all. Could you help me? Desirable example :)
Input:
<root>
<row>
<col>v11</col>
<col>v12</col>
<col>v13</col>
<col>v14</col>
</row>
<row>
<col>v21</col>
<col>v22</col>
<col>v23</col>
<col>v24</col>
</row>
</root>
Current XSLT Scheme:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="root">
<root>
<xsl:apply-templates select="row"/>
</root>
</xsl:template>
<xsl:template match="col">
<data col="1" row="1">
<xsl:value-of select="."/>
</data>
</xsl:template>
<xsl:template match="row">
<xsl:apply-templates select="col"/>
</xsl:template>
</xsl:stylesheet>
Current output:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<data col="1" row="1">v11</data>
<data col="1" row="1">v12</data>
<data col="1" row="1">v13</data>
<data col="1" row="1">v14</data>
<data col="1" row="1">v21</data>
<data col="1" row="1">v22</data>
<data col="1" row="1">v23</data>
<data col="1" row="1">v24</data>
</root>
How can I dynamically assign attribute values?
I need to make it so:
<root>
<data row="1" col="1">v11</data>
<data row="1" col="2">v12</data>
<data row="1" col="3">v13</data>
<data row="1" col="4">v14</data>
<data row="2" col="1">v21</data>
<data row="2" col="2">v22</data>
<data row="2" col="3">v23</data>
<data row="2" col="4">v24</data>
</root>
Thanks!