有条件地添加新行xslt

时间:2011-04-05 09:05:53

标签: xslt-1.0

我有以下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中,我需要隐藏PARTNUMBER列,仅当上面的Table元素有任何列为“SPECIALMATERIAL”作为其Class属性时;其次,我需要在“figure”标记行之后插入一个新行。在这种情况下,新行应该位于第2位。所以,最终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>

0 个答案:

没有答案