Subject: [xsl] Addition problem From: Sandeep Jain <sandeep@xxxxxxxxxxx> Date: Tue, 11 Feb 2003 17:35:00 +0400 |
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> </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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Debugging XSL with XML Sp, Jim Melton | Thread | Re: [xsl] Addition problem, Jeni Tennison |
RE: [xsl] Debugging XSL with XML Sp, dave beattie | Date | RE: [xsl] Debugging XSL with XML Sp, bryan |
Month |