[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: 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 -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Ingo Schildmann Sent: Wednesday, May 09, 2001 10:03 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Boolean XPath Expression and sum On Wednesday 09 May 2001 16:46, you wrote: > Hello List, > I was wondering if anyone knew a way to either > 1. Include a test for content within a template match statement, something > like: > <xsl:template match="abuncha/thing !='N/A'"> XPath's predicates are doing this job: <xsl:template match="abundcha/thing[. !='N/A']"> > OR > 2. Include a test for content within sum() , something like: > <xsl:value-of select="sum(//thing !='N/A')"/> <xsl:value-of select="sum(//thing[. != 'N/A']"/> Ingo -- Ingo Schildmann ingoschi@xxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|