Grouping XML elements based on attributes with XSLT

files

New Member
I am working on a webpage that publishes a schedule of presentations based on an XML feed that I don't have access to change.The feed looks like this:\[code\] <track name="Track 1"> <session name="Session 1" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45"> <presentation name="Presentation 1"> ...presentation info </presentation> <presentation name="Presentation 2"> ...presentation info </presentation> </session> <session name="Session 2" starttime="2012-06-06 10:45" endtime="2012-06-06 12:45"> <presentation name="Presentation 3"> ...presentation info </presentation> <presentation name="Presentation 4"> ...presentation info </presentation> </session> <session name="Session 3" starttime="2012-06-07 08:45" endtime="2012-06-07 10:45"> <presentation name="Presentation 5"> ...presentation info </presentation> <presentation name="Presentation 6"> ...presentation info </presentation> </session> </track>\[/code\]At present, I am doing an \[code\]<xsl:for-each select="session">\[/code\] loop to pull out information, however that ends with me outputting duplicate dates and times.I have no problem doing the actual date and time parsing, so I am currently outputting June 6, 2012; 10:45 with no issue, but it is being duplicated each time due to the for-each, as follows:June 6, 2012 10:45-12:45Session 1: Presentation 1, Presentation 2June 6, 2012 10:45-12:45Session 2: Presentation 3, Presentation 4June 7, 2012:8:45-10:45Session 3: Presentation 5, Presentation 6What I would like is to somehow pull out all common datetimes, for instance, get output like:June 6, 2012:10:45-12:45Session 1: Presentation 1, Presentation 2Session 2: Presentation 3, Presentation 4June 7, 2012:8:45-10:45Session 3: Presentation 5, Presentation 6For reference, here is my current implementation:\[code\]<xsl:for-each select="session"> <h4> <!-- output to Month, DD, YYYY --> <xsl:call-template name="formatDate"> <xsl:with-param name="dateTime" select="@starttime" /> </xsl:call-template> </h4> <h5> <!-- output time --> <xsl:call-template name="formatTime"> <xsl:with-param name="dateTime" select="@starttime" /> </xsl:call-template> - <xsl:call-template name="formatTime"> <xsl:with-param name="dateTime" select="@endtime" /> </xsl:call-template> </h5> <!-- session title --> <h5><xsl:value-of select="@name"/></h5> <!-- presentation title --> <xsl:for-each select="presentation"> <xsl:value-of select="@name"/><xsl:element name="br"/> </xsl:for-each></xsl:for-each>\[/code\]
 
Back
Top