1

I am having an 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>

Which should be converted to:

    <?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>

The requirement is when there is any @rowspan element, that should convert as something like <row-span-anchor/> in the corresponding place in the converted XML.

Can this be achieved using XSLT2?

Note: if td[@rowspan > 1] then, <row-span-anchor/> should be placed on next row's corresponding td (or successive rows). For example: /table/tr[1]/td[2] have @rowspan=3, then <row-span-anchor/> should be placed after /table/tr[2]/td[1] and /table/tr[3]/td[1]. In first row -fourth, seventh, eighth and tenth column (td) have @rowspan=2, hence in second row (/table/tr[2]) <row-span-anchor/> is placed.

Jagath
  • 328
  • 5
  • 19
  • 3
    I maybe low on IQ, but looking at the source and target XML files, I am unable to find a correlation. Could you please elaborate a bit more? Although all `` elements have a `rowspan` attribute, yet you have inserted `` elements randomly. – Madeyedexter Feb 03 '17 at 05:45
  • @Madeyedexter: Sorry that was an error. Now corrected. Please check if this is reasonable? – Jagath Feb 03 '17 at 06:24
  • you add ``, but when do you exactly want it to be added? Every `` element has a `rowspan` attribute, so according to your question, every `` element must have a corresponding ` – Madeyedexter Feb 03 '17 at 06:28
  • @Madeyedexter: I have added a note at the end of the question. Is that OK? – Jagath Feb 03 '17 at 06:39
  • See if this helps: http://stackoverflow.com/a/27217608/3016153 – michael.hor257k Feb 03 '17 at 06:50
  • @michael.hor257k: How can I place the ``? – Jagath Feb 03 '17 at 08:54

0 Answers0