Subject: [xsl] Performance problem From: "ficfic m" <ficfic@xxxxxxxxxxx> Date: Tue, 15 Feb 2005 13:32:26 +0200 |
<data> <item name=abc timestamp=2004-10-11T15:49:31> <bytes> 1062207488</bytes> </item> <item name=efd timestamp=2004-10-13T15:44:31> <bytes>23457</bytes> </item> .... </data>
I process the timestamp field as follow: INPUT -> 2004-10-11T15:49:31 OUTPUT -> 2004-Oct-11 15:49:31
I process the bytes field as follow: INPUT -> 1048576 OUTPUT -> 1,013MB
My xsl file: <xsl:template match="data"> <table border="1" cellspacing="0" cellpadding="3"> <tr> <th>Name</th> <th>Bytes</th> <th>Time Stamp</th> </tr> <xsl:for-each select="item"> <tr> <td nowrap="1"> <xsl:value-of select="@name"/> </td> <td> <xsl:choose> <xsl:when test="bytes"> <xsl:call-template name="format-bytes"> <xsl:with-param name="bytes_cnt" select="bytes"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> </td> <td nowrap="1"> <xsl:call-template name="format-date"> <xsl:with-param name="date-time" select="@timestamp"/> </xsl:call-template> </td> </tr> </xsl:for-each> </table> </xsl:template>
<!-- prints-out bytes count --> <xsl:variable name="Mega" select="1024 * 1024"/> <xsl:variable name="Giga" select="1024 * $Mega"/>
<xsl:template name="format-date"> <xsl:param name="date-time" select="."/> <xsl:choose> <xsl:when test="$date-time"> <xsl:value-of select="substring($date-time, 9 ,2)"/> <xsl:text>-</xsl:text> <xsl:variable name="month" select="substring($date-time, 6 ,2)"/> <xsl:choose> <xsl:when test="$month = 1">Jan</xsl:when> <xsl:when test="$month = 2">Feb</xsl:when> <xsl:when test="$month = 3">Mar</xsl:when> <xsl:when test="$month = 4">Apr</xsl:when> <xsl:when test="$month = 5">May</xsl:when> <xsl:when test="$month = 6">Jun</xsl:when> <xsl:when test="$month = 7">Jul</xsl:when> <xsl:when test="$month = 8">Aug</xsl:when> <xsl:when test="$month = 9">Sen</xsl:when> <xsl:when test="$month = 10">Oct</xsl:when> <xsl:when test="$month = 11">Nov</xsl:when> <xsl:when test="$month = 12">Dec</xsl:when> </xsl:choose> <xsl:text>-</xsl:text> <xsl:value-of select="substring($date-time, 3 ,2)"/> <xsl:text> </xsl:text> <xsl:value-of select="substring($date-time, 12 ,8)"/> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template>
Best Regards, ficfic
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Bug in Schema for XSLT 2., Dimitre Novatchev | Thread | Re: [xsl] Performance problem, David Carlisle |
RE: [xsl] Bug in Schema for XSLT 2., Michael Kay | Date | Re: [xsl] Performance problem, David Carlisle |
Month |