XSLT help with simple script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seanjuan
    New Member
    • May 2006
    • 1

    XSLT help with simple script?

    Lets say I have a movie playing on 06012006 at many times in the day, and again on 08012006 for several more times, in fact this goes on across many many days. I need to have an output like this:

    The Big Show
    06012006 : 0500, 0600, 0700
    08012006 : 0500, 0600, 0700

    Not like this, which I seem to be able to do already:

    The Big Show
    06012006 : 0500
    06012006 : 0600
    06012006 : 0700
    08012006 : 0500
    08012006 : 0600
    08012006 : 0700

    This is what my XML looks like. How to I make that happen in my XSL sheet? Thanks for the help, I don't understand this XSL stuff very well!!

    <showtimes>
    <id>my theater</id>
    <film>
    <name>The Big Show</name>
    <show>
    <date>0601200 6</date>
    <time>0500</time>
    </show>
    <show>
    <date>0601200 6</date>
    <time>0600</time>
    </show>
    <show>
    <date>0601200 6</date>
    <time>0700</time>
    </show>
    <show>
    <date>0801200 6</date>
    <time>0500</time>
    </show>
    <show>
    <date>0801200 6</date>
    <time>0600</time>
    </show>
    <show>
    <date>0801200 6</date>
    <time>0700</time>
    </show>
    </film>
    </showtimes>
  • One Caring
    New Member
    • Feb 2007
    • 1

    #2
    Hey, I know it is almost a year later but.. anyway, I just saw it and tought to put the resolution. It might be helpful for others...

    This is how you do it:

    <x:template match="show">

    <x:choose>

    <x:when test="preceding-sibling::show/date[1]!=date">

    <br/>
    <x:value-of select="date + ': '"/>
    <x:value-of select="time + ' '"/>

    </x:when>
    <x:otherwise>

    <x:value-of select="time + ' '"/>

    </x:otherwise>
    </x:choose>

    <x:apply-templates/>

    </x:template>

    Cheers
    -Kamran.

    Originally posted by seanjuan
    Lets say I have a movie playing on 06012006 at many times in the day, and again on 08012006 for several more times, in fact this goes on across many many days. I need to have an output like this:

    The Big Show
    06012006 : 0500, 0600, 0700
    08012006 : 0500, 0600, 0700

    Not like this, which I seem to be able to do already:

    The Big Show
    06012006 : 0500
    06012006 : 0600
    06012006 : 0700
    08012006 : 0500
    08012006 : 0600
    08012006 : 0700

    This is what my XML looks like. How to I make that happen in my XSL sheet? Thanks for the help, I don't understand this XSL stuff very well!!

    <showtimes>
    <id>my theater</id>
    <film>
    <name>The Big Show</name>
    <show>
    <date>0601200 6</date>
    <time>0500</time>
    </show>
    <show>
    <date>0601200 6</date>
    <time>0600</time>
    </show>
    <show>
    <date>0601200 6</date>
    <time>0700</time>
    </show>
    <show>
    <date>0801200 6</date>
    <time>0500</time>
    </show>
    <show>
    <date>0801200 6</date>
    <time>0600</time>
    </show>
    <show>
    <date>0801200 6</date>
    <time>0700</time>
    </show>
    </film>
    </showtimes>

    Comment

    • dorinbogdan
      Recognized Expert Contributor
      • Feb 2007
      • 839

      #3
      Hi,
      Did you succeed to solve the problem ?
      If yes, please let me know, in order to close the thread.
      Thanks,
      Dorin.

      Comment

      Working...