xsl-list
[Top] [All Lists]

[xsl] Group consecutive elements based on child content

2007-07-20 08:08:05
Hi

In the following structure I need to group consecutive <duration>
elements based on the concatenation of the <price> elements. The added
complication I have is that a price element can contain a number or
hyphen. The hyphen acts like a wildcard in that it can match the price
element in the preceding or following duration. A brief example of my
problem is below.

-------
INPUT
-------
<holidays>
    <duration>
        <nights>7</nights>
        <price>111</price>
        <price>222</price>
        <price>333</price>
        <price>444</price>
        <price>555</price>
    </duration>
    <duration>
        <nights>10</nights>
        <price>-</price>
        <price>222</price>
        <price>333</price>
        <price>444</price>
        <price>555</price>
    </duration>
    <duration>
        <nights>11</nights>
        <price>111</price>
        <price>222</price>
        <price>333</price>
        <price>444</price>
        <price>-</price>
    </duration>
    <duration>
        <nights>14</nights>
        <price>999</price>
        <price>222</price>
        <price>333</price>
        <price>444</price>
        <price>-</price>
    </duration>
    <duration>
        <nights>21</nights>
        <price>999</price>
        <price>456</price>
        <price>-</price>
        <price>123</price>
        <price>456</price>
    </duration>
    <duration>
        <nights>28</nights>
        <price>999</price>
        <price>456</price>
        <price>666</price>
        <price>123</price>
        <price>456</price>
    </duration>
</holidays>

--------------
DESIRED OUTPUT
--------------
<!-- <nights> text content is modified to reflect which durations have
been grouped -->
<holidays>
    <duration>
        <nights>7/10/11</nights>
        <price>111</price>
        <price>222</price>
        <price>333</price>
        <price>444</price>
        <price>555</price>
    </duration>
    <duration>
        <nights>14</nights>
        <price>999</price>
        <price>222</price>
        <price>333</price>
        <price>444</price>
        <price>-</price>
    </duration>
    <duration>
        <nights>21/28</nights>
        <price>999</price>
        <price>456</price>
        <price>666</price>
        <price>123</price>
        <price>456</price>
    </duration>
</holidays

Any help would be appreciated. I am using XSLT 2.0.

Thanks.

--
Kevin

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>