[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Addition problem

Subject: Addition problem
From: Sandeep Jain <sandeep@xxxxxxxxxxx>
Date: Tue, 11 Feb 2003 17:35:00 +0400
addition problem
Hello Guys , 

	I am very new to XSL , Can anyone give a example as to how to add
the values or incrment the values in XSL .
	I tried a lot, but I just couldnt get it ..
	
	Here is my XML Doc and XSL DOC  , All I want to do is to add the
size of all the Documents. I know with 'Sum' Can be used as straight
function , but I want to achieve the same with my logic as  I have to I have
to do increment/decrements and other manipulations based on conditions. Also
it would be great if you can guide me as to how to include javascript in xsl
document.

Thanks in Advance

Regards
Sandeep




XML
---------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<mynode>
	 <llnode created='2002-10-28T11:37:40' createdby='1000'
createdbyname='Admin' id='9567' modified='2002-10-28T12:00:45'
name='CreditCardFormTemplate' objname='Form Template' objtype='230'
ownedby='1000' ownedbyname='Admin' parentid='2000' size='1391'
versionnum='3'>
    </llnode>
    <llnode created='2002-10-28T12:02:17' createdby='1000'
createdbyname='Admin' id='9667' modified='2002-10-28T12:03:09' name='New
Form Template' objname='Form Template' objtype='230' ownedby='1000'
ownedbyname='Admin' parentid='2000' size='420' versionnum='2'>
    </llnode>
    <llnode created='2002-10-28T12:04:26' createdby='1000'
createdbyname='Admin' id='9676' modified='2002-10-28T12:04:53' name='New
Form Template 2' objname='Form Template' objtype='280' ownedby='1000'
ownedbyname='Admin' parentid='2000' size='411' versionnum='1'>
    </llnode>
    <llnode created='2001-11-07T20:12:19' createdby='1000'
createdbyname='Admin' id='11638' mimetype='text/plain'
modified='2001-11-07T20:12:20' name='Performance Appraisal Map.map'
objname='Document' objtype='144' ownedby='1000' ownedbyname='Admin'
parentid='2000' size='4668' versionnum='1'>
    </llnode>
    <llnode created='2001-11-08T11:02:08' createdby='1000'
createdbyname='Admin' id='11968' modified='2003-01-07T12:34:16' name='sandy'
objname='Folder' objtype='144' ownedby='1000' ownedbyname='Admin'
parentid='2000' size='62'>
    </llnode>
    <llnode created='2001-11-08T11:02:22' createdby='1000'
createdbyname='Admin' id='11969' modified='2001-11-08T11:06:01' name='frank'
objname='Folder' objtype='144' ownedby='1000' ownedbyname='Admin'
parentid='2000' size='1'>
    </llnode>
</mynode>



XSL
----------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="NumberOfRows" select="count(//mynode/llnode)" />
<xsl:param name="SumOfRows" select="0" />
<xsl:template match="/">

<html>
<head>
</head>
<body >
<table border="1" width="100%">
<tr bgcolor="#bcdea"><th>ODD/Even </th><th>Document Name
</th><th>Functions</th><th>Created By</th> <th>Modified On
</th><th>Size</th></tr>

	<xsl:for-each select="mynode/llnode">
	<xsl:sort select="@name" order="descending" />
	<tr>
		<xsl:choose> 
		  <xsl:when test="position() mod 2"> 		    
			  <td><xsl:text>Even</xsl:text></td>
		  </xsl:when> 
		  <xsl:otherwise>
			  <td><xsl:text>ODD</xsl:text></td>
		  </xsl:otherwise>
		</xsl:choose> 


		<td  align="left" ><xsl:value-of select="@name"/></td>
		<td align="center"><IMG
SRC="http://localhost/LLPersonalsupport/webdoc/actions.gif" NAME="x11968"
BORDER="0" ALT="Functions"></IMG></td>
		<td align="center" ><xsl:value-of
select="@createdbyname"/></td>
		<td align="center" ><xsl:value-of select="@modified"/></td>
		<td>
			<xsl:choose>
				<xsl:when  test  =  " @size = ''">	
					<xsl:text>&#xA0;</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@size"/>	
				</xsl:otherwise>
			</xsl:choose>
		</td>
		<xsl:call-template name="function"> 
			    <xsl:with-param name="addValue" select="@size"/>

		</xsl:call-template>



	</tr>	
	</xsl:for-each>	
	<tr>
	    <td colspan='6'>
		<B><xsl:text>The Number Of Documents = </xsl:text>
		<xsl:value-of select="$NumberOfRows" /></B>
	    </td>
	</tr>
</table>
</body>
</html>
</xsl:template>

<xsl:template name="function"> 
     <xsl:param name="addValue"/>   
     <xsl:with-param name="SumOfRows">
	  <xsl:value-of select="$SumOfRows + addValue"/>
     </xsl:with-param>
</xsl:template>

</xsl:stylesheet>

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.