Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with linking elements... 1

Status
Not open for further replies.

Delameko

Programmer
Oct 14, 2003
37
GB
I had a long look through this forum and tried the various examples people had supplied for other peoples problems, but I couldn't figure out how to tailor them to my own.

Its a simple cinema search for local cinemas. The idea being that each cinema will have a different XSL with the cinema venueID hardcoded in, but the titles/times can be updated dynamically by a third party. There's also a venueList element with the venueID, but I didn't include this as its not necessary.

This is a simplified version of my xml:
<listing>
<titleList>
<title titleID="someID">
<titleName>Land Of the Dead</titleName>
</title>

<title... etc etc
</titleList>

<eventList>
<event titleID="txsahara" venueID="vxromste">
<originalTimes>Progs 11.15am 2.15pm 5.15pm</originalTimes>
</event>

<event... etc etc
</eventList>
</listing>


My problem is this. The film name is not included in the showtimes (eventList), only in the film info (titleList). I don't know/understand the code needed to link the two by the titleID, so it shows the corresponding title to each set of filmtimes.

Changing the xml is not possible as it comes from an external source who want a lot of money for customisation.

Thanks in advance to anyone that can assist me.
 
The key is using current() function:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
      <xsl:apply-templates select="listing/eventList"/>
  </xsl:template>
  <xsl:template match="eventList">
    <ul>
      <xsl:apply-templates select="event"/>
    </ul>
  </xsl:template>
  <xsl:template match="event">
    <li>
      <xsl:value-of select="../../titleList/title[@titleID = current()/@titleID]/titleName"/> - <xsl:value-of select="originalTimes"/>
    </li>
  </xsl:template>
</xsl:stylesheet>

Jon

"I don't regret this, but I both rue and lament it.
 
You, sir, are a prince among men. I thank you greatly for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top