Page 1 of 1
Using included-javascript
Posted: Mon Jul 29, 2013 4:53 pm
by mstrubberg
Can I establish one DITA output type that uses included-javascript.xml and another output type that does not use the included-javascript.xml?
In the DITA Webhelp output, I want to add some custom javascript in the output. Adding the javascript to the included-javascript.xml works great. However, I now need another DITA Webhelp output type that does NOT included the custom javascript.
How can I have two separate builds where one uses the custom javascript and one that doesn't?
Re: Using included-javascript
Posted: Tue Jul 30, 2013 12:36 pm
by sorin_ristache
Hello,
The content of the file
included-javascript.xml is inserted just before the
</body> end tag of each Webhelp page. This is done at line 223 with a
<replace> element in the file
[Oxygen-14.2-install-dir]\frameworks\docbook\xsl\com.oxygenxml.webhelp\integrator.xml. If you want a Webhelp transformation that does not insert this
included-javascript.xml file in the output you need to parameterize the
<replace> element:
- Enclose the <replace> element at line 223 in file [Oxygen-14.2-install-dir]\frameworks\docbook\xsl\com.oxygenxml.webhelp\integrator.xml in an ANT <if> element that checks if the value of an ANT property is set or not. The ANT property can be set as a parameter in the DITA Webhelp transformation scenario, let's call this property webhelp.insert.javascript.
- Run the DITA OT Integrator built-in transformation on the [Oxygen-14.2-install-dir]\frameworks\docbook\xsl\com.oxygenxml.webhelp\integrator.xml file modified at step 1. This is necessary for updating the DITA Webhelp transformation with your modifications.
- Duplicate the DITA Map Webhelp transformation and add the webhelp.insert.javascript parameter. This will be the only transformation that will insert the custom JavaScript code in the output Webhelp pages.
- Add a new parameter called webhelp.insert.javascript on the Parameters tab of the new (duplicated) DITA Webhelp transformation with the value 'true'.
The default DITA Webhelp transformation (the one without the
webhelp.insert.javascript parameter set) will not insert the JavaScript code in the output pages because the
<if> condition that checks for the
webhelp.insert.javascript parameter will fail.
Regards,
Sorin
Re: Using included-javascript
Posted: Tue Jul 30, 2013 8:38 pm
by mstrubberg
If I'm composing a DITA Map and topics using DITA webhelp, should I be adding the <if> element in this file:
frameworks/dita/DITA-OT/plugins/com.oxygenxml.webhelp
I tried updating the above file with this <if> element code on <replace> and it did not work. Did I get the if statement wrong? I added a new parameter to a duplicate of the DITA webhelp default output webhelp.insert.javascript=true and then composed expecting for the javascript to be added and it was. Then I removed the new parameter, and the javascript code still was present in the output html.
Code: Select all
<if name="webhelp.insert.javascript" value="true">
<replacefilter
token="</body>"
value="${javascript-file}"
</body>"/>
</if>
Re: Using included-javascript
Posted: Wed Jul 31, 2013 1:00 pm
by sorin_ristache
You have to edit the file [Oxygen-14.2-install-dir]\frameworks\docbook\xsl\com.oxygenxml.webhelp\integrator.xml at line 223 I indicated in the previous post.
I suggest testing if the ANT property
webhelp.insert.javascript was set by the transformation parameter with the same name by using an
ANT isset condition element:
Code: Select all
<if>
<isset property="webhelp.insert.javascript"/>
<then>
<replace file="${htmlFile}" encoding="UTF-8">
<replacefilter
token="</body>"
value="${javascript-file}
</body>"/>
</replace>
</then>
</if>
Regards,
Sorin
Re: Using included-javascript
Posted: Tue Jan 14, 2014 7:18 pm
by mstrubberg
Sorin,
I'm using <oXygen/> XML Editor 15.1, build 2013101713. In another post that was asking how to add the javascript to the <head > tag of each topic.html file, you instructed just adding the javascript to: ${frameworks.dir}/dita/DITA-OT/plugins/com.oxygenxml.webhelp/xsl/dita/desktop/common.xsl inside the <xsl:template name="jsAndCSS">.
I've added my javascript to the common.xsl file, saved, and ran my DITA 2 Webhelp output and the javascript is not in the resulting topic html files in the head tag.
What did I miss?
Re: Using included-javascript
Posted: Wed Jan 15, 2014 11:49 am
by sorin_ristache
Hello,
I tested some custom JavaScript code added in the template
name="jsAndCSS" in the file
${frameworks.dir}/dita/DITA-OT/plugins/com.oxygenxml.webhelp/xsl/dita/desktop/common.xsl. The DITA Webhelp transformation added the custom code in the <head> element of each HTML output page of the Webhelp set output.
I just added the custom JavaScript code at the end of the template:
Code: Select all
<xsl:template name="jsAndCSS">
. . .
. . .
<!-- add custom JavaScript code here before the </xsl:template> tag-->
<script language="javascript">
. . .
</script>
</xsl:template>
Please make sure you edit the correct
common.xsl file, from the install directory of the Oxygen version that you use.
If it does not work for you please post here the following:
- the path of your Oxygen install dir, for example: c:\program files (x86)\oxygen\oxygen_15.0,
- the complete file path of the modified common.xsl file, for example: c:\program files (x86)\oxygen\oxygen_15.0\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\dita\desktop\common.xsl,
- the version number displayed in the Help -> About dialog when you run the DITA Webhelp transformation, for example: <oXygen/> XML Editor 15.0,
- the whole template name="jsAndCSS" from the above common.xsl file.
Regards,
Sorin