Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript with xlt formatting error

I'm using javascript to pad numbers in my xslt file. but when debugging I get an error saying.

Extension function parameters or return values which have Clr type 'ConcatString' are not supported.

How can I fix this?

xslt

<xsl:template name="padNumber">
    <xsl:param name="value"></xsl:param>
    <xsl:param name="length"></xsl:param>
    <xsl:value-of select="user:PadDigits($value,$length)"/>
  </xsl:template>

javascript

function PadDigits(n, totalDigits)
{
    n = n.toString();
    var pd = '';
    if (totalDigits &gt; n.length)
    {
        var i;
        for (i=0; i&lt;(totalDigits-n.length); i++)
        {
            pd += '0';
        }
    }
    pd = pd + n.toString();
    return pd;
}
like image 591
Antarr Byrd Avatar asked Mar 17 '26 01:03

Antarr Byrd


1 Answers

Change your PadDigits to return strings:

return "" + pd;
like image 88
sainiuc Avatar answered Mar 18 '26 14:03

sainiuc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!