cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Kavanagh <...@dotech.com>
Subject GroupingTransformer
Date Fri, 18 Apr 2003 17:52:01 GMT
I've been on the cocoon-user list for a while, but had this transformer 
I wanted to submit.

I'm not sure if anyone has written something like the before, but here 
goes...

This tranformer will group sets of elements in an XML stream. A simple 
example is like this.

If you have this data set, and tell the transformer to group the <Y> 
elements by 2...
<X>
    <Y>
    <Y>
    <Y>
    <Y>
    <Y>
<X>

becomes,
<X>
    <Group>
      <Y>
      <Y>
    </Group>
    <Group>
      <Y>
      <Y>
    </Group>
    <Group>
      <Y>
    </Group>
<X>

You can also tell it to supply an index to the Group element.

This is an example sitemap;
<map:transform type="grouping">
    <map:parameter name="namespaceURI" 
value="http://www.dotech.com/cocoon/spreadsheet/1.0"/>
    <map:parameter name="groupedElementName" value="Row"/>
    <map:parameter name="groupedTagName" value="Group"/>
    <map:parameter name="groupSize" value="10"/>
    <map:parameter name="indexStart" value="1"/>
</map:transform>

The indexStart is optional. The javadoc in the source I've attached 
describes this also.

I've found this usefull when I wanted to  group some data before turning 
into SQL inserts (for inserting groups of data). I can see that it would 
also be useful to process the result of a query to generate page 
boundaries.

Feel free to comment on this, or just take it and commit it.

David

Mime
View raw message