xsl-list
[Top] [All Lists]

[xsl] unusual grouping problem

2007-09-16 13:57:48
I have what I hope is an interesting grouping problem. I?ve tried
<for-each-group>, Meunchian technique, and some crazy home-made <for-each>
loops but can?t 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 I?ve 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>



I?d like to do something like :
<xsl:for-each-group select="/patient/lab " group-adjacent="every $lab in
current-group() satisfies $lab/@type!=(_at_)type">

but you can?t 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=(_at_)type">

But that identifies duplicates starting from the first lab in the entire
list, not just within the group currently being created.


I?ve also tried some more convoluted and desperate ideas but I?ll save you
those details.

Any help is much appreciated.

Thanks.









--~------------------------------------------------------------------
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>