Creating Links: fo:basic-link

Creating Links: <fo: basic-link >

Another powerful aspect of XSL-FO is the ability to use links from document to document. This is currently supported in the fop processor with the XSL-FO <fo:basic-link> element, which acts much like a simple hyperlink.

You can use these properties with <fo:basic-link> :

  • Common accessibility properties: source-document, role

  • Common aural properties: azimuth, cue-after, cue-before, elevation, pause-after, pause-before, pitch, pitch-range, play-during, richness, speak, speak-header, speak-numeral, speak-punctuation, speech-rate, stress, voice-family, volume

  • Common border, padding, and background properties: background-attachment , background- color , background-image, background-repeat , background-position-horizontal, background-position-vertical, border-before-color, border-before-style, border-before-width, border-after-color, border-after-style, border-after-width, border-start-color, border-start-style, border-start-width, border-end-color, border-end-style, border-end-width, border-top-color, border-top-style, border-top-width, border-bottom-color, border-bottom-style, border-bottom-width, border-left-color, border-left-style, border-left-width, border-right-color, border-right-style, border-right-width, padding-before, padding-after, padding-start, padding-end, padding-top, padding-bottom, padding-left, padding-right

  • Common inline margin properties-inline: space-end, space-start

  • Common relative position properties: top, right, bottom, left, relative-position

  • alignment-adjust

  • alignment-baseline

  • baseline-shift

  • destination-placement-offset

  • dominant-baseline

  • external-destination

  • id

  • indicate -destination

  • internal-destination

  • keep-together

  • keep-with- next

  • keep-with-previous

  • line-height

  • line-height-shift-adjustment

  • show-destination

  • target-processing-context

  • target-presentation-context

  • target-stylesheet

The following example,, includes a link to a PDF document created earlier in this chapter, graphics.pdf:

Listing 12.6
 <?xml version="1.0 encoding="UTF-8"?>  <fo:root xmlns:fo="">      <fo:layout-master-set>          <fo:simple-page-master margin-right="20mm" margin-left="20mm"              margin-bottom="10mm" margin-top="10mm" page-width="300mm"              page-height="400mm" master-name="page">              <fo:region-body margin-right="0mm" margin-left="0mm"                  margin-bottom="10mm" margin-top="0mm"/>              <fo:region-after extent="10mm"/>          </fo:simple-page-master>      </fo:layout-master-set>      <fo:page-sequence master-name="page">          <fo:flow flow-name="xsl-region-body">              <fo:block space-after="12pt" font-weight="bold"                  font-size="36pt"                  text-align="center">                  Using Links              </fo:block>              <fo:block font-size="24pt">                  If you'd like to see some images, click                  <fo:basic-link external-destination="graphics.pdf">                      <fo:inline text-decoration="underline">here</fo:inline>                  </fo:basic-link>.              </fo:block>          </fo:flow>      </fo:page-sequence>  </fo:root> 

You can see the PDF document built from in Figure 12.6. Note that Ive explicitly underlined the link to make it appear more like a hyperlink. When you move the mouse cursor over the link in Adobe Acrobat, the cursor changes to the same one that browsers such as the Internet Explorer use for hyperlinks , as you see in Figure 12.6. When you click the link, Acrobat navigates to graphics.pdf (which you should place in the same directory as links.pdf for the purposes of this example), displaying that new document.

Figure 12.6. Supporting basic links with XSL-FO.

Creating the link is easy in this case; here, Im just setting the external-destination property of the <fo:basic-link> element to graphics.pdf :

 <fo:block font-size="24pt">                  If you'd like to see some images, click                  <fo:basic-link external-destination="graphics.pdf">                  .                  .                  .                  </fo:basic-link>.              </fo:block> 

All thats left is to add some underlined text that the user can click to navigate to the new document. You dont need to make the text underlined, of course, but otherwise theres nothing to indicate that the text is a link, except that the mouse cursor changes when it moves over the text. You add the underlined text as follows :

 <fo:block font-size="24pt">                  If you'd like to see some images, click                  <fo:basic-link external-destination="graphics.pdf">                      <fo:inline text-decoration="underline">here</fo:inline>                  </fo:basic-link>.              </fo:block> 

So far, the only implementations of XSL-FO links are basic ones, as shown in this example. However, if youre familiar with the XML specifications for XPointer and XLink, you should expect a great deal more sophistication in this area in the future.

Inside XSLT
Inside Xslt
ISBN: B0031W8M4K
Year: 2005
Pages: 196

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: