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 to do it?
我有一个需要旋转/轴交换的html表。它可以脱机完成。有谁知道我可以使用的工具吗?
1 个解决方案
#1
8
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:
应用于此XML文档时:
<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.
请注意:假设表格具有规则结构。
#1
8
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:
应用于此XML文档时:
<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.
请注意:假设表格具有规则结构。