For HTML with embedded Javascript, I need to output > as > rather than as >
In XSLT I’m doing
<xsl:character-map name="a"> <!-- This charmap is necessary for embedding CSS that contains '>' combinators --> <xsl:output-character character=">" string=">"/> </xsl:character-map>
and
<xsl:output method="xhtml" indent="no" encoding="UTF-8" use-character-maps="a" omit-xml-declaration="no" html-version="5.0" doctype-public="" doctype-system=""/>
In RESTXQ I tried the following:
I created a document called html-charmap.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?> <serialization-parameters xmlns="http://www.w3.org/2010/xslt-xquery-serialization"> <use-character-maps> <character-map character=">" map-string=">"/> </use-character-maps> </serialization-parameters>
It resides in the directory where the xqm is located. The xqm contains this function:
module namespace my = 'my';
declare %rest:GET %rest:path("/charmap/test") %output:method("xhtml") %output:html-version("5.0") %output:parameter-document("html-charmap.xml") %rest:produces("text/html") function my:html() { <html> <head> <title>Charmap Test</title> <meta charset="UTF-8"/> <script> alert('You are in ' + (document.compatMode==='CSS1Compat'?'Standards':'Quirks') + ' mode and 1
0 is ' + (1 > 0)</script>
</head> <body> <h1>Charmap Test</h1> <p>></p> <p>></p> </body> </html> };
When I retrieve /charmap/test, all > characters are still escaped as >
When I change %output:parameter-document to %output:parameter-document("tml-charmap.xml"), BaseX doesn’t complain about the missing parameter document.
What am I doing wrong?
In XSLT 3 with Saxon, I can also do
<xsl:output method="xhtml" indent="yes" include-content-type="no" encoding="UTF-8" parameter-document="html-charmap.xml" omit-xml-declaration="no" html-version="5.0" doctype-public="" doctype-system=""/>
and this will use html-charmap.xml and it will complain when it’s the wrong file name.
Gerrit