<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0">
<xsl:output method="text"/>
<xsl:variable name="comma" select="','"/>
<xsl:template match="/">
<xsl:apply-templates select="//Payroll_Data"/>
</xsl:template>
<xsl:template match="Payroll_Data">
<xsl:for-each-group select="Salary" group-by="Type">
<xsl:value-of select="../(EmpId, FirstName, LastName), Type, GrossPay, sum(current-group()/GrossPay)" separator="	"/>
<xsl:text> </xsl:text>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>