#### 10.2.1 Including external code snippets with PI markers

When you use the DITA 1.2 <coderef> element to include code from an external file, by default you get the content of the entire referenced file. However, you can use DITA2Go external-code PI markers to select only a portion of the referenced code, by character range or by line number. For example:

    <?dtall ExtCodeStartLine="4" ExtCodeEndLine="15" ?>

Placed in your document, this PI marker would include only lines 4 through 15 of the file referenced in the next <coderef>. To start at the beginning of the referenced file, omit ExtCodeStartLine; to go to the end, omit ExtCodeEndLine. You can specify starting and ending characters in the file, instead of lines; for example:

    <?dtall ExtCodeStartChar="34" ExtCodeEndChar="320" ?>

You could include a check on the length of the file, and specify its encoding, also:

    <?dtall ExtCodeFileLen="438" ExtCodeFileEnc="UTF-8" ?>

An external-code PI marker applies only to the next <coderef> instance, and is self canceling following the <coderef>. Instead of dtall, you can use dthtm to affect only HTML/XHTML/XML outputs, or dtrtf to affect only Word and WinHelp output.

See §38. Working with processing instructions .

Previous Topic: 10.2 Referencing external code or text fragments

Next Topic: 10.2.2 Including external code snippets with fragment identifiers

Parent Topic: 10.2 Referencing external code or text fragments

Sibling Topics:

10.2.2 Including external code snippets with fragment identifiers

Table of Contents • Index