A list of numbers corresponding to the factors is defined with this string : 24850973612485097361
The number is flipped and is multiplied for each number with the factor corresponding to its position, 0 corresponding to 10 and all cumulated
For example, for and order having the number 28200703:
The number is flipped giving 30700282
Using the factor string 24850973612485097361 for the corresponding size for the number, the calculation is done as following:
3 x 2 = 6
0 x 4 = 0
7 x 8 = 56
0 x 5 = 0
0 x 10 = 0
2 x 9 = 18
8 x 7 = 56
2 x 3 = 6
Cumulated: 142
Try it this way:
<xsl:template name="process">
<xsl:param name="number"/>
<xsl:param name="factors" select="'24850973612485097361'"/>
<xsl:param name="accumulated" select="0"/>
<xsl:choose>
<xsl:when test="$number">
<xsl:variable name="n" select="$number mod 10" />
<xsl:variable name="m" select="substring($factors, 1, 1)" />
<xsl:call-template name="process">
<xsl:with-param name="number" select="floor($number div 10)"/>
<xsl:with-param name="factors" select="substring($factors, 2)"/>
<xsl:with-param name="accumulated" select="$accumulated + $n * $m" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$accumulated"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Example of call:
<xsl:call-template name="process">
<xsl:with-param name="number" select="28200703"/>
</xsl:call-template>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.