I want to store XSLT code in a HTML file like that:
<script id="xsltCode" type="text/xml">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
...
<script>...</script>
...
</xsl:stylesheet>
</script>
As you can see, the problem I have is caused by the <script>
tag inside the XSLT code. What is the simplest solution to escape it?
Thank you for your help.
Throwing arbitrary tags in there isn't really advisable. If you can't load the XSLT separately, alternatives are:
<
needs to be escaped with <
&
or a numeric escape like
, turn those into &amp;
and &#10;
.In any case, leave out the XML declaration. It doesn't make sense here and could even cause problems.