History | Edit

Code References

The DITA coderef element can be used to reference an external file that contains literal code. This is especially useful if you need to reference code from an external source that may occasionally change. Another advantage is that you don't have to convert illegal characters into their character equivalents. When the coderef is processed, the referenced code file is imported and delimiting characters (such as < or &) are displayed as standard text, rather than treated as XML markup.

For more information about code references, see DITA 1.3 Specification: Coderef.

Example of using a Coderef

<p>This code is an example of how to use a coderef.</p>
  <codeblock><coderef href="MyExternalCode.xsl"/></codeblock>

Defining Line Ranges

DITA-OT provides additional code reference processing support that allows you to define line ranges in case you only want to reference certain parts of the external file, rather than the whole file.

For information and examples of how to define line ranges, see DITA Open Toolkit Documentation: Extended Code Reference Processing.