XML technologies / DocBook / Block elements / Callouts / Inserting callouts indirectly
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
If callouts cannot be inserted directly into the text, you need regions. The following prerequisites apply:
coordinates: Specify where the callouts should appear.
Container element: Text and coordinates must be wrapped in a container element, such as
programlistingcoorscreenco.Extension functions: At the time of writing, only Saxon and Xalan have extension functions that position callouts correctly; see Extension functions and elements.
This method allows content to be inserted from an external file, separating source code from callouts. This is especially useful when the source code is reused or changes frequently. You may, however, need to adjust the coordinates.
To use this method, define coordinates identifying the relevant positions. Use the element areaspec to define the full set of coordinates, and area to specify a callout. Use the element calloutlist to describe the individual callouts.
Example: Defining callouts
<areaspec units="...">
<area ANKER="..." coords='...'/>
<!-- Weitere Einträge -->
</areaspec>Replace the placeholder ANKER with id in DocBook 4 and xml:id in DocBook 5.
Line 1: Coordinate definitions begin with areaspec. The coordinate unit is specified in the attribute units (see the list below). The default depends on whether callouts are for text or images. For text it is linecolumn, for images calspair.
Line 2: A callout, specified with the element area. The attribute coords contains the coordinate specified by units on areaspec.
The attribute units must contain a valid unit value. Possible values are:
calspair="x1, y1 x2, y2"specifies a rectangular region with (x1, y1) for the lower-left corner and (x2, y2) for the upper-right corner. X and Y are integers from 0 to 10,000, interpreted as percentages from 0.00% to 100.00%. This attribute is meaningful only in a graphical context.
linecolumn="Zeile"specifies the line; the value is undefined in a graphical context.
linerange="Startzeile Endzeile"defines coordinates as start and end lines; this attribute is undefined in a graphical context.
linecolumnpair="Zeile1 Spalte1 Zeile2 Spalte2"identifies a region using two line/column pairs. The marked region contains all characters starting at column1 of line1 and ending at column2 of line2. Its meaning is undefined in a graphical context.
otherunitsspecifies an application-specific unit defined by the processing application. If this value is specified, the attribute
otherunitsmust be present.
Note: Avoid unchecked values in coords
Note that the schema cannot check the format of coords. You must ensure that the syntax is correct.
For text, the most useful units are linecolumn and linecolumnpair. The following example defines coordinates by line.
Example: Defining line coordinates
<programlistingco>
<areaspec units="linecolumn">
<area ANKER="co.commands" coords="4"/>
<area ANKER="co.cmd" coords="6"/>
<area ANKER="co.join" coords="7"/>
<area ANKER="co.run" coords="9"/>
</areaspec>
<programlisting language="python">#!/usr/bin/python -u
import sys
import string
import commands
cmd = ["file", sys.argv[1], "| cut -d',' -f2" ]
cmd = string.join(cmd)
(res, out) = commands.getstatusoutput(cmd)
print res, out</programlisting>
</programlistingco>Replace the placeholder ANKER with id in DocBook 4 and xml:id in DocBook 5.
Line 1: The container element holding both coordinates and the listing.
Line 2: Defines all coordinates using line-based units (attribute units with the value linecolumn).
Line 3: This callout is placed on line 4.
Line 8: The actual listing without callouts.
The previous example defined coordinates by line. By default, the callout extension function places them in the column specified by the parameter callout.defaultcolumn. All callouts therefore appear in the same column. To change this, set the attribute units to linecolumnpair as shown in the following example:
Example: Defining line/column coordinates
<programlistingco>
<areaspec units="linecolumnpair">
<area ANKER="co.commands" coords="4"/>
<area ANKER="co.cmd" coords="6 48"/>
<area ANKER="co.join" coords="7 1"/>
<area ANKER="co.run" coords="9 44"/>
</areaspec>
<programlisting language="python">#!/usr/bin/python -u
import sys
import string
import commands
cmd = ["file", sys.argv[1], "| cut -d',' -f2" ]
cmd = string.join(cmd)
(res, out) = commands.getstatusoutput(cmd)
print res, out</programlisting>
</programlistingco>Replace the placeholder ANKER with id in DocBook 4 and xml:id in DocBook 5.
Line 2: Defines all coordinates using line/column units (attribute units with the value linecolumnpair).
Line 3: This callout specifies only the line. The column comes from the parameter callout.defaultcolumn.
Line 4: This callout is placed at line 6, column 48.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top