Subject: RE: [xsl] Boolean XPath Expression and sum From: "Clapham, Paul" <pclapham@xxxxxxxxxxxxx> Date: Wed, 9 May 2001 15:35:00 -0700 |
11=1+2+3+5, so that's what I would have expected. If you'd used count() instead of sum() I would have expected 4. PC2 -----Original Message----- From: John Wang [mailto:jwang@xxxxxxxxxxx] Sent: May 9, 2001 14:46 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Boolean XPath Expression and sum Here is my XML <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="notAvailable.xsl"?> <abuncha> <thing>1</thing> <thing>2</thing> <thing>N/A</thing> <thing>3</thing> <thing>5</thing> <thing>N/A</thing> </abuncha> Here is my XSL <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/"> <abuncha> <xsl:apply-templates/> <sum> <xsl:value-of select="sum(//thing[.!='N/A'])"/> </sum> </abuncha> </xsl:template> <xsl:template match="thing[.!='N/A']"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="thing[.='N/A']"> </xsl:template> </xsl:stylesheet> Here is what I expected: <?xml version="1.0"?> <abuncha> <thing>1</thing> <thing>2</thing> <thing>3</thing> <thing>5</thing> <sum>4</sum> </abuncha> Here is what I actually got: <?xml version="1.0"?> <abuncha> <thing>1</thing> <thing>2</thing> <thing>3</thing> <thing>5</thing> <sum>11</sum> </abuncha> my question is: Where does the 11 come from? Thanks in advance. -John XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Boolean XPath Expression , Francis Norton | Thread | [xsl] encoding problem, HeHangjun |
RE: [xsl] Boolean XPath Expression , John Wang | Date | Re: [xsl] Boolean XPath Expression , Francis Norton |
Month |