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="spanish" country="mexico" genre="drama">
<title>Y Tu Mamá También</title>
<date>2002</date>
<country>Mexico</country>
<language>Spanish</language>
<rating>R</rating>
<director>Alfonso 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="http://www.w3.org/1999/xlink/"
xlink:type="simple" xlink:href="http://www.google.com"
xlink:title="Google" xlink:role=""http://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:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://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:apply-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>Action Movies</H1></a>
<xsl:apply-templates select="key('genre', 'action')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t2"><H1>Animation Movies</H1></a>
<xsl:apply-templates select="key('genre', 'animation')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t3"><H1>Comedy Movies</H1></a>
<xsl:apply-templates select="key('genre', 'comedy')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t4"><H1>Drama Movies</H1></a>
<xsl:apply-templates select="key('genre', 'drama')">
<xsl:sort select="title"/>
</xsl:apply-templates>
<a name="t5"><H1>Suspense Movies</H1></a>
<xsl:apply-templates select="key('genre', 'suspense')">
<xsl:sort select="title"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="movie">
<table>
<tr>
<td colspan="2"><h2><b><xsl:value-of select="title" /></b></h2></td>
</tr>
<tr>
<td><b>Date: </b></td> <td><xsl:value-of select="date" /></td>
</tr>
<tr>
<td><b>Country: </b></td> <td><xsl:value-of select="country" /></td>
</tr>
<tr>
<td><b>Language: </b></td> <td><xsl:value-of select="language" /></td>
</tr>
<tr>
<td><b>Rating: </b></td> <td><xsl:value-of select="rating" /></td>
</tr>
<tr>
<td><b>Director: </b></td> <td><xsl:value-of select="director" /></td>
</tr>
<tr>
<td><b>Actors: </b></td> <td><xsl:value-of select="actors" /></td>
</tr>
<tr>
<td><b>Genre: </b></td> <td><xsl:value-of select="genre" /></td>
</tr>
<tr>
<td valign="top"><b>Summary: </b></td> <td><xsl:value-of select="summary" /></td>
</tr>
</table>
<br></br>
</xsl:template>
<xsl:template match="link">
<link href="{@xlink:href}">
<xsl:apply-templates>
</link>
</xsl:template>
</xsl:stylesheet>[/html]