XSLT 1.0 grouping to reformat element defined by date into element defined by task

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2010-05-19T06:01:09Z Indexed on 2010/05/19 18:00 UTC
Read the original article Hit count: 354

Filed under:
|
|

Hi folks, I have a tricky XSLT transformation and I'd like your advise My xml is formatted as below:

<Person>
<name>John</name>
<date>June12</date>
<workTime taskID=1>34</workTime>
<workTime taskID=2>12</workTime>
</Person>
<Person>
<name>John</name>
<date>June12</date>
<workTime taskID=1>21</workTime>
<workTime taskID=2>11</workTime>
</Person>

The output xml should be:

<Person>
<name>John</name>
<taskID>1</taskID>
<workTime>
    <date>June12</date>
    <time>34</time>
</worTime>
<workTime>
    <date>June13</date>
    <time>21</time>
</worTime>
</Person>
<Person>
<name>John</name>
<taskID>2</taskID>
<workTime>
    <date>June12</date>
    <time>12</time>
</worTime>
<workTime>
    <date>June13</date>
    <time>11</time>
</worTime>
</Person>

Essentially, as an input, a "Person" object gathers all the task/workTime for a specific date. As an output, I want the "Person" object to gather the date/workTime for a specific task.

I need to use XLST 1.0. I've been trying to use grouping with key but get very puzzled.

Appreciate your help. Daniel

© Stack Overflow or respective owner

Related posts about xslt

Related posts about grouping