Increase y value of SVG drawing using XSLT iteration
I asked a similar question earlier. I have made some changes to the code,
but am still stuck.
I have part of an XSLT like this:
<xsl:variable name="y" select="0" />
<xsl:if test="units_display='true'">
<xsl:call-template name="DisplayBox">
<xsl:with-param name="current_y" select="$y" />
<xsl:with-param name="value" select="units" />
<xsl:with-param name="text" select="'Units'" />
</xsl:call-template>
</xsl:if>
<xsl:if test="sensor_display='true'">
<xsl:call-template name="DisplayBox">
<xsl:with-param name="current_y" select="$y" />
<xsl:with-param name="value" select="sensor" />
<xsl:with-param name="text" select="'Type'" />
</xsl:call-template>
</xsl:if>
<xsl:if test="offset_display='true'">
<xsl:call-template name="DisplayBox">
<xsl:with-param name="current_y" select="$y" />
<xsl:with-param name="value" select="offset" />
<xsl:with-param name="text" select="'Offset'" />
</xsl:call-template>
</xsl:if>
My call-template is like this:
<xsl:template name="DisplayBox">
<xsl:param name="current_y" />
<xsl:param name="value" />
<xsl:param name="text" />
<rect x="20" y="{150 + $current_y}" width="220" height="20"
fill="#FFFFFF" stroke="black" stroke-width="1" />
<text x="25" y="{168 + $current_y}" font-family="arial" font-size="20px"
fill="black">
<xsl:value-of select="$value"/>
</text>
<line x1="90" y1="{150 + $current_y}" x2="90" y2="{170 + $current_y}"
stroke="black" stroke-width="1" />
<text x="95" y="{168 + $current_y}" font-family="arial" font-size="20px"
fill="black"><xsl:value-of select="$text" /></text>
</xsl:template>
I can't work out how to increase the value of current_y depending on
whether the if statements are true or not. E,g, if a statement is true,
the y value needs to be increased by 20, but not if the statement is
false.
So the output could be empty if all 3 statements are false or could be any
of these permutations:
Any help would be greatly appreciated.
No comments:
Post a Comment