473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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

Similar topics

4
by: Thomas Honold | last post by:
Hi there, I want to generate C++ or Java code by script, e.g. classes with getter/setter methods. Someone told me that nowadays it is done with XML and XSLT. I should use - XML File which...
20
by: Bernd Fuhrmann | last post by:
Hi! I have some trouble with some simple stupid XSLT-stuff. My stylesheet: ------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
6
by: RC | last post by:
Hello World, I am try do call a JavaScript function from XSLT, but I got function not avaible error. See "????" below. Would someone out there tell me how? Thank Q! <xsl:stylesheet...
3
by: Jack Fox | last post by:
I've never had the need to work with XML, but I believe I now have an appropriate application. I have time-series data in objects organized as a tree that I want an ASP.NET program to write out to...
1
by: John Moore | last post by:
I have a set of code that is called on every page load that loads an xslt file. The xslt file has an embedded <script> tag. Loading the page mutliple times causes aspnet_wp.exe to use all available...
3
by: Ian Roddis | last post by:
Hello, I want to embed SQL type queries within an XML data record. The XML looks something like this: <DISPLAYPAGE> <FIELD NAME="SERVER" TYPE="DROPDOWN"> <OPTION>1<OPTION> <OPTION>2<OPTION>...
1
by: Peran | last post by:
If I create a simple xslt stylesheet I can quickly test this in VS2005 by pressing the "Show XSLT Output" button rather than running the whole solution. If I then create a xslt stylesheet with...
3
by: Greg | last post by:
Hi, I want to create a web based interface that uses a form + Javascript (in an XHTML namespace) to construct an XPath to query and modify the attributes of some SVG (in an SVG namespace). ...
3
by: RC | last post by:
Let's say: if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Now I got an XML object here var xmlDocument = XMLHttpRequestObject.responseXML; // next I have...
1
by: qbp90x5lb | last post by:
I'm using an XSLT transform to output the element value contents from a simple XML file into a new .TXT file. Everything works fine except for certain XML files, when calling msxsl with the .xslt, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.