Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Multiple Groups in XSLT

From: JoelBrimm@-----------.---------.---
To: NULL
Date: 8/6/2007 12:48:00 PM


I've managed to get half way there - But I can't quite get the last 
grouping.  Can anyone help?  

XSL
---
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:output method="xml" />
	
	<xsl:key name="byUnit" match="Studio_Appt_Date_Times" use="bus_unit_id"/>
	<xsl:key name="byDate" match="Studio_Appt_Date_Times" use="sched_date" />
	<xsl:key name="byDateAndTimeRange" match="Studio_Appt_Date_Times" 
use="concat(sched_date,time_range_descr)" />
	
	<xsl:template match="/">
		<Studio_Appt_Data>
			<xsl:for-each 
select="/DataSet_Studio_Appt_Dates/Studio_Appt_Date_Times[generate-id() = 
generate-id(key('byUnit',bus_unit_id)[1] ) ]">
			<xsl:sort select="bus_unit_id"/>
				<bus_unit_id><xsl:value-of select="bus_unit_id"/></bus_unit_id>
			</xsl:for-each>
			<xsl:apply-templates/>
		</Studio_Appt_Data>
	</xsl:template>
			
	<xsl:template match="/DataSet_Studio_Appt_Dates">	
		<Studio_Appt_Dates>
			<xsl:apply-templates select="Studio_Appt_Date_Times[generate-id(.) = 
generate-id(key('byDate',sched_date)[1] ) ]" />
		</Studio_Appt_Dates>
	</xsl:template>
	
	<xsl:template match="/DataSet_Studio_Appt_Dates/Studio_Appt_Date_Times">
		<Appt_Date><xsl:value-of select="sched_date"/></Appt_Date>
		<Appt_Times>
			<xsl:for-each select="key('byDate',sched_date)">
				<Appt_Time><xsl:value-of select="sched_time"/></Appt_Time>
			</xsl:for-each>
		</Appt_Times>
	</xsl:template>
	
</xsl:stylesheet>

OUTPUT
=====
<?xml version="1.0" encoding="UTF-8"?>
<Studio_Appt_Data>
	<bus_unit_id>2405</bus_unit_id>
	<Studio_Appt_Dates>
		<Appt_Date>8/7/2007 12:00:00 AM</Appt_Date>
		<Appt_Times>
			<Appt_Time>11:00:00</Appt_Time>
			<Appt_Time>11:30:00</Appt_Time>
			<Appt_Time>12:00:00</Appt_Time>
			<Appt_Time>13:00:00</Appt_Time>
			<Appt_Time>13:30:00</Appt_Time>
			<Appt_Time>15:00:00</Appt_Time>
			<Appt_Time>15:30:00</Appt_Time>
			<Appt_Time>16:00:00</Appt_Time>
			<Appt_Time>16:30:00</Appt_Time>
			<Appt_Time>17:00:00</Appt_Time>
			<Appt_Time>17:30:00</Appt_Time>
			<Appt_Time>18:00:00</Appt_Time>
			<Appt_Time>18:30:00</Appt_Time>
			<Appt_Time>19:00:00</Appt_Time>
			<Appt_Time>19:30:00</Appt_Time>
			<Appt_Time>20:00:00</Appt_Time>
		</Appt_Times>
		<Appt_Date>8/8/2007 12:00:00 AM</Appt_Date>
		<Appt_Times>
			<Appt_Time>11:00:00</Appt_Time>
			<Appt_Time>11:30:00</Appt_Time>
			<Appt_Time>12:00:00</Appt_Time>
			<Appt_Time>13:00:00</Appt_Time>
			<Appt_Time>13:30:00</Appt_Time>
			<Appt_Time>15:00:00</Appt_Time>
			<Appt_Time>15:30:00</Appt_Time>
			<Appt_Time>16:00:00</Appt_Time>
			<Appt_Time>16:30:00</Appt_Time>
			<Appt_Time>17:00:00</Appt_Time>
			<Appt_Time>17:30:00</Appt_Time>
			<Appt_Time>18:00:00</Appt_Time>
			<Appt_Time>18:30:00</Appt_Time>
			<Appt_Time>19:00:00</Appt_Time>
			<Appt_Time>19:30:00</Appt_Time>
			<Appt_Time>20:00:00</Appt_Time>
		</Appt_Times>
		<Appt_Date>8/9/2007 12:00:00 AM</Appt_Date>
		<Appt_Times>
			<Appt_Time>11:00:00</Appt_Time>
			<Appt_Time>11:30:00</Appt_Time>
			<Appt_Time>12:00:00</Appt_Time>
			<Appt_Time>13:00:00</Appt_Time>
		</Appt_Times>
	</Studio_Appt_Dates>
</Studio_Appt_Data>



Thanks!

Joel Brimm.



transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent