Subject: XSLT containing javascript code with '<'
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Sat, 11 Feb 2012 20:58:51 +0100
|
This is the essential part of what I have (after some research):
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method = "html" cdata-section-elements="script" encoding =
"UTF-8" indent = "yes"/>
<xsl:template match="/">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head>
<script type="text/javascript"><![CDATA[
function restore(){
if( 1 < 10 ) alert("x"); // something else in reality.
}
]]></script>
<title>X</title>
</head>
<body>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
However, the output from Saxon 9 (latest) contains
if( 1 < 10 ) alert("x");
which Chrome refuses to accept as correct javascript, and I think it is right.
Omitting cdata-section-elements="script" doesn't alter anything, of course.
Any ideas?
Wolfgang
|