[xsl] copy-of breaks javascript in CDATA sections

Subject: [xsl] copy-of breaks javascript in CDATA sections
From: Felix Nensa <nensa@xxxxxxxx>
Date: Sun, 25 Jan 2009 18:30:07 +0100

I have an XHTML document generated with XSLT (Saxon 9.1) where I need
to insert external third party XHTML fragments.
Basically I do sth. like:

  <xsl:variable name="frag" select="document('http://somehost/somepage.html') />
  <xsl:copy-of select="$frag//div[@id='someid']/div"/>

In some of the external fragments there is some ugly javascript looking like:

  <script type="text/javascript">/*<![CDATA[*/document.write('<script

When inserting the above via copy-of it gets written into the document like:

  <script type="text/javascript">/**/document.write('&lt;script

I know that there is nothing wrong from the XML parsers point of view
but do you see any chance of preventing it from escaping the script
tags inside the document.write()?
Unfortunately I have to take these fragments as they come and cannot
fix the problem there.
So what I am looking for is a workaround to insert these fragments via
XSLT without braking the javascript.
Any chance to solve that?

Kind regards,


Current Thread