Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Here is a solution</strong>, which combines the conversion of hex to decimal values as present in <a href="http://fxsl.sf.net" rel="nofollow noreferrer"><strong>FXSL</strong></a> with a <strong><a href="http://www.stylusstudio.com/xsllist/200303/post70360.html" rel="nofollow noreferrer">borrowed non-FXSL template</a></strong> for convertion of decimal to hex.</p> <p><strong>This transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:f="http://fxsl.sf.net/" xmlns:func-transform2="f:func-transform2" exclude-result-prefixes="xsl f func-transform2" &gt; &lt;xsl:import href="transform-and-sum.xsl"/&gt; &lt;xsl:import href="hex-to-decimal.xsl"/&gt; &lt;!-- to be applied on testTransform-and-sum2.xml --&gt; &lt;xsl:output method="text"/&gt; &lt;func-transform2:func-transform2/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:variable name="vdecSum"&gt; &lt;xsl:call-template name="transform-and-sum"&gt; &lt;xsl:with-param name="pFuncTransform" select="document('')/*/func-transform2:*[1]"/&gt; &lt;xsl:with-param name="pList" select="/*/*"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:call-template name="toHex"&gt; &lt;xsl:with-param name="decimalNumber" select="$vdecSum"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; &lt;xsl:template match="func-transform2:*" mode="f:FXSL"&gt; &lt;xsl:param name="arg1" select="0"/&gt; &lt;xsl:call-template name="hex-to-decimal"&gt; &lt;xsl:with-param name="pxNumber" select="$arg1"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; &lt;xsl:template name="toHex"&gt; &lt;xsl:param name="decimalNumber" /&gt; &lt;xsl:if test="$decimalNumber &gt;= 16"&gt; &lt;xsl:call-template name="toHex"&gt; &lt;xsl:with-param name="decimalNumber" select="floor($decimalNumber div 16)" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;xsl:value-of select="substring($hexDigits, ($decimalNumber mod 16) + 1, 1)" /&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on this XML document</strong>:</p> <pre><code>&lt;t&gt; &lt;hexNum&gt;1001&lt;/hexNum&gt; &lt;hexNum&gt;0FA3&lt;/hexNum&gt; &lt;/t&gt; </code></pre> <p><strong>produces the correct, wanted result</strong>:</p> <pre><code>1FA4 </code></pre>
 

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