Re: How to group some records by a specific value

Hello
If your data is sorted, as it is below, then it is probably not too
difficult with a nested repeat along the lines of:

<xf:repeat
nodeset="instance('mydata')/record[not(type=following-sibling::record/type)]">
  <xf:output ref="type"/>
  <xf:repeat
nodeset="instance('mydata')/record[type=current()/type]/name">
    <xf:output ref="."/>
  </xf:repeat>
</xf:repeat>

The first repeat finds all the records where the type element is not the
same as the following record. Then the second repeat uses the value of
type to find all names in records which have this type.

It only works when the records are grouped by type, otherwise you will get
the same type being used several times.

Something like this should work.

Swithun.

On Fri, 30 Sep 2005, Catherine Poinsignon wrote:

> Hi all,
>
> I have some instance data that looks like this for input of an xforms:
> <xforms:instance id="mydata">
> <data>    <record><name>name1</name><type>A</type></record>
<record><name>name2</name><type>A</type></record>
<record><name>name3</name><type>A</type></record>
<record><name>name4</name><type>B</type></record>
<record><name>name5</name><type>B</type></record>
<record><name>name6</name><type>C</type></record>
<record><name>name7</name><type>C</type></record></data></xforms:instance>
I would like to obtain a result like :Type A            name1
name2            name3Type B            name4            name5Type C
name6            name7 I think it is possible using a repeat, but I don't
know how.Could you please help me ? Tanks in advance, Catherine>
>

Received on Friday, 30 September 2005 08:57:49 UTC