Forum Moderators: open

Message Too Old, No Replies

url in xslt

displ;ay each cell value ina table as a hyperlink

         

Shastra

1:49 am on Aug 10, 2005 (gmt 0)

10+ Year Member



Hello,
I need the final xhtml output (a table)to be like this-
--------------------
Enterprise Reports
-------------------
Report1Name
.............
Report2Name
.............

and so on. The report1Name will be replaced by the actual name of the report which will be the hypertext and on clicking will bring up the report page. Also I need to sort this column by report name

I plan to have the xml file containing data on the report names and the corresponding urls with the structure:
catalog/report/name
catalog/report/url

I am unable to generate just one column in the table that will have the report name as a hyperlink. xsl will not let me pull the url part containing the valueas <a href="...">

Any help is greatly appreciated.

athinktank

5:30 am on Aug 10, 2005 (gmt 0)

10+ Year Member



Howdy Shastra, Welcome to Webmasterworld

I have whipped up this example, I hope it helps. There are three parts, the xml, xsl and an ant build file to do the transform.

<?xml version="1.0"?>
<cat>
<reports>
<report>
<name>a</name>
<url>http://localhost/report.jsp?id=1</url>
</report>
<report>
<name>c</name>
<url>http://localhost/report.jsp?id=2</url>
</report>
<report>
<name>b</name>
<url>http://localhost/report.jsp?id=2</url>
</report>
</reports>
</cat>

<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<div class="title-style">
<xsl:text>Enterprise Reports</xsl:text>
</div>
<xsl:for-each select="/cat/reports/report">
<xsl:sort select="name" order="ascending"/>
<div class="item-style">
<a href="{url}">
<xsl:value-of select="name" />
</a>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

<?xml version="1.0"?>
<project name="WebmasterWorld" default="go" basedir=".">
<target name="go">
<style basedir="." destdir="." extension=".html" style="xsl.xsl" includes="data.xml" excludes="nothing.xml" classpath="C:/saxon8/saxon8.jar">
</style>
</target>
</project>

Shastra

9:48 pm on Aug 13, 2005 (gmt 0)

10+ Year Member



Greetings athinktank!
Thanks a lot.. for the prompt response and your help. The {} aroung the url xml element in xsl file did the trick.
Best
Shastra