![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Date comparison in xslt [Thread Next] Re: Date comparison in xsltTo: 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,
'-','')) >
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/
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
