sum function and formatting

Here should go questions about transforming XML with XSLT and FOP.
oandie
Posts: 5
Joined: Thu May 12, 2005 4:31 pm

sum function and formatting

Post by oandie » Tue May 24, 2005 12:55 pm

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

oandie
Posts: 5
Joined: Thu May 12, 2005 4:31 pm

additional information

Post by oandie » Tue May 24, 2005 10:04 pm

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

george
Site Admin
Posts: 2100
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Mon Jun 06, 2005 10:57 am

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

Post Reply