The coderef element

The coderef element is used to reference external files, such as code samples, that are then imported as part of the processing to be rendered as standard text. The coderef is an alternative to the codeblock element for cases when the code is stored or maintained in its original form outside the DITA source.

The coderef element, introduced in DITA 1.2, is a reference element like xref and conref. Its purpose is to allow the transclusion of XML and other blocks of code from an external file.

For example, you may want to include a sample block of HTML code stored in its own HTML file. When the coderef is processed, the referenced code file is imported, escaped (to convert the tagging delimiting characters such as "<" are displayed, rather than treated as DITA instructions), and then output in the same way as a static codeblock element.