XSL-FO - References and Links
Part:
1
2
This tutorial helps you to understand:
- Page Number References
- Hyper Links
- Marked Objects References
- XSL-FO Example - complex_page.fo
Page Number References
"page-number": An XSL-FO element serving as a data variable to refer to
the current page number. It is very useful for producing running page number
in page header area. The following code puts the current page number at the left
edge of a block:
<fo:block text-align="end">
</fo:page-number/>
</fo:block>
"page-number-citation": An XSL-FO element serving as a data variable to refer to
the page number where the referenced formatting object is located.
The referenced formatting object is specified by its "id" attribute.
The following code puts the page number of chapter 2 in referencing sentence:
<fo:block id="chapter_2">
Chapter 2 ...
</fo:block>
...
<fo:block>
See Chapter 2 on page
<fo:page-number-citation ref-id="chapter_2"/> for details.
</fo:block>
Hyper Links
"basic-link": An XSL-FO element serving as a special statement to
produce a hyper link. A hyper link is clickable while the output document is
viewed in a browser. When a hyper link is clicked, the browser should move to
another location in the same document or an external document
where this hyper link is referred to.
The following code defines a hyper link for an entry in the table of contents:
<fo:block id="chapter_2">
Chapter 2 ...
</fo:block>
...
<fo:block id="toc">
...
<fo:basic-link internal-destination="chapter-2" color="#0000ff">
Chapter 2. ------ <fo:page-number-citation ref-id="chapter_2"/>
</fo:basic-link>
</fo:block>
The following code defines a hyper link referring to an external document
with the help of an XSL function url():
<fo:block id="reference">
See <fo:basic-link
external-destination="url('www.geocities.com/herong_yang')"
color="#0000ff">Herong's home page</fo:basic-link>
for more details.
</fo:block>
Internal destinations are also useful for building indexes at the end of a document.
Page number citations and internal destinations can refer both forward and backward.
Forward references requires XSL formatter to process the source code twice, because
a forward page number is not known during the first process. FOP seems to be processing
the source code twice automatically. But I remember that I have to run TeX processors
twice to resolve page number citations correctly with TeX documents.
Marked Objects References
"marker": An XSL-FO element serving as a special statement to mark a group of formatting
objects with a reference name.
"retrieve-marker": An XSL-FO element serving as a special statement to retrieve the
formatting objects marked by the specified reference name. This statement can only be used in
"static-content" flows.
The following code marks a chapter title with "chapter_title" as the reference name, and
then retrieves the chapter title in the footer area:
<fo:static-content flow-name="footer"
<fo:block border-top-width="1px" border-top-style="solid"
text-align="center">
<fo:retrieve-marker retrieve-class-name="chapter_title"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="body"
...
<fo:block id="chapter_2">
<fo:marker marker-class-name="chapter_title">
Chapter 2. Title
</fo:marker>
<fo:block>
Chapter 2. Title
</fo:block>
</fo:block>
...
</fo:flow>
(Continued on next part...)
Part:
1
2
|