Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Date comparison in xslt

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 7/10/2007 2:04:00 PM

tokyo12@g... wrote:

> I want the sum() only to run on the field called quant on records
> where the "todaydate" > June 1.  So I tried:
> 
> <xsl:value-of select="format-
> number(sum($prod[number(translate(todaydate/@val, '-','')) >
> number(translate('2007-06-01', '-', '')) ]/quant/
> @val),'###,###,###,##0')"/>
> 
> Is that totally wrong?  It doesnt print anything!

I am not sure where the problem is. I have tried this example input

<root>
   <prod>
     <todaydate val="2006-01-01"/>
     <quant val="2"/>
   </prod>
   <prod>
     <todaydate val="2007-01-01"/>
     <quant val="2"/>
   </prod>
   <prod>
     <todaydate val="2007-07-01"/>
     <quant val="2"/>
   </prod>
   <prod>
     <todaydate val="2007-06-02"/>
     <quant val="2"/>
   </prod>
</root>

with this stylesheet

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

   <xsl:template match="/">
     <html lang="en">
       <head>
         <title>Example</title>
       </head>
       <body>
         <xsl:variable name="prod" select="root/prod"/>
         <xsl:value-of select="format-number(
                                 sum(
                                   $prod[
                                     number(translate(todaydate/@val, 
'-','')) &gt;
                                     number(translate('2007-06-01', '-', 
''))
                                   ]/quant/@val
                                 ),'###,###,###,##0'
                               )"/>
       </body>
     </html>
   </xsl:template>

</xsl:stylesheet>

and the result with MSXML 6 is

<html lang="en">
<head>
<META http-equiv="Content-Type" content="text/html">
<title>Example</title>
</head>
<body>4</body>
</html>

which is the correct result.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent