469,310 Members | 2,750 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,310 developers. It's quick & easy.

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>06012006</date>
<time>0500</time>
</show>
<show>
<date>06012006</date>
<time>0600</time>
</show>
<show>
<date>06012006</date>
<time>0700</time>
</show>
<show>
<date>08012006</date>
<time>0500</time>
</show>
<show>
<date>08012006</date>
<time>0600</time>
</show>
<show>
<date>08012006</date>
<time>0700</time>
</show>
</film>
</showtimes>
May 8 '06 #1
2 2240
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.

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>06012006</date>
<time>0500</time>
</show>
<show>
<date>06012006</date>
<time>0600</time>
</show>
<show>
<date>06012006</date>
<time>0700</time>
</show>
<show>
<date>08012006</date>
<time>0500</time>
</show>
<show>
<date>08012006</date>
<time>0600</time>
</show>
<show>
<date>08012006</date>
<time>0700</time>
</show>
</film>
</showtimes>
Feb 27 '07 #2
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Thomas Honold | last post: by
20 posts views Thread by Bernd Fuhrmann | last post: by
3 posts views Thread by Jack Fox | last post: by
3 posts views Thread by Ian Roddis | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.