XSLT help with href

C

Craig

Hello there,

I'm trying to generate a hyperlink (href) using XSLT to generate a web
page that displays a table with selected information. At the moment
everything is working except for the hyperlink which I can't seem to
get my head around. I have the XSLT code listed below so if anyone can
let me know what the problem is with my script I would be greatly
appreciated. Here is the code:

<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/REC-html40">
<xsl:eek:utput method='html' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:template match="/">
<html>
<head>
<title>Bob Action Log</title>
</head>
<body>
<P>Here are the log files for the individual builds</P>
<table border="1">
<tr>
<th align="center">Build Step</th>
<th align="center">Arch</th>
<th align="center">Config</th>
<th align="center">Action</th>
<th align="center">Build Started At</th>
<th align="center">Build Time</th>
<th align="center">RESULT</th>
</tr>
<xsl:for-each select="BobActivityLog/ActionLog">
<tr>
<td><xsl:value-of select="StepName"/></td>
<td><xsl:value-of select="Arch"/></td>
<td><xsl:value-of select="Config"/></td>
<td><xsl:value-of select="Action"/></td>
<td><xsl:value-of select="TimeStamp"/></td>
<td><xsl:value-of select="BuildTime"/></td>
<xsl:choose>
<xsl:when test="Result = 0">
<td>PASS</td>
</xsl:when>
<xsl:eek:therwise>
<td bgcolor="pink">
<xsl:attribute name="title">
<xsl:value-of select="MainErr"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="StepName"/>
</xsl:attribute>
FAIL (<xsl:value-of select="Result"/>)</td>
</xsl:eek:therwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
J

Joe Kesselman

At a quick glance, I don't see anything obviously wrong. What does your
input look like, what output are you trying to get, what output are you
actually getting?
 
M

Martin Honnen

Craig wrote:

I'm trying to generate a hyperlink (href) using XSLT to generate a web
page that displays a table with selected information. At the moment
everything is working except for the hyperlink which I can't seem to
get my head around.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you want to generate HTML 4 output then remove that namespace
declaration as HTML does not know any namespaces.
<xsl:eek:utput method='html' version='1.0' encoding='UTF-8' indent='yes'/>
<td bgcolor="pink">
<xsl:attribute name="title">
<xsl:value-of select="MainErr"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="StepName"/>
</xsl:attribute>
FAIL (<xsl:value-of select="Result"/>)</td>

You are generating a href attribute on a td element but with HTML you
need an a element e.g
<a>
<xsl:attribute name="href">
<xsl:value-of select="StepName"/>
</xsl:attribute>
some link content here
</a>
or easier with an attribute value template as
<a href="{StepName}">some link content here</a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top