Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xsl:value-of select

Reply
Thread Tools

xsl:value-of select

 
 
aidy
Guest
Posts: n/a
 
      02-20-2008
Hi,

Here is my xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="testresults">
<table border="2">
<tr>
<td><b>TESTID</b></td>
<td><b>TEST DESCRIPTION</b></td>
<td><b>STATUS</b></td>
<td><b>MESSAGE</b></td>
</tr>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="test">
<xsl:for-each select="teststatus">
<tr>
<td>
<xsl:if test="position()=1">
<xsl:value-of select="../@id"/>
</xsl:if>
</td>
<td><xsl:value-of select="../description"/></td>
<xsl:choose>
<xsl:when test=".= 'ACTION'">
<td bgcolor="#FFFF00"><xsl:value-of select="."/></td>
</xsl:when>
<xsl:when test=".= 'PASS'">
<td bgcolor="#00ff00"><xsl:value-of select="."/></td>
</xsl:when>
<xsl:when test=".= 'FAIL'">
<td bgcolor="#FF0000"><xsl:value-of select="."/></td>
</xsl:when>
</xsl:choose>
<td><xsl:value-of select="following-sibling::message[1]"/></
td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

ACTION and FAIL have messages associated with them but PASS doesn't

here is the xml

- <testresults>
- <test id="Register">
<description>Register a x account</description>
<teststatus>ACTION</teststatus>
<message>gone to http://x.com/</message>
<teststatus>ACTION</teststatus>
<message>HTML text of Whoops, we are sorry but an error has
occurred... is being verified</message>
<teststatus>PASS</teststatus>
<teststatus>ACTION</teststatus>
<message>HTML text of The generated code you entered was incorrect
is being verified</message>
<teststatus>PASS</teststatus>
<teststatus>ACTION</teststatus>
<message>HTML text of You appear to have an active account with this
email address. is being verified</message>
<teststatus>FAIL</teststatus>
<message>You appear to have an active account with this email
address</message>
<teststatus>ACTION</teststatus>
<message>clicked log out</message>
<teststatus>FAIL</teststatus>
<message>Need to check registered email here, but not having success
with Admin MasterRegCode</message>
<teststatus>ACTION</teststatus>
<message>browser has been closed</message>
</test>

At the moment the xsl create messages for PASS in the HTML. I need
to prevent this.

Aidy
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-20-2008
aidy wrote:

> At the moment the xsl create messages for PASS in the HTML. I need
> to prevent this.


Well you could use xsl:if test as you have done elsewhere or you could
restructure the whole stylesheet to use xsl:apply-templates and
templates matching the different teststatus values e.g.

<xsl:stylesheet
xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xslutput method="html" indent="yes"/>

<xsl:template match="testresults">
<table border="2">
<thead>
<tr>
<th>TESTID</th>
<th>TEST DESCRIPTION</th>
<th>STATUS</th>
<th>MESSAGE</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="test/teststatus"/>
</tbody>
</table>
</xsl:template>

<xsl:template match="teststatus[. = 'ACTION']">
<tr>
<td>
<xsl:if test="position() = 1">
<xsl:value-of select="../@id"/>
</xsl:if>
</td>
<td><xsl:value-of select="../description"/></td>
<td bgcolor="#FFFF00"><xsl:value-of select="."/></td>
<td><xsl:value-of select="following-sibling::message[1]"/></td>
</tr>
</xsl:template>

<xsl:template match="teststatus[. = 'PASS']">
<tr>
<td>
<xsl:if test="position() = 1">
<xsl:value-of select="../@id"/>
</xsl:if>
</td>
<td><xsl:value-of select="../description"/></td>
<td bgcolor="#00ff00"><xsl:value-of select="."/></td>
<td></td>
</tr>
</xsl:template>

<xsl:template match="teststatus[. = 'FAIL']">
<tr>
<td>
<xsl:if test="position() = 1">
<xsl:value-of select="../@id"/>
</xsl:if>
</td>
<td><xsl:value-of select="../description"/></td>
<td bgcolor="#FF0000"><xsl:value-of select="."/></td>
<td><xsl:value-of select="following-sibling::message[1]"/></td>
</tr>
</xsl:template>

</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-20-2008
aidy wrote:

> <td><xsl:value-of select="following-sibling::message[1]"/></
> td>


If you want to make only a small change then use
<td>
<xsl:value-of select="following-sibling::*[1][self::message]"/>
</td>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select gridview row without using select button? =?Utf-8?B?RGFiYmxlcg==?= ASP .Net 5 02-27-2009 02:56 AM
select.select and socket.setblocking Laszlo Nagy Python 12 01-03-2009 09:25 PM
select.select() on windows jas Python 4 10-27-2005 11:10 AM
Selection from One SELECT changes selected option of another SELECT? J. Hall HTML 2 04-21-2004 05:36 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments