2 Replies Latest reply on Oct 31, 2018 3:04 PM by Fofana

    Calculating a sum of rounded numbers

    Fofana

      Hi, I am new to XSL and I have this template customized to round seconds:

       

      <xsl:template name="getRoundedValue">

            <xsl:param name="valueToRound" />

                <xsl:choose>

                  <xsl:when test="$valueToRound = 0">

                     0

                  </xsl:when>

                  <xsl:otherwise>

                       <xsl:choose>

                          <xsl:when test="not($valueToRound > number(substring-before($varMinIncrement,'|')))">

                                    <xsl:value-of select="number(substring-before($varMinIncrement,'|'))" />

                          </xsl:when>

                     <xsl:otherwise>

                     <xsl:value-of select="(floor(number($valueToRound) div number(substring-after($varMinIncrement,'|'))) +1) * number(substring-after($varMinIncrement,'|'))" />

                     </xsl:otherwise>

                 </xsl:choose>

        </xsl:otherwise>

      </xsl:choose>

      </xsl:template>

       

      I call this template by passing a value like this:

       

      <xsl:call-template name="getRoundedValue">

           <xsl:with-param name="valueToRound">

                <xsl:value-of select="unRoundedQuantity" />

           </xsl:with-param>

      </xsl:call-template>

       

      Now I have to round this complex entries and make a sum on the rounded values and don't get the exact syntax for that:

       

      <xsl:variable name="varAmountNotZero">

         <xsl:value-of select="sum(//lineItems[subscriptionAttributes[parameter='CATEGORY_NAME_FR']/value = $mainCategory and ../../../accountId = $accID]/usageLineItem[uomName='Seconde']/lstLineItems[chargeCategoryDescription = $currentDestination and eventAttributes/eventAttribute/EVENT_TYPE = $TypeOfCalling and amount &gt; 0 and eventAttributes/eventAttribute/RATED_QUANTITY &gt; 0]/eventAttributes/eventAttribute/RATED_QUANTITY)" />

      </xsl:variable>

       

      Thanks for any help