Skip to main content

XSL to select the group of rows based on the three XML fields and condition

1 reply [Last post]
Anonymous

I would like to group based on fields of row element (combination of StackNumber,BlockNumber and LocationCode) and select only higher BookVersion (BookVersion) based rows in particular group(combination of StackNumber,BlockNumber and LocationCode) and also to select the rows of DeliveryMode with the value as TRANSIT.

Here is the input document

<?xml version="1.0"?>

19
61001
TRANSIT
MON
03
1010

20
61001
TRANSIT
MON
01
1011

20
61001
TRANSIT
MON
02
1013

21
61001
RECVD
MON
03
1022

21
61001
TRANSIT
MON
03
1022

22
15098
TRANSIT
MON
01
1010

22
22456
TRANSIT
MON
02
1011

22
22456
TRANSIT
MON
03
1012

22
22456
RECVD
MON
02
1021

XSL (using saxon 9 parser) that I wrote:

I wrote this above one but can't figure out to select correct store number based on greater value based element 'BookVersion' in each group.

example group must be printed like this .

20
61001
MON
1013
02

I'm getting wrong store number here for a particular selected group. I'm struck to proceed further here, I will appreciate if some body can lead me the way to write correct it in this XSL.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ccpuser
Offline
Joined: 2010-10-21

XSL V 1.0 based solution:








































2) Version 2.0 Based solution:


xmlns:xsd="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xsd"
version="2.0">



group-by="concat(StackNumber,' ',
BlockNumber,' ',LocationCode)">