Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2010, 09:45 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you run the code with IE then MSXML is used as the XSLT processor and that would simply throw an error on exsl:node-set I think, unless you fix it with an msxsl: script as follows:
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  exclude-result-prefixes="exsl msxsl"
  version="1.0">
  
  <xsl:output method="html" indent="yes"/>
  
  <msxsl:script language="JScript" implements-prefix="exsl">
  this['node-set'] = function(node) { return node; }
  </msxsl:script>
  
  <xsl:key name="k1" match="Item" use="Account"/>
  
  <xsl:template match="Items">
    <table>
      <thead>
        <tr>
          <th>Account</th>
          <th>currentConsumption</th>
          <th>Previous Consumption</th>
          <th>percent Change</th>
          <th>Rank</th>
        </tr>
      </thead>
      <tbody>
        <xsl:variable name="latest">
          <xsl:for-each select="Item[generate-id() = generate-id(key('k1', Account)[1])]">
            <xsl:for-each select="key('k1', Account)">
              <xsl:sort select="substring-after(substring-after(BillDate, '/'), '/')" data-type="number" order="descending"/>
              <xsl:sort select="substring-before(BillDate, '/')" data-type="number" order="descending"/>
              <xsl:sort select="substring-before(substring-after(BillDate, '/'), '/')" data-type="number" order="descending"/>
              <xsl:if test="position() = 1">
                <xsl:copy-of select="."/>
              </xsl:if>
            </xsl:for-each>
          </xsl:for-each>
        </xsl:variable>
        <xsl:for-each select="exsl:node-set($latest)/Item">
          <xsl:sort select="PercentChange" data-type="number" order="ascending"/>
          <tr>
            <xsl:apply-templates select="Account | currentConsumption | PreviousMonthConsumption | PercentChange"/>
            <td><xsl:value-of select="position()"/></td>
          </tr>
        </xsl:for-each>
      </tbody>
    </table>
  </xsl:template>
  
  <xsl:template match="Item/*">
    <td><xsl:value-of select="."/></td>
  </xsl:template>

</xsl:stylesheet>
When I do that I have no problems here with IE (IE 8) to run the transformation.

Why you would get that strange output I have no idea but I am not sure I understand what you are doing exactly as you provided some HTML markup result code which is rather difficult to get at when the transformation is run directly in the browser.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting problem (Paging) pat123 XSLT 9 January 30th, 2007 01:00 PM
Sorting problem kuku SQL Server 2000 2 November 7th, 2005 03:36 PM
Large Text Sorting Problem shellhb ASP.NET 1.0 and 1.1 Basics 0 October 27th, 2005 02:46 PM
Sorting Problem whiterainbow BOOK: Access 2003 VBA Programmer's Reference 4 June 6th, 2005 12:59 AM
Difficult sorting problem sunjammer XSLT 0 July 1st, 2003 11:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.