XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 24th, 2004, 11:53 PM
ve1601 ve1601 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 ve1601 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Simple XPATH question

My XML document looks like :

<resultSet recordCount="259" columnCount="9">
<record>
<column name="DOMAIN">A</column>
</record>
<record>
<column name="DOMAIN">A</column>
</record>
<record>
<column name="DOMAIN">B</column>
</record>
<record>
<column name="DOMAIN">C</column>
</record>
<record>
<column name="DOMAIN">C</column>
</record>
<record>
<column name="DOMAIN">C</column>
</record>
</resultSet>

How should the xslt be coded to group the elements by domain i.e. How do i get something that lists just A, B & C removing all duplicate entries.
One of the forum members had the same problem and his issue was resolved by the following variable declaration and some more code...

<xsl:variable name="groupbyOrderId" select="//ROW[not(@OrderID=preceding-sibling::ROW/@OrderID)]/@OrderID"/>

I was trying to get something very similar to work on my document with no success. I would really appreciate some help on this issue.

Reply With Quote
  #2  
Old July 25th, 2004, 04:25 AM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Have a look at this :

http://www.dpawson.co.uk/xsl/sect2/N6280.html#d8122e139

it looks like it's what you're looking for.

Reply With Quote
  #3  
Old July 27th, 2004, 06:37 PM
ve1601 ve1601 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 ve1601 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This fixes my problem & transforms the result set as a comma delimited string
XSLT:
=====
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="domains" match="record" use="column" />

<xsl:template match="/resultSet">
<html>
<body>
<table border="1">
<xsl:apply-templates
select="record[count(.|key('domains',column)) = count(.)]" />
</table>
</body>
</html>
</xsl:template>

<xsl:template match="record">
<tr>
<td><xsl:value-of select="column" /></td>
<td>
<xsl:for-each
select="key('domains',current()/column)/column">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
</td>
</tr>
</xsl:template>

</xsl:stylesheet>

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Simple XPATH question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT