This tutorial uses the DITA Open Toolkit 1.4.2.1 and the corresponding PDF plugin release, and Wrycan's demo text. This assumes you have a working DITA environment and can run the default formatting with PDF plugin. If you don't know how to do this, contact us and we can post an example of how to do this! We will be working in the demo/fo/Customization directory of the of the open toolkit as shown in the image below.

1. We will customize the cross references so that there will be no "on page xx" displayed. The DITA markup that we are customizing looks like the following in XML:
<p><b>This xref link to <xref href="PellentesqueConsectetuer.xml#pellCon/sampleXREFtarget" scope="local"/> is a sample link to an element within this topic.<b><p>
And the default output looks like the following in the PDF output:
This xref link to Table 3: Sample XREF Target on page 11 is a sample link to an element within this topic.
This xref link to Table 3: Sample XREF Target on page 11 is a sample link to an element within this topic.
2. Next, we need to find the code in the XSL where this occurs, and then create the customization layer to override this code. To do this, a full text search of the demo folder can be done for the text "on page." One tool that can do this quickly is Edit Plus which reveals that in demo/fo/cfg/common/vars/en_us.xml, on line 258, there is a variable that is set with the name "On the page" as shown below:
<variable id="On the page"> on page <param ref-name="pagenum"/></variable>
3. Another search can now be done for the text "On the page," which shows that demo/fo/xsl/fo/links.xsl on line 371 is where this variable is being called, in the template <xsl:template name="insertPageNumberCitation">. The next step is to integrate this template into the customization layer.
4. A quick and easy way to do this is to copy the file demo/fo/Customization/fo/xsl/custom.xsl.orig to custom.xsl. Then open it and copy/paste the original insertPageNumberCitation template from links.xsl. This template has an <xsl:otherwise> containing the "On the page" variable, so in order to remove the "on page xx" text, this otherwise case should be removed by deleting everything from and including <xsl:otherwise> to <xsl:otherwise> and save the file. Note: If you are going to be making a lot of customizations to the fo plugin, then it might be a good idea to utilize the <xsl:import>
function to better organize your customizations. If you have any questions about this method, feel free to ask and we'll do a post on it!
5. Finally, the fo plugin needs to be told that customizations have been added. In order to do this, copy demo/fo/Customization/catalog.xml.orig to catalog.xml and uncomment line 10 from:
<!--uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/-->
to
<uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/> and save the file.
<!--uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/-->
to
<uri name="cfg:fo/xsl/custom.xsl" uri="fo/xsl/custom.xsl"/> and save the file.
The creation of the customization layer is now complete! Re-run the pdf and see the results. In our case the output now looks like the following:
This xref link to Table 3: Sample XREF Target is a sample link to an element within this topic.
This xref link to Table 3: Sample XREF Target is a sample link to an element within this topic.
If you would like to see any other ways to customize the DITA Open Toolkit, contact us and we can provide one!
0 comments:
Post a Comment