posted 8 years ago
This is generally under the category of grouping problem. On all generality and for bigger data set, in xslt 1.0, you can look into the use of xsl:key. But don't worry, it is doable without, without sacrificing efficiency for a smaller data set.
First observation is the construction of ListOfPaySlipData is kind of constant for type 'yes' or 'y', so you put the construction in a named template, say 'process' hereinbelow. Then second observation is that PaySlip_Val and ListOfPaySlipMonth are to appear only once. The ListOfPaySlipMonth structure is more involved that is why a call to a named template is necessary for an orderly template scripting. In any case, they appear at the first occurrence of Type 'yes' or 'y'. This is now determined by simply counting of preceding-sibling of the similar kind of Type.
This is how.