我有一个XML:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<tr>
<td rowspan="1">0</td>
<td rowspan="3">1</td>
<td rowspan="1">2</td>
<td rowspan="2">3</td>
<td rowspan="1">4</td>
<td rowspan="1">5</td>
<td rowspan="2">6</td>
<td rowspan="2">7</td>
<td rowspan="1">8</td>
<td rowspan="2">9</td>
</tr>
<tr>
<td rowspan="1">10</td>
<td rowspan="1">11</td>
<td rowspan="1">12</td>
<td rowspan="1">13</td>
<td rowspan="1">14</td>
</tr>
<tr>
<td rowspan="1">15</td>
<td rowspan="1">16</td>
<td rowspan="1">17</td>
<td rowspan="1">18</td>
<td rowspan="1">19</td>
<td rowspan="1">20</td>
<td rowspan="1">21</td>
<td rowspan="1">22</td>
<td rowspan="1">23</td>
</tr>
</table>
哪个应转换为:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<tr>
<td rowspan="1">0</td>
<td rowspan="3">1</td>
<td rowspan="1">2</td>
<td rowspan="2">3</td>
<td rowspan="1">4</td>
<td rowspan="1">5</td>
<td rowspan="2">6</td>
<td rowspan="2">7</td>
<td rowspan="1">8</td>
<td rowspan="2">9</td>
</tr>
<tr>
<td rowspan="1">10</td>
<row-span-anchor/>
<td rowspan="1">11</td>
<row-span-anchor/>
<td rowspan="1">12</td>
<td rowspan="1">13</td>
<row-span-anchor/>
<row-span-anchor/>
<td rowspan="1">14</td>
<row-span-anchor/>
</tr>
<tr>
<td rowspan="1">15</td>
<row-span-anchor/>
<td rowspan="1">16</td>
<td rowspan="1">17</td>
<td rowspan="1">18</td>
<td rowspan="1">19</td>
<td rowspan="1">20</td>
<td rowspan="1">21</td>
<td rowspan="1">22</td>
<td rowspan="1">23</td>
</tr>
</table>
要求是有任何@rowspan
元素,应该在转换后的XML中的相应位置转换为类似<row-span-anchor/>
的内容。
可以使用XSLT2实现吗?
注意:如果td[@rowspan > 1]
,则<row-span-anchor/>
应放在下一行的td
(或连续的行)上。例如:/table/tr[1]/td[2]
有@rowspan=3
,然后<row-span-anchor/>
应放在/table/tr[2]/td[1]
和/table/tr[3]/td[1]
之后。在第一行 - 第四,第七,第八和第十列(td
)中有@rowspan=2
,因此在第二行(/table/tr[2]
)<row-span-anchor/>
被放置。