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

Reply
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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 4th, 2008, 04:59 AM
waxdart waxdart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 waxdart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 30 sec
Reputation Power: 0
Muenchian Grouping with in a Muenchian Group ???

I've not idea if this is possible. I have a big flat xml file which I cannot change. So I'm hoping XSLT will help.

I found a url jenitennison dot com which has got me part of the way; but now I'm faffing.

Here is the out put I'm trying to get
Its grouped by Location, then Course and then I'd like every instance of date for its respective grouping.

Location A
Course A - Date1
- Date2
- Date3
Course B - Date4
- Date5
- Date6

Location B
Course A - Date7
- Date8
- Date9
Course B - Date10
- Date11
- Date12

The xsl and xml I've gone back to is just like the example given on jenitennison dot com I spent all day yesterday trying to understand; but with no luck. Any help or link to help is more than welcome




I get this which is almost there but not great.

Location A
Course A - Date1
Course A - Date2

Course B - Date4
Course B - Date5

Location B
Course A - Date7
Course A - Date8
Course B - Date10
Course B - Date11


<xsl:key name="course-by-location" match="contact" use="location" />

<xsl:template match="records">
<xsl:for-each select="contact[count(. | key('course-by-location', location)[1]) = 1]">
<xsl:sort select="location" />
<b><xsl:value-of select="location" /></b><br />

<xsl:for-each select="key('course-by-location', location)">
<xsl:sort select="course" />
<xsl:value-of select="course" /> - <xsl:value-of select="date" /><br />
</xsl:for-each><br />

</xsl:for-each>

</xsl:template>


<records>
<contact id="0001">
<date>Date1</date>
<course>Course A</course>
<location>Location A</location>
</contact>
<contact id="0002">
<date>Date2</date>
<course>Course A</course>
<location>Location A</location>
</contact>
<contact id="0003">
<date>Date3</date>
<course>Course D</course>
<location>Location A</location>
</contact>
...
</records>

Reply With Quote
  #2  
Old April 4th, 2008, 09:14 AM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 474 jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 18 m 31 sec
Reputation Power: 52
second level grouping:
Code:
<xsl:key name="date-by-course-location" match="contact" use="concat(location, '-', course)"/>

<xsl:for-each select="key('course-by-location', location)[count(.|key('date-by-course-location', concat(location,'-', course))[1]) = 1]">
	<xsl:sort select="course"/>
	<xsl:value-of select="course"/>
	<xsl:for-each select="key('date-by-course-location', concat(location,'-', course))">
		<xsl:text>- </xsl:text>
		<xsl:value-of select="date"/>
		<br/>
	</xsl:for-each>
</xsl:for-each>

Reply With Quote
  #3  
Old April 4th, 2008, 10:44 AM
waxdart waxdart is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 waxdart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 30 sec
Reputation Power: 0
:) its works - it works

Thank you. I wouldn't have got the concat.


For those who are just starting out and learn best from example I have posted the full thing for you to use and change

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

<xsl:key name="date-by-course-location" match="contact" use="concat(location, '-', course)"/>
<xsl:key name="course-by-location" match="contact" use="location" />

<xsl:template match="records">
	<xsl:for-each select="contact[count(. | key('course-by-location', location)[1]) = 1]">
		<xsl:sort select="location" />
		<b><xsl:value-of select="location" /></b><br />
		<xsl:for-each select="key('course-by-location', location)[count(.|key('date-by-course-location', concat(location,'-', course))[1]) = 1]">
			<xsl:sort select="course"/>
				<xsl:value-of select="course"/>
			<xsl:text> - </xsl:text> 
			<xsl:for-each select="key('date-by-course-location', concat(location,'-', course))">
				<xsl:value-of select="date"/>
				<xsl:text> </xsl:text> 
			</xsl:for-each>
			<br />
		</xsl:for-each>
		<br />		
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

<tags>  xslt 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Muenchian Grouping with in a Muenchian Group ???


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway