Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:08:33+00:00 2026-06-07T06:08:33+00:00

I am working on a webpage that publishes a schedule of presentations based on

  • 0

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:

  <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>

At present, I am doing an <xsl:for-each select="session"> 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:45

Session 1: Presentation 1, Presentation 2

June 6, 2012

10:45-12:45

Session 2: Presentation 3, Presentation 4

June 7, 2012:

8:45-10:45

Session 3: Presentation 5, Presentation 6

What I would like is to somehow pull out all common datetimes, for instance, get output like:

June 6, 2012:

10:45-12:45

Session 1: Presentation 1, Presentation 2

Session 2: Presentation 3, Presentation 4

June 7, 2012:

8:45-10:45

Session 3: Presentation 5, Presentation 6

For reference, here is my current implementation:

<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>

And the date-time formatter:

<!-- formatting dateTime -->
<xsl:template name="formatDate">
  <xsl:param name="dateTime" />
  <xsl:variable name="date" select="substring-before($dateTime, ' ')" />
  <xsl:variable name="year" select="substring-before($date, '-')" />
  <xsl:variable name="month" select="number(substring-before(substring-after($date, '-'), '-'))" />
  <xsl:variable name="day" select="number(substring-after(substring-after($date, '-'), '-'))" />

  <!-- output -->
  <xsl:choose>
    <xsl:when test="$month = '1'">January</xsl:when>
    <xsl:when test="$month = '2'">February</xsl:when>
    <xsl:when test="$month = '3'">March</xsl:when>
    <xsl:when test="$month = '4'">April</xsl:when>
    <xsl:when test="$month = '5'">May</xsl:when>
    <xsl:when test="$month = '6'">June</xsl:when>
    <xsl:when test="$month = '7'">July</xsl:when>
    <xsl:when test="$month = '8'">August</xsl:when>
    <xsl:when test="$month = '9'">September</xsl:when>
    <xsl:when test="$month = '10'">October</xsl:when>
    <xsl:when test="$month = '11'">November</xsl:when>
    <xsl:when test="$month = '12'">December</xsl:when>
  </xsl:choose>
  <xsl:value-of select="' '" />
  <xsl:value-of select="$day" />
  <xsl:value-of select="', '" />
  <xsl:value-of select="$year" />
</xsl:template>

<!-- formatting dateTime -->
<xsl:template name="formatTime">
  <xsl:param name="dateTime" />
  <xsl:value-of select="substring-after($dateTime, ' ')" />
</xsl:template>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:08:34+00:00Added an answer on June 7, 2026 at 6:08 am

    You want to group using the Muenchian method. Add this immediately inside the root element of your stylesheet:

    <xsl:key name="sessions-by-track-name-starttime-and-endtime" match="/track/session" use="concat(parent::track/@name, ' ', @starttime, ' ', @endtime)"/>
    

    Then update your XSLT as shown:

    <xsl:for-each select="session[generate-id() = generate-id(key('sessions-by-track-name-starttime-and-endtime', concat(parent::track/@name, ' ', @starttime, ' ', @endtime))[1])]">
      <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>
    
      <xsl:for-each select="key('sessions-by-track-name-starttime-and-endtime', concat(parent::track/@name, ' ', @starttime, ' ', @endtime))">
    
        <!-- 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>
    
    </xsl:for-each>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage that has to be displayed in several different languages based
Database resources, that can be accessed from webpage that I'm currently working on, have
I've got a webpage that I'm working on where you click on a letter
I'm currently working in an application that has to navigate a webpage and recollect
I am working on a webpage in C# on VS2010. I have a gridview
I have a webpage that has a button that sends a letter on the
I have an ASP.NET 4 webpage that contains an update panel which just allows
I'm working on a webpage that involves using the Blueprint CSS Framework, as this
We have an asp.net webpage that uses viewstate. During a lengthy operation (that takes
I have a webpage that needs to take numeric input, this part is easy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.