Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  XML Lab Products  eXml Web Server Control  eXml group-by i...
 eXml group-by is not a valid extention element
 
godfather96
3 posts
Joined
6/4/2007

eXml group-by is not a valid extention element
Posted: 04 Jun 07 9:18 AM (Canada)

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>

            </tr>

 

            <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>

                <td>

                  <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>

 

 

 

 

olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: eXml group-by is not a valid extention element
Posted: 04 Jun 07 11:43 PM (Israel)
Sorry, but eXml control doesn't support XSLT 2.0. You'll have to use XSLT 1.0 grouping. See http://www.jenitennison.com/xslt/grouping/ for XSLT 1.0 grouping samples.
Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
godfather96
3 posts
Joined
6/4/2007

Re: eXml group-by is not a valid extention element
Posted: 05 Jun 07 6:47 AM (Canada)

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       20
Keyword 1       10
Keyword 2       15

Kiosk 2

Keyword 1      15
Keyword  1       10

The Grouping should be:

Kiosk 1

Keyword 1      30
Keyword 2       15

Kiosk 2

Keyword 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>

 

 

              </xsl:for-each>
            </xsl:for-each>
          </table>
        </div>
   

  </xsl:template>
</xsl:stylesheet>

olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: eXml group-by is not a valid extention element
Posted: 06 Jun 07 1:25 PM (N/A)
You need two-level grouping, looks like you want to group Klog elements within KioskID, not globally every Kog.

Try composite key then:

<xsl:key name="distinct-keywords" match="Klog" use="concat(../@KioskID, ':', @Keyword)"></xsl:key>

and then:

<xsl:for-each select="Klog[generate-id(.)=generate-id(key('distinct-keywords',concat(../@KioskID, ':', @Keyword))[1])]">


Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
godfather96
3 posts
Joined
6/4/2007

Re: eXml group-by is not a valid extention element
Posted: 09 Jun 07 6:00 PM (Canada)
Thanks, Worked like a charm
  XML Lab Products  eXml Web Server Control  eXml group-by i...
Forum Home  Search