transpose/swap x,y axes in html table
I have an html table that needs rotating / axis swaping. It can be done off line. Any one know of a tool I can use t开发者_JAVA百科o do it?
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="table">
<xsl:for-each select="tr[1]/td">
<xsl:variable name="vRowPos" select="position()"/>
<tr>
<xsl:for-each select="/table/tr">
<xsl:variable name="vColPos" select="position()"/>
<xsl:copy-of select="/table/tr[$vColPos]/td[$vRowPos]"/>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
when applied on this XML document:
<table>
<tr>
<td>A11</td>
<td>A12</td>
<td>A13</td>
<td>A14</td>
<td>A15</td>
</tr>
<tr>
<td>A21</td>
<td>A22</td>
<td>A23</td>
<td>A24</td>
<td>A25</td>
</tr>
<tr>
<td>A31</td>
<td>A32</td>
<td>A33</td>
<td>A34</td>
<td>A35</td>
</tr>
</table>
produces the wanted, correct results:
<table>
<tr>
<td>A11</td>
<td>A21</td>
<td>A31</td>
</tr>
<tr>
<td>A12</td>
<td>A22</td>
<td>A32</td>
</tr>
<tr>
<td>A13</td>
<td>A23</td>
<td>A33</td>
</tr>
<tr>
<td>A14</td>
<td>A24</td>
<td>A34</td>
</tr>
<tr>
<td>A15</td>
<td>A25</td>
<td>A35</td>
</tr>
</table>
Do note: The assumption is that the table has regular structure.
精彩评论