有条件添加新行 xslt
我有以下 XML:
<table class="DETAILGROUP" UID="2001">
<row class="FIGURE">
<cell class="FIGURE">figure</cell>
</row>
<row class="DETAILLINE">
<cell class="CALLOUT">22</cell>
<cell class="SPECIALMATERIAL">Support</cell>
<cell class="PARTNUMBER">SRM</cell>
</row>
<row class="DETAILLINE">
<cell class="CALLOUT">33</cell>
<cell class="SPECIALMATERIAL">Machine</cell>
<cell class="PARTNUMBER"></cell>
</row>
<row class="DETAILLINE">
<cell class="CALLOUT">Support</cell>
<cell class="SPECIALMATERIAL"></cell>
<cell class="PARTNUMBER"></cell>
</row>
</table>
在输出 HTML 中,仅当上述 Table 元素具有任何以“SPECIALMATERIAL”作为其 Class 属性的列时,我才需要隐藏 PARTNUMBER 列;其次,我需要在“figure”标记行之后插入一个新行。在这种情况下,新行应该出现在第二个位置。因此,最终的 HTML 将是这样的 -
<table>
<tr>
<td>
figure
</td>
</tr>
<tr>
<td>
Sr
</td>
<td>
Name
</td>
<td>
Description
</td>
</tr>
<tr>
<td>
22
</td>
<td>
Support
</td>
<td>
SRM
</td>
</tr>
<tr>
<td>
33
</td>
<td>
Machine
</td>
<td>
</td>
</tr>
I have the following XML:
<table class="DETAILGROUP" UID="2001">
<row class="FIGURE">
<cell class="FIGURE">figure</cell>
</row>
<row class="DETAILLINE">
<cell class="CALLOUT">22</cell>
<cell class="SPECIALMATERIAL">Support</cell>
<cell class="PARTNUMBER">SRM</cell>
</row>
<row class="DETAILLINE">
<cell class="CALLOUT">33</cell>
<cell class="SPECIALMATERIAL">Machine</cell>
<cell class="PARTNUMBER"></cell>
</row>
<row class="DETAILLINE">
<cell class="CALLOUT">Support</cell>
<cell class="SPECIALMATERIAL"></cell>
<cell class="PARTNUMBER"></cell>
</row>
</table>
In output HTML I need to hide the PARTNUMBER column, only if the above Table element has any column with "SPECIALMATERIAL" as its Class attribute; Secondly, I need to insert a new row just after the"figure" tag row. In this case new row should come at 2nd position.So, Final HTML will be like this-
<table>
<tr>
<td>
figure
</td>
</tr>
<tr>
<td>
Sr
</td>
<td>
Name
</td>
<td>
Description
</td>
</tr>
<tr>
<td>
22
</td>
<td>
Support
</td>
<td>
SRM
</td>
</tr>
<tr>
<td>
33
</td>
<td>
Machine
</td>
<td>
</td>
</tr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论