sum function and formatting

Here should go questions about transforming XML with XSLT and FOP.
Posts: 5

sum function and formatting

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"/>

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..


Posts: 5

additional information

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.


Site Admin
Posts: 2100

Mon Jun 06, 2005 10:57 am


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,

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 2 guests