Page 1 of 1

jquery script in footer

Posted: Thu Dec 08, 2011 2:53 am
by healdp
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

Re: jquery script in footer

Posted: Thu Dec 08, 2011 2:03 pm
by Radu
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

Re: jquery script in footer

Posted: Fri Dec 09, 2011 11:59 pm
by healdp
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