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!

Problem with requesting a node

Status
Not open for further replies.

145236987

IS-IT--Management
Feb 20, 2006
1
NL
Hi,

I'm working on a list of my movies. I'm making a button when i click it, it will display all the movies with the genre comedy. My problem is requesting the title names of all the movies wich genre is comedy. But I can't get it to work

================ my XML ======================
-<movielist>
-<movie>
-<title>
-<genres>
-<genre>
-<displayname>
-<displayname>
-<displayname>
==============================================



============ part of my XSL ==================

<xsl:param name="genre" />
<xsl:template match="movielist/movie">

<xsl:choose>
<xsl:when test="contains($genre, 'comedy')">
<xsl:choose>
<xsl:when test="contains(genres/genre/displayname, 'comedy')">
<xsl:value-of select="title"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:param name="genre" />
<xsl:template match="movielist/movie">

<xsl:choose>
<xsl:when test="contains($genre, 'comedy')">
<xsl:choose>
<xsl:when test="contains(genres/genre/displayname, 'comedy')">
<xsl:value-of select="title"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xs:when> ....etc

==============================================

Can anyone tell me what I'm doing wrong here?
 
The "part of my XSL" is very obscur, if it does not appear to you!
[1] Why parameter genre is empty? and declared twice?
[2] Why xsl:template not closed?
[3] Why the island of <xsl:choose> at the second half of the except? What is the purpose? ...

I can only try to salvage something like this.
[tt]
<xsl:template match="//movie">
<xsl:choose>
<xsl:when test="contains(./genres/genre, 'comedy')">
<xsl:value-of select="title"/>
</xsl:when>
</xsl:choose>
</xsl:template>
[/tt]
 
XSL is a template language, so try make use of that:
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:param name="genre"/>
  <xsl:template match="movielist">
    <xsl:apply-templates select="movie[genres/genre/displayname = $genre]"/>
  </xsl:template>
  <xsl:template match="movie">
Do stuff here....
</xsl:template>
</xsl:stylesheet>

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top