xsl-list
[Top] [All Lists]

[xsl] copy-of breaks javascript in CDATA sections

2009-01-25 12:30:35
Hi,

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[(_at_)id='someid']/div"/>

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

  <script type="text/javascript">/*<![CDATA[*/document.write('<script
type="text/javascript"
src="http://somehost/somescript.js";></script>');/*]]>*/</script>

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

  <script type="text/javascript">/**/document.write('&lt;script
type="text/javascript"
src="http://somehost/somescript.js"&gt;&lt;\/script&gt;');/**/</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,

Felix

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>