[xsl] sum function

Subject: [xsl] sum function
From: "Andreas Schnabl" <Oandie@xxxxxxx>
Date: Sun, 29 May 2005 12:35:30 +0200 (MEST)
Hi there,

I am trying to sum some coordinates, afterwards I want to format them and
display the issue. What I need is to summarize the first coordinates with
the leading 3 and then the second with the leading 5. 
I tried the following but it didn't work out. It seems that the processor
don't use the "substring-before"- elment, cause if I change it into
"substring- after I got the same display...
Here comes the code so far: 


<xsl:template name="x">
<xsl:variable name="x_sum"
select="sum(xplan:Position/gml:Polygon/gml:exterior/gml:LinearRing/gml:Pos[substring-before(.,'
')])"/>
<xsl:variable name="x_count"
select="count(xplan:Position/gml:Polygon/gml:exterior/gml:LinearRing/gml:Pos)"/>
<xsl:variable name="x_format" select="format-number($x_sum, '#')"/>"
<xsl:variable name="x_rw" select="3400000"/>
<xsl:variable name="x_ges" select="$x_rw*$x_count"/>
<xsl:variable name="x_ges1" select="$x_format - $x_ges"/>
<xsl:variable name="x_ges2" select="$x_ges1 div $x_count"/>
<xsl:value-of select="$x_sum"/>

</xsl:template>


The source looks like this:

Code:

(...)
<gml:Pos>3480252.383 5889479.27</gml:Pos>
<gml:Pos>3480289.585 5889464.571</gml:Pos>
(...)


I changed the position of "substring" in the XPath expression like this:

 

<xsl:variable name="x_sum"
select="sum(substring-before(xplan:Position/gml:Polygon/gml:exterior/gml:LinearRing/gml:Pos,'
'))"/>

 

But then I got only the first value.
What I need is both of the values inside the gml:Pos element, but apart from
each other. In the first step I would count all the values which a are
before the blank and in the second the values after the blank and sum them
up as well. 
I need to get the balance point of the values.

 
I don't know if it depends maybe on the XSLT- processor I need. I am working
with XMLSpy, 2005 professinal edition and I use the built in processor.
 

cheers

andy


-- 
--------------------------------------------
GERMANY
Andreas Schnabl
Geibelstrasse 2a
76185 Karlsruhe
Tel.:0721- 4903793
Mob.: 0170-1590394
--------------------------------------------

5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse f|r Mail, Message, More +++

Current Thread