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 16th, 2009, 03:13 PM
Registered User
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display only unique Nodes

I have a list of XML with assignmentdescriptions that are redundant (Midterm twice), how can I filter them out to only display the unique ones only.

<Data>
<CategoryDescription>Midterm</CategoryDescription>
<CategoryWeight>25.0000</CategoryWeight>
<AssignmentDescription>Midterm</AssignmentDescription>
<StudentWeightedScore>19.200000</StudentWeightedScore>
</Data>
<Data>
<CategoryDescription>Midterm</CategoryDescription>
<CategoryWeight>230.0000</CategoryWeight>
<AssignmentDescription>Midterm</AssignmentDescription>
<StudentWeightedScore>19.200000</StudentWeightedScore>
</Data>
<Data>
<CategoryDescription>Midterm</CategoryDescription>
<CategoryWeight>20.0000</CategoryWeight>
<AssignmentDescription>Homework 1</AssignmentDescription>
<StudentWeightedScore>19.200000</StudentWeightedScore>
</Data>
 
Old July 17th, 2009, 08:41 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

With XSLT 2.0 you can do e.g.
Code:
<xsl:for-each-group select="//Data" group-by="AssignmentDescription">
  <!-- now here the first Data element in each group is the context node 
         so you can do e.g.-->
  <xsl:copy-of select="."/>
  <!-- to output the first Data element in each group or e.g. -->
  <xsl:apply-templates select="."/>
  <!-- to process the first Data element in each group -->
</xsl:for-each-group>
With XSLT 1.0 you would need to use Muenchian grouping: http://www.jenitennison.com/xslt/grouping/muenchian.xml
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I display parent & child nodes if XML .... vishnu108mishra ASP.NET 2.0 Basics 0 November 17th, 2007 07:45 AM
how to display a unique number in a web form abhishek0807 ASP.NET 2.0 Professional 0 March 4th, 2007 02:12 PM
HOW TO: Display specified # of nodes kwilliams XSLT 2 October 5th, 2005 11:04 AM
Display nodes from xml nambati XSLT 2 September 17th, 2004 07:57 AM
How to display all nodes in my Network using VB 6 harini19 VB How-To 1 January 16th, 2004 10:10 AM





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