I’m trying to use this script
function padNumber(num, len){
var str = ''+num;
while(str.length < len){
str = '0' + str;
}
return str;
}
in my xlst file but I get this error when trying to debug.
XslLoadException
—————- XSLT compile error.XmlException
———— Name cannot begin with the ‘ ‘ character, hexadecimal value 0x20. Line 522, position 27.
line 522 is
while(str.length < len){
Any suggestions?
For the sake of redability, you can also put the Javascript code within a CDATA section. In this case you don’t need to change the JS code.
However, the text in a CDATA section must not contain the string
"]]>". If so, this string must be split between two consecutive CDATA sections.I believe that it is not too-likely for a typical JS code to contain that string, but one must be aware of such possibility, regardless how slim it is.