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

Re: How to group some records by a specific value

From: Catherine Poinsignon <catherine.poinsignon@lombard.lu>
Date: Fri, 30 Sep 2005 11:20:38 +0200
Message-Id: <s33d1ffd.091@lombard.lu>
To: <swithun@swithun.servebeer.com>
Cc: <www-forms@w3.org>
Hello,
Thank you very much : it works !
I have not found the "following-sibling" in the xForms specification, but it works...
Thanks a lot.
Regards,
 
Catherine

>>> Swithun Crowe <swithun@swithun.servebeer.com> 30/09/2005 10:57:43 >>>


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 09:22:39 GMT

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