Note that there are some explanatory texts on larger screens.

plurals
  1. POxslt V1.0 - subtemplate with recursive loop returns empty value
    primarykey
    data
    text
    <p>I'm trying to get the highest value of the sum of the childs of each cluster.</p> <ul> <li><p>cluster1 : 10 + 20 = 30</p></li> <li><p>cluster2 : 20 + 30 = 50 --> 50 is highest value</p></li> </ul> <p><strong>Problem</strong>: The return value of the subtemplate is "".<br> why? The variable tempMax is getting a <em>node</em> with my number in it instead of just a number.</p> <pre><code>$tempMax = {Dimension:[1]} + [1] = / + + node()[1] = 50 </code></pre> <p>How can I fix this? (xslt v1.0). </p> <hr> <p>xml:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;column-chart-stacked-full&gt; &lt;clusters&gt; &lt;cluster number="1"&gt; &lt;bar&gt; &lt;value&gt;10&lt;/value&gt; &lt;/bar&gt; &lt;bar&gt; &lt;value&gt;20&lt;/value&gt; &lt;/bar&gt; &lt;/cluster&gt; &lt;cluster number="2"&gt; &lt;bar&gt; &lt;value&gt;20&lt;/value&gt; &lt;/bar&gt; &lt;bar&gt; &lt;value&gt;30&lt;/value&gt; &lt;/bar&gt; &lt;/cluster&gt; &lt;/clusters&gt; &lt;/column-chart-stacked-full&gt; </code></pre> <p>my xsl:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;xsl:variable name="highestClusterVal"&gt; &lt;xsl:call-template name="findMaxClusterVal"/&gt; &lt;/xsl:variable&gt; &lt;xsl:template name="findMaxClusterVal"&gt; &lt;xsl:param name="count" select="count(column-chart-stacked- full/clusters/cluster)"/&gt; &lt;xsl:param name="limit" select="$count"/&gt; &lt;xsl:param name="max" select="0"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$count &amp;gt; 0"&gt; &lt;xsl:variable name ="barSum" select="sum(column-chart-stacked-full/clusters/cluster[$count]/bar/value)"/&gt; &lt;xsl:variable name="tempMax"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$max &amp;lt; $barSum"&gt; &lt;xsl:value-of select="$barSum"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$max"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:variable&gt; &lt;!-- recursive loop --&gt; &lt;xsl:call-template name="findMaxClusterVal"&gt; &lt;xsl:with-param name="count" select="$count - 1"/&gt; &lt;xsl:with-param name="limit" select="$limit"/&gt; &lt;xsl:with-param name="max" select="$tempMax"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;!-- return max value --&gt; &lt;xsl:value-of select="$max"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>return of $max</p> <pre><code>$max = {Dimension:[1]} + [1] = / + + node()[1] = 50 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload