OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arithmetic with XML/XSL



>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.