Can anyone help me with this problem. I am trying to use exml web control to transform an xml file and I receive the following error
'group-by' is not a recognized extension element. An error occurred at ....
here is my code
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" extension-element-prefixes="xsl"> <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"> <div> <table width="100%" cellpadding="4" cellspacing="4" border="0"> <tr valign="top" align="left"> <th colspan="3">Stats Report</th>
</tr> <xsl:for-each select="doc/StatsReport/Store"> <tr valign="top" align="left"> <td> Store: <xsl:value-of select="@Number"/> </td> <td></td> <td></td> </tr>
<xsl:for-each select="KioskID">
<tr valign="top" align="left"> <td colspan="3"> KioskID: <xsl:value-of select="@KioskID"/> </td>
</tr> <tr> <td colspan="3"> <hr></hr> </td>
</tr>
<tr valign="top" align="left"> <td> <h6>Keyword </h6> </td> <td> <h6>Count</h6> </td>
<xsl:for-each-group select="Klog" group-by="@Keyword">
<tr>
<td>
<xsl:value-of select="current-grouping-key()"/> </td> <td> <xsl:value-of select="sum(current-group()/@Count)"/> </td> </tr> </xsl:for-each-group> <xsl:for-each select="Keyword"> <tr>
<xsl:value-of select="@Name"/> </td> <td> <xsl:value-of select="@NoCount"/> </td> </tr> </xsl:for-each>
</xsl:for-each> </xsl:for-each> </table> </div>
</xsl:template></xsl:stylesheet>
XML FILE
<?xml version="1.0"?><doc><ReportName>Report2</ReportName><StartDate>Apr 4 2007 12:00AM</StartDate><EndDate>Jun 1 2007 11:59PM</EndDate><StatsReport><Store Number="123"><KioskID KioskID="STCSW1"><Klog Keyword="Keyword1" SubKeyword="" Count="77"/><Klog Keyword="Keyword2" SubKeyword="Name First" Count="4"/><Klog Keyword="Keyword2" SubKeyword="OrderForm" Count="1"/></KioskID></Store></StatsReport>
</doc>
Thank you for that link here is what I have so far for grouping in xslt 1.0 but there is one problem :
The ouput of this groups only for one "KioskID", so if I have;Kiosk 1
Keyword 1 20Keyword 1 10Keyword 2 15Kiosk 2 Keyword 1 15Keyword 1 10
The Grouping should be:
Kiosk 1Keyword 1 30Keyword 2 15Kiosk 2Keyword 1 25
But I am getting the correct result for Kiosk 1 and nothing for Kiosk 2 could you help me with this? do I need another key?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="distinct-keywords" match="Klog" use="@Keyword"></xsl:key> <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <xsl:template match="/"> <div> <table width="100%" cellpadding="4" cellspacing="4" border="0"> <tr valign="top" align="left"> <th colspan="3">Stats Report</th>
</tr> <xsl:for-each select="doc/StatsReport/Store"> <tr valign="top" align="left"> <td> Store: <xsl:value-of select="@Number"/> </td> <td></td> <td></td> </tr> <xsl:for-each select="KioskID"> <tr valign="top" align="left"> <td colspan="3"> KioskID: <xsl:value-of select="@KioskID"/> </td> </tr> <tr> <td colspan="3"> <hr></hr> </td>
</tr> <tr valign="top" align="left"> <td> <h6>Keyword </h6> </td> <td> <h6>Count</h6> </td> </tr>
<xsl:for-each select="Klog[generate-id(.)=generate-id(key('distinct-keywords',@Keyword)[1])]"> <tr valign="top" align="left" > <td> <xsl:value-of select="@Keyword"/> </td> <td> <xsl:value-of select="sum(../Klog[current()/@Keyword=./@Keyword]//@Count)"/> </td> </tr> </xsl:for-each> <xsl:for-each select="Keyword"> <tr> <td> <xsl:value-of select="@Name"/> </td> <td> <xsl:value-of select="@NoCount"/> </td> </tr> </xsl:for-each>