cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Pöhler <>
Subject XSL variable scope question
Date Mon, 14 Aug 2000 09:48:33 GMT

i try to transform a xsp:sql resultset to a simple bar-chart. I need to
scale the values from the query to the maximum height of the bar chart. I
think i need the maximum value existing in the resultset in every output
element to calculate the real height. I have a problem finding this maximum
value, and i think it is a problem of variable scope. 

The test in the loop header seems to use $maxvisits=0, in the loop-body the
$maxvists are OK. If there is any other solution to produce barcharts or
charts in general.

my (xsp-based) resultset:
<query countrows="2">
	<row rowpos="0">
	<row rowpos="1">
	<row rowpos="2">

my stylesheet:
	<xsl:template match="row">
		<xsl:element name="svg:rect"
			<xsl:attribute name="x"><xsl:value-of
select="number(./@rowpos)*round(360 div (../@countrows + 1))+20"
			<xsl:attribute name="width"><xsl:value-of
select="round(240 div (../@countrows + 1))" />pt</xsl:attribute>
			<!-- These attributes must be calculated, too -->
			<xsl:attribute name="height"><xsl:value-of
select="./visits" />pt</xsl:attribute>
			<xsl:attribute name="y"><xsl:value-of

	<xsl:template match="query">
		<xsl:variable name="maxvisits">0</xsl:variable>		
		<xsl:for-each select="./row">
			 view visits=<xsl:value-of select="visits" />
			 view maxvisits=<xsl:value-of select="$maxvisits" />
			<xsl:if test="number(visits)>number($maxvisits)">
				<!-- set the new maxvisits -->
name="$maxvisits"><xsl:value-of select="visits" /></xsl:variable>
				entering loop-body: maxvisits =
<xsl:value-of select="$maxvisits" />
			<xsl:with-param name="maxvisits"><xsl:value-of
select="$maxvisits" /></xsl:with-param>


Marco Pöhler
eprofessional GmbH
Friedensallee 50, 22765 Hamburg, GERMANY
fon: +49 (0)40 399 278-25, fax: +49 (0)40 399 278-78 ,

View raw message