Hi there,
Not to sure if this is the right group as I am unsure as to the cause of
the problem..Anyhowz let me know if this is OT.
I am using the php5 XML dom (libxslt) to transform xml documents into
xhtml. I have come into a slight problem though, when trying to use
CDATA sections in the xsl file to sep off javascript the resulting XHTML
also contains the actual CDATA tag.
Also if I don't use a CDATA tag in the Javascript the xslt processor used
in php seems to automatically add it in, and I am back to the problem of
the the resulting code containing the actual CDATA tag, which inturn
causes the javascript code to be invalid
XSL File snippet
----------------
<script language="javascript">
<![CDATA[
function confirmDelete()
{
if( confirm('Are you sure?')
{
document.msgList.submit();
}
}
]]>
</script>
The resulting XHTML looks exactly the same
------------------------------------------
<script language="javascript">
<![CDATA[
function confirmDelete()
{
if( confirm('Are you sure?')
{
document.msgList.submit();
}
}
]]>
</script>
resulting in client side errors because of invalid JS.
I was expecting:
<script language="javascript">
function confirmDelete()
{
if( confirm('Are you sure?')
{
document.msgList.submit();
}
}
</script>
Is this how CDATA sections are supposed to work? Everywhere I have looked
said this is the way to output Javascript, infact I can't NOT use CDATA
as (mentioned above) the PHP processor auto adds them for script
elements.
Does anyone have a clue where I am going wrong here?
Any help would be apreciated, thanks.