XSL Template
How To Group data in XSL
Requirement is to list employee's birthday per below
Date Of Birth|<List of all employee number in seperated by comma>
Date Of Birth|<List of all employee number in seperated by comma>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/comon"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
extension-element-prefixes="exsl xs">
<xsl:output omit-xml-declaration="yes" indent="yes" method="text"/>
<xsl:strip-space elements="*"/>
<xsl:variable name ="newline" select = "' '"/>
<xsl:template match="/">
<xsl:apply-templates select="DATA_DS"/>
</xsl:template>
<xsl:template match="DATA_DS">
<xsl:text>DOB,PERSON NUMBER</xsl:text>
<xsl:value-of select="$newline"/>
<xsl:for-each-group select="//G_1" group-by="LF_EVT_OCRD_DT">
<xsl:variable name="LINE">
<xsl:value-of select="current-grouping-key()"/>
<xsl:text>|</xsl:text>
<xsl:for-each select="current-group()">
<xsl:value-of select="PERSON_NUMBER"></xsl:value-of>
<xsl:if test="not(position() = last())">,</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$LINE"/>
<xsl:value-of select="$newline"/>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
Comments
Post a Comment