Chapter 9. Cross-Document Links

To quote from the specification:

Because XML, unlike HTML, has no built-in semantics, there is no built-in notion of a hypertext link.

So why does XSL-FO address links? Certainly for a paper-based output, an active hyperlink isn’t much use, though for a screen-based presentation using PDF, it might be. While XSL-FO is used primarily for paper-based output today, it would be a mistake to think this is XSL-FO’s only purpose. XSL-FO is designed to present XML across several media, including interactive media; to do that, it needs to support hyperlinking. In its simplest form, the link is useful to cross-reference to content, locations within the document, and specific structural elements. For web-based delivery, it is handy to have an active link, and for print output, the actual content of the active element needs to be meaningful. This facility is offered in the first version of the specification.

XSL-FO has a formatting object named fo:basic-link, which provides the basic linking capability. Example 9-1 and Figure 9-1 show this in use.

Example 9-1. A basic link

xml source

<para>...see the figure on page <link idref="fig53"/> 
</para>

and the stylesheet
<xsl:template match="link">
<fo:basic-link background-color="lightblue"
    internal-destination="{@idref}">Page 
    <fo:page-number-citation ref-id="intro"/>
  </fo:basic-link>

</xsl:template>
A basic link

Figure 9-1. A basic link ...

Get XSL-FO now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.