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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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]">

   
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.