|
Rank: Newbie
Joined: 10/21/2017 Posts: 1 Location: The Netherlands
|
Hello!
Im trying to implement JavaScript in my XSLT-document. Most of the time it works fine, but I just tried a simple console.log("test"); and it gives me the error-message:
"This file is not valid! If you save the file in its current state, other XML processors may have a problem opening the file."
This is for sure the cause of the problem because if I remove the console.log it works fine. How come?
Code: https://pastebin.com/yaqndNF9
Best regards, Robin
|
|
Rank: Member
Joined: 10/29/2002 Posts: 6 Location: MU
|
Hi, The file is invalid because the 'console' variable in the msxsl script is not declared. Not sure what you want to achieve with your javascript code. As it is it will be compiled and made available during the xslt transformation. If you want the javascript to be included in the generated html file then you must create a <script> element. If you want to wrap with //<![CDATA[ ... //]]> you can add a special character with entity ref before and after the script code and use character maps to remap to //<![CDATA[ and //]]>. Also note that the exclude-result-prefixes applies to the descendant literal elements - so putting it on the xsl:output element will not have the desired effect - better would be to have it on the xsl:stylesheet. Hope this helps.
|
|
guest |