IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

XSLT/JavaScript issues Options · View
Robin
Posted: Saturday, October 21, 2017 10:07:37 AM
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
Phocus
Posted: Monday, November 27, 2017 7:38:46 AM
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.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.