XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Diijon TaylorSubject: 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.


Postnext
Diijon TaylorSubject: 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>

Posttop
James DurningSubject: grouping with Muenchian method..im so close
Author: James Durning
Date: 09 Jul 2007 11:37 AM
I think the problem was that you were one level too far down:
Change the
<xsl:template match="IMAX_DAILY_SCHEDULE"> to
<xsl:template match="NewDataSet">

and the for-each from
<xsl:for-each select="self::node()[count(.|key('dateGroup',
concat(start_time, '+', end_time))[1])=1]">
to
<xsl:for-each select="IMAX_DAILY_SCHEDULE[count(.|key('dateGroup',
concat(start_time, '+', end_time))[1])=1]">

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.