I have an XML and XSL document. I am trying to incorporate hyperlinks throughout the XML document. I have read many of the related posts on this and other forums but I can't seem to get it right. Please help! Do I have to declare the namespace in the XSL doc also as shown below or should I take it out? No matter what I do, nothing appears for the link tag in the browser.
a piece of my xml DOC (using google for now as an easy example but google will not be my actual webpage):
[html]<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="genre.xsl "?>
<movielist>
<intro>Browse the Foreign Movies</intro>
<movie language="spani sh" country="mexico " genre="drama">
<title>Y Tu Mamá También</title>
<date>2002</date>
<country>Mexico </country>
<language>Spani sh</language>
<rating>R</rating>
<director>Alfon so Cuarón</director>
<actors>Ana López Mercado, Gael García Bernal, Diego Luna</actors>
<genre>Drama</genre>
<summary>In Mexico, two teenage boys and an attractive older woman embark on a road trip and learn a thing or
two about life, friendship, and each other.</summary>
<link> xmlns:xlink="ht tp://www.w3.org/1999/xlink/"
xlink:type="sim ple" xlink:href="htt p://www.google.com"
xlink:title="Go ogle" xlink:role=""ht tp://www.w3.org/1999/XSL/Transform">
xlink:actuate=" onRequest"
</link>
</movie>[/html]
xsl document in whole:
[html]<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xlink="ht tp://www.w3.org/1999/xlink" exclude-result-prefixes="xlink ">
<xsl:key name="genre" match="movie" use="@genre" />
<xsl:template match="/movielist">
<html>
<head>
<title>Movies By Genre</title>
</head>
<body>
<H1><xsl:appl y-templates select="intro"/></H1>
<H1>By Genre</H1>
<a href="genre.xml #t1">Action</a>
<br></br>
<a href="genre.xml #t2">Animation </a>
<br></br>
<a href="genre.xml #t3">Comedy</a>
<br></br>
<a href="genre.xml #t4">Drama</a>
<br></br>
<a href="genre.xml #t5">Suspense</a>
<a name="t1"><H1>A ction Movies</H1></a>
<xsl:apply-templates select="key('ge nre', 'action')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t2"><H1>A nimation Movies</H1></a>
<xsl:apply-templates select="key('ge nre', 'animation')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t3"><H1>C omedy Movies</H1></a>
<xsl:apply-templates select="key('ge nre', 'comedy')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t4"><H1>D rama Movies</H1></a>
<xsl:apply-templates select="key('ge nre', 'drama')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t5"><H1>S uspense Movies</H1></a>
<xsl:apply-templates select="key('ge nre', 'suspense')">
<xsl:sort select="title"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="movie">
<table>
<tr>
<td colspan="2"><h2 ><b><xsl:valu e-of select="title" /></b></h2></td>
</tr>
<tr>
<td><b>Date: </b></td> <td><xsl:valu e-of select="date" /></td>
</tr>
<tr>
<td><b>Countr y: </b></td> <td><xsl:valu e-of select="country " /></td>
</tr>
<tr>
<td><b>Language : </b></td> <td><xsl:valu e-of select="languag e" /></td>
</tr>
<tr>
<td><b>Rating : </b></td> <td><xsl:valu e-of select="rating" /></td>
</tr>
<tr>
<td><b>Director : </b></td> <td><xsl:valu e-of select="directo r" /></td>
</tr>
<tr>
<td><b>Actors : </b></td> <td><xsl:valu e-of select="actors" /></td>
</tr>
<tr>
<td><b>Genre: </b></td> <td><xsl:valu e-of select="genre" /></td>
</tr>
<tr>
<td valign="top"><b >Summary: </b></td> <td><xsl:valu e-of select="summary " /></td>
</tr>
</table>
<br></br>
</xsl:template>
<xsl:template match="link">
<link href="{@xlink:h ref}">
<xsl:apply-templates>
</link>
</xsl:template>
</xsl:stylesheet>[/html]