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 13th, 2010, 08:45 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default grouping by nodes questions

Hi, I am trying to group some child nodes but having a problem. I want to group all children nodes of <prelreqs> except if the child node name is <safety>. Then I want to process those children as a group.

When I use the below for-each-group construct, I get an error with Saxon 9.1.0.7
Code:
<xsl:for-each-group select="prelreqs" group-by="child::*[not(name(.) = 'safety')]">
    <xsl:sort select="current-grouping-key()"/>
    <xsl:for-each select="current-grouping-key()">
        <!--do something-->
    </xsl:for-each>
</xsl:for-each-group>
error:
Code:
XPTY0004: Required item type of first argument of name() is node(); supplied value has
  item type xs:anyAtomicType
The error is thrown on this line:
Code:
<xsl:for-each select="current-grouping-key()">
Thanks.
 
Old July 13th, 2010, 08:51 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You're not actually 'grouping' there, you are just trying to filter. The following would be easier:

Code:
<xsl:for-each select="preleqs/*[name() != 'safety']">
 ...
</xsl:for-each>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
bonekrusher (July 13th, 2010)
 
Old July 13th, 2010, 08:56 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I don't understand what you want to achieve, current-grouping-key() gives you a single atomic item so what should a for-each select="current-grouping-key()" achieve exactly?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
bonekrusher (July 13th, 2010)
 
Old July 13th, 2010, 09:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I can't relate the error message you're getting to the code you've shown - I would want to see a complete reproducible example. However, as others have pointed out, the code you're written doesn't make much sense.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
bonekrusher (July 13th, 2010)
 
Old July 13th, 2010, 10:58 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

You are all correct. I need to filter rather then sort.

Thanks for the help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Muenchian Grouping on individual nodes in xslt1.0 sudhish.sikhamani XSLT 9 July 1st, 2008 10:32 AM
Get distinct values on *second* grouping of nodes. MissHenesy XSLT 4 October 23rd, 2006 10:34 AM
Grouping orphan nodes to paranet elements ROCXY XSLT 2 January 1st, 2006 07:11 AM
Grouping stand alone nodes inside an element Bala007 XSLT 2 December 30th, 2005 02:25 PM
Grouping Nodes shoei78 XSLT 3 May 28th, 2004 10:34 PM





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