[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Boolean XPath Expression and sum

Subject: RE: Boolean XPath Expression and sum
From: "John Wang" <jwang@xxxxxxxxxxx>
Date: Wed, 9 May 2001 16:45:57 -0500
xpath expression 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[.!=&apos;N/A&apos;])"/>
			</sum>
		</abuncha>
	</xsl:template>
	<xsl:template match="thing[.!=&apos;N/A&apos;]">
		<xsl:copy-of select="."/>
	</xsl:template>
	<xsl:template match="thing[.=&apos;N/A&apos;]">
	</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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.