Altova Mailing List Archives
>xsl-list Archive Home
>Recent entries
>Thread Prev - [xsl] Grouping adjacent elements by value - within a range
>Thread Next - RE: [xsl] Grouping adjacent elements by value - within a range
Re: [xsl] Grouping adjacent elements by value - within a range
To: xsl-list@-----.------------.---
Date: 8/13/2010 11:53:00 AM
It's not clear to me whether a period goes in the same group as the previous element if (a) its price is within £20 of the price of the previous period, or (b) its price is within £20 of the price of the first period in the group, or (c) its price is within £20 of every other period within the group. Assuming (c) which seems the most plausible, I think you need to do this by sibling recursion rather than by xsl:for-each-group. Here's an example of the idea, there are plenty of others you can find by googling: http://internal.rhaptos.org/devblog/cbearden/2009.07.12-2010 The difference is how to test whether the next item belongs in the same group: typically you'll pass along parameters containing the minimum and maximum price of items in the group, and either add the next item to the group or start a new group depending how the price of the next item compares with these two values. Michael Kay Saxonica On 13/08/2010 10:35, Kevin Bird wrote: > Hello > > I typeset price tables for Tour Operators brochures. Due to design changes, the space left to display price information has been reduced. I need to group adjacent<price> elements that are within a certain range (the range would be passed as a parameter). Once the price groupings are worked out, I then need to modify the corresponding<period> elements. > > The example below shows adjacent price elements grouped that are within a range of £20 (with the lowest price returned). Using the same groupings, the<period> elements are modified by taking the first<startdate> and last<enddate>. > > I can use XSLT 2.0. > > > ========================= > SOURCE XML > ========================= > > <?xml version="1.0" encoding="UTF-8"?> > <grid> > <row id="periods"> > <period> > <startdate>01-Sep-2010</startdate> > <enddate>19-Sep-2010</enddate> > </period> > <period> > <startdate>20-Sep-2010</startdate> > <enddate>25-Sep-2010</enddate> > </period> > <period> > <startdate>26-Sep-2010</startdate> > <enddate>30-Sep-2010</enddate> > </period> > <period> > <startdate>01-Oct-2010</startdate> > <enddate>11-Oct-2010</enddate> > </period> > <period> > <startdate>12-Oct-2010</startdate> > <enddate>31-Oct-2010</enddate> > </period> > </row> > <row id="prices"> > <price>1209</price> > <price>1109</price> > <price>1129</price> > <price>1359</price> > <price>1369</price> > </row> > </grid> > > > ========================= > RESULT XML > ========================= > > <?xml version="1.0" encoding="UTF-8"?> > <grid> > <row id="periods"> > <period> > <startdate>01-Sep-2010</startdate> > <enddate>19-Sep-2010</enddate> > </period> > <period> > <startdate>20-Sep-2010</startdate> > <enddate>30-Sep-2010</enddate> > </period> > <period> > <startdate>01-Oct-2010</startdate> > <enddate>31-Oct-2010</enddate> > </period> > </row> > <row id="prices"> > <price>1209</price> > <price>1109</price> > <price>1359</price> > </row> > </grid> > > > Any help 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@l...> > --~-- > > > --~------------------------------------------------------------------ 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@l...> --~--
Disclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

