jquery script in footer

healdp
Posts: 4
Joined: Thu Dec 08, 2011 2:39 am

jquery script in footer

Post by healdp » Thu Dec 08, 2011 2:53 am

Hi,

Using Oxygen 12 or 13, I'm trying to have my DITA > XHTML transform include some JQuery javascript code. I thought the simplest way would be to use the args.ftr (or hdr) to inject the code. It has to be well-formed, so I've tried various permutations of CDATA tags. Surprisingly, the CDATA tags are written as-is to the XHTML, which obviously isn't what I want, and seems very odd.

I've tried things like:

Code: Select all

<script language="JavaScript">
<![CDATA[
$(document).ready(function(){

... some jquery code ...

});
]]>
</script>
I thought the contents of the CDATA tags would be written to the output, which it is, but includes the CDATA tags themselves! Preceding the CDATA tags with // seems to make no difference.

Any ideas? I suspect the problem is staring me in the face...

Thanks!

Pete

Radu
Posts: 7019
Joined: Fri Jul 09, 2004 5:18 pm

Re: jquery script in footer

Post by Radu » Thu Dec 08, 2011 2:03 pm

Hi Pete,

Oxygen uses the DITA Open Toolkit to publish DITA content to various output sources.

I do not quite understand the problem.
So from what I've tested if I set the parameter args.hdr to a small file containing your sample code (with CDATA tags) and transform, the final HTML output will contain the <script> but without the CDATA markers. I tested this with both an Oxygen 13.1 and 12.2.
From your post I understand exactly the opposite.
Did you add any customizations to the DITA OT or are you using a custom DITA OT installation?

The XSLT code which is responsible for adding the header and footer files to the XHTML output is in this file:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/xsl/xslhtml/dita2htmlImpl.xsl

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

healdp
Posts: 4
Joined: Thu Dec 08, 2011 2:39 am

Re: jquery script in footer

Post by healdp » Fri Dec 09, 2011 11:59 pm

Thanks Radu,

My problem turned out to be due to some peculiar needs we have in our footer code. I ended up using a combination of several CDATA chunks, plus a DIV to wrap multiple script tags. Works fine now.

Cheers!

Pete

Post Reply