You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Raber Chris <cp...@yahoo.com> on 2002/02/15 21:47:37 UTC
Fun with CDATA.
This is probably better asked to an XSLT forum, but
here goes. I am doing WEB clipping/transcoding using
jTidy & Xalan.
Source html gets fed into jTidy, resulting XHTML gets
fed into Xalan with a style sheet that does the web
clipping.
One of the challanges is handling script code. What I
did is enhance (hack) jTidy to wrap script code in
CDATA. This works fine unless the scipt code is also
wrapped in comments. Consider this block:
<script type="text/javascript" language="JavaScript">
<![CDATA[
<!--
var remote = null;
function rs(n,u,w,h) {
remote = window.open(u, n, 'width=' + w + ',height='
+ h +',resizable=yes,scrollbars=no');
if (remote != null) {
if (remote.opener == null)
remote.opener = self;
window.name = 'yilff';
remote.location.href = u;
}
}
function clickHandler(url)
{window.open(url,'mediaframe_window','toolbar=no,width=750,height=550,left=0,top=30,status=no,scrollbars=no,resizable=yes');}
//-->
]]>
</script>
When this is run through XSLT with an "identity copy"
template, the output is:
<script type="text/javascript" language="JavaScript"
xml:space="preserve">
<!--
var remote = null;
function rs(n,u,w,h) {
remote = window.open(u, n, 'width=' + w + ',height='
+ h +',resizable=yes,scrollbars=no');
if (remote != null) {
if (remote.opener == null)
remote.opener = self;
window.name = 'yilff';
remote.location.href = u;
}
}
function clickHandler(url)
{window.open(url,'mediaframe_window','toolbar=no,width=750,height=550,left=0,top=30,status=no,scrollbars=no,resizable=yes');}
//-->
</script>
And the browser shows an error on the line where the
'<' in the comment has been changed to <.
Any suggestions on how to get CDATA to output < and >
instead of < and > here? Or maybe a better
approach?
TIA,
-Chris.
__________________________________________________
Do You Yahoo!?
Got something to say? Say it better with Yahoo! Video Mail
http://mail.yahoo.com