Page 1 of 1

sum function and formatting

Posted: Tue May 24, 2005 12:55 pm
by oandie
Hi there,

I am trying to sum some coordinates, afterwards I want to format them and display the issue.
I tried the following but it didn't work out.

Code: Select all

<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: Select all


(...)
<gml:pos>3480252.383 5889479.27</gml:pos>
<gml:pos>3480289.585 5889464.571</gml:pos>
(...)
On the display it says that it is not a number, so I used "number" to convert it but it didn't work as well.

Maybe somebody could give me a tip..

cheers

andy

additional information

Posted: Tue May 24, 2005 10:04 pm
by oandie
I forgot to say that I want to summarize the first coordinates with the leading 3 and then the second with the leading 5.

cheers

andy

Posted: Mon Jun 06, 2005 10:57 am
by george
Hi,
gml:pos[substring-before(.,' ')]
This selects the gml:pos nodes that have some content before a space character inside them, so it will not select the text that for the first number.

Best Regards,
George