Hi Martin,
My xml input
<report>
<result>
<title>Test Case 1</title>
<req bid="38180">My Data1 </req>
<exp_resp><code>OK</code><message>test1</message><fault></fault></exp_resp>
<resp><code>OK</code><message>test1</message><fault></fault></resp>
</result>
<result>
<title>Test Case 2</title>
<req bid="38180">My Data2 </req>
<exp_resp><code>OK</code><message>test2</message><fault></fault></exp_resp>
<resp><code>OK</code><message>test2</message><fault></fault></resp>
</result>
</report>
my XSLT for the same...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" indent="yes" />
<xsl:variable name="WHITESPACE" select="' '" />
<xsl:variable name="COLS" select="30" />
<xsl:variable name="ROWS" select="5" />
<xsl:preserve-space elements="fault" />
<xsl:template match="/">
<html>
<body >
<h2 >
My Report
</h2>
<table width="560" border="1" cellspacing="0"
cellpadding="0"
align="center">
<tr bgcolor="#9acd32">
<th>
Description
</th>
<th>
Request
</th>
<th>
Expected Response
</th>
<th>
Actual Response
</th>
<th>
Status
</th>
</tr>
<xsl:for-each select="report/result">
<tr>
<xsl:if
test="(position() mod 2 = 0)">
<xsl:attribute
name="bgcolor">
#FFF8C6
</xsl:attribute>
</xsl:if>
<td>
<xsl:value-of
select="title" />
</td>
<td>
<xsl:if
test="req/* or req/text()">
<textarea rows="$ROWS" cols="$COLS" readonly="true"
onClick="alert(this.value)">
<xsl:if test="(position() mod 2
= 0)">
<xsl:attribute
name="style">background-color: #FFF8C6</xsl:attribute>
</xsl:if>
<xsl:copy-of select="req" />
</textarea>
</xsl:if>
</td>
<td>
<textarea rows="$ROWS" cols="$COLS" >
<xsl:if test="(position() mod 2 = 0)">
<xsl:attribute
name="style">background-color: #FFF8C6</xsl:attribute>
</xsl:if>
<xsl:copy-of
select="exp_resp" />
</textarea>
</td>
<td>
<textarea rows="$ROWS" cols="$COLS" >
<xsl:if test="(position() mod 2 = 0)">
<xsl:attribute
name="style">background-color: #FFF8C6</xsl:attribute>
</xsl:if>
<xsl:copy-of
select="resp" />
</textarea>
</td>
<td>
<xsl:choose>
<xsl:when
test="normalize-space(resp/fault)=normalize-space(exp_resp/fault)">
<xsl:call-template name="STATUS_DETECTION">
<xsl:with-param name="my-param" select="'S'" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="STATUS_DETECTION">
<xsl:with-param name="my-param" select="'F'" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
<xsl:variable name="result">
<xsl:for-each select="report/result">
<xsl:if
test="normalize-space(resp/fault)=normalize-space(exp_resp/fault)">
<xsl:call-template name="STATUS_DETECTION">
<xsl:with-param name="my-param" select="S" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="no-of-S" xmlns:exslt="http://exslt.org/common"
select="count(exslt:node-set($result)/img[contains(@src, 'success')])"
/>
<xsl:value-of select="$no-of-S" />
</table>
</body>
</html>
</xsl:template>
<xsl:template name="STATUS_DETECTION">
<xsl:param name="my-param" />
<xsl:choose>
<xsl:when test="$my-param='S'">
<xsl:text><img src="../img/success.png"/> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text><img src="../img/failure.png"/> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
On Thu, Mar 13, 2008 at 11:43 AM, Martin Honnen
<Martin(_dot_)Honnen(_at_)gmx(_dot_)de> wrote:
Senthilkumaravelan K wrote:
> Am passing my-param as 'S' .
> I understand that I need to do something like Micael Kay Suggested .
> How do I
> (a) process the input twice, once to produce the images, once to produce
the
> counts
>> (b) capture the output in a variable, and post-process it to count how
many
>> images of each kind are present
> Once I am doing it for displaying images and when I try the same for
> similar loop for count and it comes as zero.
> Please help me in here.
Please post a minimal but complete XML input sample and stylesheet, then
we can try to find the error.
--
Martin Honnen
http://JavaScript.FAQTs.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--