W3C home > Mailing lists > Public > www-forms@w3.org > September 2005

Re: How to group some records by a specific value

From: Swithun Crowe <swithun@swithun.servebeer.com>
Date: Fri, 30 Sep 2005 09:57:43 +0100 (BST)
To: Catherine Poinsignon <catherine.poinsignon@lombard.lu>
cc: www-forms@w3.org
Message-ID: <Pine.LNX.4.61.0509300944460.7409@meshach.swithun.servebeer.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:01 GMT