|
next
|
Subject: grouping with Muenchian method..im so close Author: Diijon Taylor Date: 06 Jul 2007 12:36 PM
|
Over the past two days I've read all types of articles about the method and tried many ways, but now I'm stuck on how to finish it up. My xml is basically:
<NewDataSet>
<IMAX_DAILY_SCHEDULE>
<start_date>July 11, 2007</start_date>
<end_date>July 25, 2007</end_date>
<title>Harry Potter</title>
<start_time>12:00 am</start_time>
<channel>c283975336192110VgnVCM100000190c640aRCRD</channel>
<url>6bc540ea59e43110VgnVCM100000190c640aRCRD</url>
</IMAX_DAILY_SCHEDULE>
<IMAX_DAILY_SCHEDULE>
<start_date>July 11, 2007</start_date>
<end_date>July 25, 2007</end_date>
<title>Deep Sea</title>
<start_time>10:00 am</start_time>
<channel>c283975336192110VgnVCM100000190c640aRCRD</channel>
<url>6bc540ea59e43110VgnVCM100000190c640aRCRD</url>
</IMAX_DAILY_SCHEDULE>
<IMAX_DAILY_SCHEDULE>
<start_date>July 15, 2007</start_date>
<end_date>July 29, 2007</end_date>
<title>Dinosaurs</title>
<start_time>10:00 am</start_time>
<channel>c283975336192110VgnVCM100000190c640aRCRD</channel>
<url>6bc540ea59e43110VgnVCM100000190c640aRCRD</url>
</IMAX_DAILY_SCHEDULE>
</NewDataSet>
And I want the transformed xml to look like:
July 11,2007-July 25,2007
Title: Harry Potter
Title: Deep Sea
-------------------------
July 15,2007-July 29,2007
Title: Dinosaurs
Of course, I want the dates to be pulled from the node values as well. Here is my current xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="dateGroup"
match="IMAX_DAILY_SCHEDULE"
use="concat(start_date,'+',end_date)" />
<xsl:variable name="startDate" select="start_date" />
<xsl:variable name="endDate" select="end_date" />
<xsl:variable name="startDate_endDate"
select="concat($startDate, '+', $endDate)" />
<xsl:template match="IMAX_DAILY_SCHEDULE">
<div>
Start Date:<xsl:value-of disable-output-escaping="yes" select="start_date" />,
End Date:<xsl:value-of disable-output-escaping="yes" select="end_Date" />
</div>
<xsl:for-each select="self::node()[count(.|key('dateGroup',
concat(start_time, '+', end_time))[1])=1]">
<div>Title: <xsl:value-of disable-output-escaping="yes" select="title" /></div>
</xsl:for-each>
<xsl:call-template name="divider" />
</xsl:template>
<xsl:template name="divider">
<div style="height:15px;">----------</div>
</xsl:template>
</xsl:stylesheet>
However, Currently I'm getting:
Start Date: July 11,2007, End Date:
Title: Harry Potter
-------------
Start Date: July 11,2007, End Date:
Title: Deep Sea
-------------
Start Date: July 15,2007, End Date:
Title: Dinosaurs
I've worked hard to even get to this point but it seems like I've got some type of formatting issue.
|
next
|
Subject: grouping with Muenchian method..im so close Author: Diijon Taylor Date: 06 Jul 2007 02:59 PM
|
This worked:
<?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="dateGroup" match="IMAX_DAILY_SCHEDULE" use="concat(start_date,'+',end_date)"/>
<xsl:template match="IMAX_DAILY_SCHEDULE">
<xsl:for-each select="self::node()[generate-id(.)=
generate-id(key('dateGroup', concat(start_date,'+',end_date))[1])]">
<xsl:sort select="start_date"/>
<xsl:for-each select="key('dateGroup', concat(start_date,'+',end_date))">
<xsl:sort select="title"/>
<xsl:sort select="start_time"/>
<xsl:if test="position() = 1">
<xsl:attribute name="div">
<xsl:value-of select="count(key('dateGroup', concat(start_date,'+',end_date)))"/>
</xsl:attribute>
<div style="font-weight: bold;">
<xsl:value-of select="start_date"/> - <xsl:value-of select="end_date"/>
</div>
</xsl:if>
<div>
<xsl:value-of select="title"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="start_time"/>
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
|
|
|