This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: count(arvosana) with if condition


The following will help you...

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<xsl:if test="count(//arvosana[text()&lt;3])">
add text..
the no of arvosana with value less than 3 are <xsl:value-of select="count(//arvosana[text()&lt;3])"/>

</xsl:if>
</xsl:template>
</xsl:stylesheet>
This prints the no of arvosana with values less than 3.

HTH

From: Jarkko.Moilanen@uta.fi
Reply-To: xsl-list@lists.mulberrytech.com
To: xsl-list <xsl-list@lists.mulberrytech.com>
Subject: [xsl] count(arvosana) with if condition
Date: Tue, 25 Jun 2002 14:14:57 +0300 (EEST)

Hi!

I´m  trying to count the number of such elements where value is 3.
And if the value is lesser than 3 it should insert xsl:text.
I´m doing it by using variable (name=3), but it´s not working. Dunno what
I´m doing wrong.

XML-FILE:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<Document title="Keskiarvot kurssien arvosanoista">
<P1Kurssi koodi="P1" name="P1 Johdatus vuorovaikutteiseen mediaan"
link="http://hypst09.uta.fi:6969/cgi-bin/html?P1";>

<P1Arvosanat>
  <arvosana>3</arvosana>
  <arvosana>2.25</arvosana>
  <arvosana>1.75</arvosana>
  <arvosana>1.25</arvosana>
  <arvosana>2.75</arvosana>
</P1Arvosanat>
</P1Kurssi>
</Document>


XSL-FILE (part of it):

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";><xsl:output method="html"
encoding="iso-8859-1" indent="yes" />
	<xsl:template match="Document">
<html>
<table>
<tr bgcolor="white">
<td width="80">
<p><font face="Verdana" size="2">
<xsl:value-of select="$3" />

</font></p></td>
</tr>
</table>
</html>
</xsl:template>

<xsl:variable name="3">
	<xsl:for-each select="P1Kurssi/P1Arvosanat">
	<xsl:choose>
	<xsl:when test="arvosana='3'">
	<xsl:value-of select="count(arvosana)" />
	</xsl:when>
	<xsl:otherwise>
	<xsl:text> - </xsl:text>
	</xsl:otherwise>
	</xsl:choose>
	</xsl:for-each>
</xsl:variable>
</xsl:stylesheet>

******************************************************************
Jarkko Moilanen         *You are wise, witty, and wonderful,     *
Researcher/ ITCM        *but you spend too much time             *
jm60697@uta.fi          *reading this sort of trash.             *
www.uta.fi/~jm60697     *                                        *
GSM: +358 50 3766 927   *                                        *
******************************************************************
* ITCM | Information Technology and Crisis Management            *
* http://www.itcm.org                                            *
******************************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]