External links
Links can be set to external destinations (e.g. WWW addresses) which may be used as a hyperlink in the PDF.
In this section the use of the <fo:basic-link> element for the setting of external references (to Internet addresses or further documents) is demonstrated by an example.
Excerpt from the DTD:
<!ELEMENT WR (#PCDATA)>
<!ATTLIST WR WWWAddress CDATA #REQUIRED>
Stylesheet:
<xsl:template match="WR">
<fo:inline text-decoration="underline">
<fo:basic-link> ❶
<xsl:attribute name="external-destination"> ❷
<xsl:value-of select="@WWWAddress"/> ❸
</xsl:attribute>
<xsl:apply-templates/> ❹
</fo:basic-link>
</fo:inline>
</xsl:template>
❶ With the text-decoration attribute which is set to the value underline in the <fo:inline> element, the content of the WR element is highlighted in the print layout by underlining and thus it is set apart from the surrounding text.
❷ With the <fo:basic-link> element the condition is created for using the link as a hyperlink.
❸ The external-destination attribute gets the value of the WWWAddress attribute from the XML document to be processed (with <xsl:value-of>) as attribute value. This address has to be syntactically correct and target-aimed in order to fulfil its function.
❹ The textual content of WR is displayed in the print layout (underlined in this example). This content can differ from the formal link address in the printout. In the PDF the mouse cursor may signal the existence of a reference when touching the link. For the tracking of the link, the attribute value of WWWAddress is used, not the textual content of <WR>.
The generation of the hyperlink is dependent on the chosen XSL-FO formatter and the PDF generator. When using the XSL-Formatter of Antenna House, the PDF generators of Antenna House and Adobe (Acrobat Distiller) generate these hyperlinks.
<< back | next >> |
Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo@dpunkt.de