This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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[.!=&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@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Ingo Schildmann
Sent: Wednesday, May 09, 2001 10:03 AM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] 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@web.de

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]