[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic with XML/XSL
- From: Craig Patterson <craigdpatterson@hotmail.com>
- To: richard.ward@csfb.com, xml-dev@lists.xml.org
- Date: Tue, 12 Jun 2001 08:32:36 +0800
>How do I go about adding/subtracting etc. the values of two XML elements
>via XSL?
The XSL is potentially straight forward eg.
<xsl:value-of select="number(Element1) + number(Element2)"/>
However you are performing the arithmetic on a time value which must also
include rolling the accompanying date forward and backward. This makes the
whole process rather difficult.
Your best option may be to try to use a Java extension function assuming you
are in an environment where Java is available and your XSLT processor
supports the mechanism. The following XSLT from Michael Kay's XSLT
Programmers Reference gets the current date.
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://www.jclark.com/xt/java/java.util.Date">
<xsl:template match="/">
<html xsl:exclude-result-prefixes="date">
<body>
<p><xsl:value-of select="date:to-string(date:new())"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Regards,
Craig Patterson
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.