Subject: [xsl] unusual grouping problem From: russ@xxxxxxxxxxx Date: Sun, 16 Sep 2007 13:57:28 -0700 (PDT) |
I have what I hope is an interesting grouping problem. Ive tried <for-each-group>, Meunchian technique, and some crazy home-made <for-each> loops but cant come up with anything that works. Source xml is: <patient> <lab type="1" /> <lab type="2" /> <lab type="3" /> <lab type="1" /> <lab type="3" /> <lab type="1" /> <lab type="1" /> <lab type="2" /> <lab type="3" /> <lab type="3" /> <lab type="1" /> <patient> The labs are sorted by a timestamp that Ive left out for clarity, and need to remain in that same order. I need the labs broken into the fewest number of groups possible without any group containing the same lab type more than once. So the above should produce: <patient> <group> <lab type="1" /> <lab type="2" /> <lab type="3" /> </group> <group> <lab type="1" /> <lab type="3" > </group> <group> <lab type="1" /> </group> <group> <lab type="1" /> <lab type="2" /> <lab type="3" /> </group> <group> <lab type="3"/> <lab type="1"/> </group> </patient> Id like to do something like : <xsl:for-each-group select="/patient/lab " group-adjacent="every $lab in current-group() satisfies $lab/@type!=@type"> but you cant access current-group() from the grouping criteria. I need something like a members-of-the-group-currently-being-created()" function. I also tried: <xsl:for-each-group select="/patient/lab " group-ending-with="some $lab in preceding-sibling::lab satisfies $lab/@type=@type"> But that identifies duplicates starting from the first lab in the entire list, not just within the group currently being created. Ive also tried some more convoluted and desperate ideas but Ill save you those details. Any help is much appreciated. Thanks.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] passing xml strings to xs, Michael Kay | Thread | RE: [xsl] unusual grouping problem, Michael Kay |
[xsl] Client-side compiled XSLT/DOM, M. David Peterson | Date | RE: [xsl] unusual grouping problem, Michael Kay |
Month |