473,387 Members | 1,700 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,387 software developers and data experts.

Need help with XLink and XSL documents

1
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]
May 2 '07 #1
1 1642
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN....

The HTML hyperlink tag is <a>, so use:
[html]<a href="{@xlink:href}">
<xsl:apply-templates>
</a>[/html]
May 2 '07 #2

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

Similar topics

5
by: Erik Jälevik | last post by:
Is it possible to use XLink within an XHTML document? I am trying the following in Mozilla Firebird 0.7 (which supposedly supports XLink) and I don't get a link: <?xml version="1.0"...
0
by: Anna | last post by:
Hello all. I hope this is the right group to ask my question. I have an HTML page that contains an SVG file in an object. Inside an SVG file I want to add a link to link to some anchor on the...
0
by: Gene Ellis | last post by:
Very simple question. If I have the XML file below: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="newspage.xsl"?> <newspage> <content>Click here for blah...
1
by: Lothar Lemnitzer | last post by:
Dear fellows, I have a problem with matching namespaces in an XML document and an XSLT stylesheet (at least I think that this is the source of trouble). My XML document looks like this: 1...
0
by: B | last post by:
I am working on an application which reads, writes and generates XBRL-compliant documents. XBRL makes extensive use of XLink in creating these documents. I have so far been unable to ascertain...
2
by: Carmit | last post by:
Hi, I'm trying to build a proxy for this webservice: http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/EndTransactionLLSRQ.wsdl I'm getting the following error: Error: Unable to import...
2
by: adMjb | last post by:
Hi Any help would be fantastic I have a simple problem but I cant work it out... DOHH...., this is my XML: <?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet type="text/css"...
4
by: jvanulden | last post by:
Hello all, I am having difficulty figuring out how to create an XmlElement and giving it an attribute that requires a namespace. Here is what I have so far which throws an exception because you...
0
by: ab.angadbhat | last post by:
hi, I have an element in the xml file which has xlink:href ="xyz.xml" as an attribute. I am using xpointer to point to only 2nd <Uelement of the xyz.xml file and so i am doing:- xlink:href...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.