xsl-list
[Top] [All Lists]

Extracting highest values between 'found' positions

2004-11-18 11:23:47
Hi

I have the following XML structure:

<panel>
        <rowdates>
                <date id="1">
                        <start>051005</start>
                        <end>051006</end>
                </date>
                <date id="2">
                        <start>051007</start>
                        <end>051115</end>
                </date>
                <date id="3">
                        <start>051116</start>
                        <end>051201</end>
                </date>
                <date id="4">
                        <start>051202</start>
                        <end>051231</end>
                </date>
                <date id="5">
                        <start>060101</start>
                        <end>060120</end>
                </date>
                <date id="6">
                        <start>060121</start>
                        <end>060131</end>
                </date>
        </rowdates>
        <property>
                <accommodation person="adult">
                        <holidays>
                                <nights>7</nights>
                                <price>269</price>
                                <price>289</price>
                                <price>309</price>
                                <price>359</price>
                                <price>319</price>
                                <price>329</price>
                        </holidays>
                        <holidays>
                                <nights>14</nights>
                                <price>304</price>
                                <price>374</price>
                                <price>-</price>
                                <price>-</price>
                                <price>-</price>
                                <price>-</price>
                        </holidays>
                </accommodation>
        </property>
        <property>
                <accommodation person="adult">
                        <holidays>
                                <nights>7</nights>
                                <price>669</price>
                                <price>789</price>
                                <price>809</price>
                                <price>959</price>
                                <price>3299</price>
                                <price>2929</price>
                        </holidays>
                        <holidays>
                                <nights>14</nights>
                                <price>3104</price>
                                <price>7374</price>
                                <price>999</price>
                                <price>-</price>
                                <price>99</price>
                                <price>129</price>
                        </holidays>
                </accommodation>
        </property>
</panel>

I need to match <date> elements within <rowdates> (which would be held
as parameters within the stylesheet), find their positions, then extract
the highest <price> element within those positions.

E.g..   Parameter1 '051005' matches the <start> child of <date id="1">
        Parameter2 '051201' matches the <end> child of <date id="3">
        So I need to compare <price> elements 1-3

        Parameter3 '060101' matches the <start> child of <date id="5">
        Parameter4 '060131' matches the <end> child of <date id="6">
        So I need to compare <price> elements 5-6

        .. and so on.

        Note that position 4 is unmatched and passes through 'as is'.

The result would look like:

<panel>
        <rowdates>
                <date id="1">
                        <start>051005</start>
                        <end>051201</end>
                </date>
                <date id="2">
                        <start>051202</start>
                        <end>051231</end>
                </date>
                <date id="3">
                        <start>060101</start>
                        <end>060131</end>
                </date>
        </rowdates>
        <property>
                <accommodation person="adult">
                        <holidays>
                                <nights>7</nights>
                                <price>309</price>
                                <price>359</price>
                                <price>329</price>
                        </holidays>
                        <holidays>
                                <nights>14</nights>
                                <price>374</price>
                                <price>-</price>
                                <price>-</price>
                        </holidays>
                </accommodation>
        </property>
        <property>
                <accommodation person="adult">
                        <holidays>
                                <nights>7</nights>
                                <price>809</price>
                                <price>959</price>
                                <price>3299</price>
                        </holidays>
                        <holidays>
                                <nights>14</nights>
                                <price>7374</price>
                                <price>-</price>
                                <price>129</price>
                        </holidays>
                </accommodation>
        </property>
</panel>

The added complication is that some of the input files may match some,
but not all the dates being searched. How do I cope with that?

Any suggestions greatly appreciated.

--
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>
  • Extracting highest values between 'found' positions, Kevin Bird <=