|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] [XSLT2] Some common, generic grouping problems
Hello, does anyone know of a comprehensive summary of ideas on how to tackle many of the common grouping problems (URL, post, book)? When it comes to grouping, I'm always lacking the smart ideas and concise code you members of this list come up with. For some of the grouping scenarios I managed to find generic solutions (either on this list or in the spec itself), but for some I'm still at a loss. I've collected a few examples below: __Notes__ <arbitrary/> stands for one or many arbitrary elements in sequence. There might be many different ones, even ones not known to the transformation author in advance. I'm thinking of grouping problems in terms of grouping likewise colored nodes. Colors may have different brightnesses to give them special meaning. I'm using the following: dark-<color> the first element in a group to be created <color> an element in a group to be created light-<color> the last element in a group to be created <color> a variety of colors identifying elements going into the same group based in the same (basic) color. The color "none" or no color attribute at all specifies an unknown color (e.g. because it never was explicitly set) __Example XML #1__ <root> <arbitrary /> <elem color="dark-red" /> <elem color="red" /> <arbitrary color="none" /> <elem color="red" /> <elem color="light-red" /> <arbitrary /> </root> The task is to group all elements between pairs of 'dark-red' colored and 'light-red' colored elements, i.e.: <root> <arbitrary /> <red> <elem color="dark-red" /> <elem color="red" /> <arbitrary color="none" /> <elem color="red" /> <elem color="light-red" /> </red> <arbitrary /> </root> __Example XML #2__ <root> <arbitrary /> <elem color="dark-red" /> <elem color="red" /> <arbitrary /> <elem color="red" /> <arbitrary /> <elem color="dark-red" /> <elem color="red" /> <arbitrary /> <elem color="red" /> <arbitrary /> </root> The task is to group all elements starting at 'dark-red' up to the last red element before the subsequent 'dark-red' element, i.e.: <root> <arbitrary /> <red> <elem color="dark-red" /> <elem color="red" /> <arbitrary /> <elem color="red" /> </red> <arbitrary /> <red> <elem color="dark-red" /> <elem color="red" /> <arbitrary /> <elem color="red" /> </red> <arbitrary /> </root> __Example XML #3__ <root> <arbitrary /> <elem color="red" /> <elem color="red" /> <elem color="dark-red" /> <elem color="red" /> <arbitrary /> <elem color="red" /> <elem color="dark-red" /> <arbitrary /> </root> The task is to group by adjacent color, but force starting a new group when the color is dark, i.e.: <root> <arbitrary /> <red> <elem color="red" /> <elem color="red" /> </red> <red> <elem color="dark-red" /> <elem color="red" /> </red> <arbitrary /> <red> <elem color="red" /> </red> <red> <elem color="dark-red" /> </red> <arbitrary /> </root> I guess one of the main difficulties I'm struggling with currently are the <arbitrary /> elements. Should I try to "color" them before starting the grouping? How would this best be done in example #2? Or is trying to add the "missing" colors the wrong approach? -Christian
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






