[Logo] Forums for GrailsFlow, Weceem, XSLfast
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Page Grouping  XML
Forum Index » XSLfast Forum
Author Message
Grégoire Rolland



Joined: 31/08/2009 08:02:28
Messages: 3
Offline

Hello,

I have a XML document like this :



I want to do a page grouping by seller-id :

On the first page :

Seller : 1
customer CA
customer DA

On the second page :

Seller : 2
customer BA

I don't know how to do this with XSLFast.

Best Regads,

Grégoire Rolland


This message was edited 1 time. Last update was at 04/09/2009 17:04:02

Victor Krapivin



Joined: 04/06/2009 10:12:44
Messages: 54
Online


I have a XML document like this :

<report>
<customer>
<name>CA</name>
<seller-id>1</seller-id>
</customer>
<customer>
<name>BA</name>
<seller-id>2</seller-id>
</customer>
<customer>
<name>DA</name>
<seller-id>1</seller-id>
</customer>
</report>

I want to do a page grouping by seller-id :

On the first page :

Seller : 1
customer CA
customer DA

On the second page :

Seller : 2
customer BA


This is case of



For case we have unique seller-id, this task is pretty simple. The steps are:


  • Assign grouping customer/seller-id to page.
  • Specify sort clause to '.', numeric, ascending.
  • Place table with data you want to see.
  • Assign grouping to table as 'customer/name', and place all data you need into table, like name itself: '{.}' (without quotes).


But in case you have non-unique seller-id values in XML, the way is the pretty similar, but with initial step: "group by" seller-id's.

How to do this?

First, we need to define xsl:key, as follows:

a) Follow to Layout->Layout settings dialog, "additional templates" tab.
b) Define internal variable here:



This is important step informing XSLfast to group customer nodes by seller-id, and store grouped nodes for future usage.

Once we have grouped nodes, we need to refer to it in groupings. So, we need to use feature in XSLfast named "virtual groupings". It named "virtual" because there are limited selections from real XML node sets by values.

The simplest case of this grouping is



it uses customer name related to specific seller-id.

Note:


  • To make these virtual groupings, you need to use 2nd tab at grouping dialog, named "filtering". At the left, you see tree with nodes and you can drag and drop values from it as usual. At the top, check box and "copy from" edit box let you specify from which node you planning to start make virtual grouping. It will add sub-nodes and attributes to it once you pressed "add" button for drag and drop in future with correct XPath substitution. If you don't need this, you can turn off check box here.
  • At the middle, you see expression box; here you need type expression to filtering. By pressing "evaluate" button at he bottom you'll see the results of filtering immediately. The rest of buttons let you add, modify or delete virtual groupings by selecting it at left tree and pressing buttons.


Above, we used groupings customer/seller-id and customer/name respectively. Now, instead of these simple expressions, we need to use bit more complex ones:



and



respectively. The expression customer[generate-id(.)=generate-id(key('customer-key',seller-id))]/seller-id describes we need only unique values of seller-id for this grouping. Typically it is page grouping. And the expression customer[seller-id=current()]/name' specifies we're using names related to specific seller-id at the page scope.

Except additional step and bit more complex expressions, the basic idea is the same as for unique seller-id values in XML: two groupings for page and for table respectively, and sort expression of page grouping. Of course you can use two tables instead, where one table is placed inside of other table, with the same approach.

This message was edited 3 times. Last update was at 04/09/2009 17:06:05


Best regards,
Victor Krapivin
[WWW]
 
Forum Index » XSLfast Forum
Go to:   
Powered by JForum 2.1.8 © JForum Team