This library groups together several macros used to define a document in XSL-FO format. These directives must be called by specifying the namespace "hardisFo":
<@hardisFo.toolMacro parameters>...</@hardisFo.toolMacro> ${ hardisFo.toolFunction(...) }
Each macro called hardisFo.foXXX represents the <fo:XXX> tag in XSL-FO language.
When processing a template, running a hardisFo.foXXX macro will produce the following fragment of XSL-FO code in the result document: <fo:XXX...> ... </fo:XXX>.
Each hardisFo.foXXX macro call must be correctly nested in the right hardisFo.foXXX parent macro, as specified by the XSL-FO language.
For example, specification XSL v1.1 states that a <fo:flow> tag can only be placed inside a <fo:page-sequence> tag, so the hardisFo.foFlow macro can only be called in the nested content of a hardisFo.foPageSequence macro.
Only XSL-FO tags supported by Apache FOP 2.2 have been ported (click here for more details).
hardisFo.foXXX macro naming convention.
A hardisFo.foXXX macro corresponds to each XSL-FO <fo:XXX> tag.
The renaming rule is as follows: the XXX tag name is converted from its Kebab case notation to Camel case notation.
Table of correspondences:
XSL-FO tag |
hardisFO macro |
basic-link |
hardisFo.foBasicLink |
bidi-override |
hardisFo.foBidiOverride |
block |
hardisFo.foBlock |
block-container |
hardisFo.foBlockContainer |
bookmark |
hardisFo.foBookmark |
bookmark-title |
hardisFo.foBookmarkTitle |
bookmark-tree |
hardisFo.foBookmarkTree |
character |
hardisFo.foCharacter |
color-profile |
hardisFo.foColorProfile |
conditional-page-master-reference |
hardisFo.foConditionalPageMasterReference |
declarations |
hardisFo.foDeclarations |
external-graphic |
hardisFo.foExternalGraphic |
float |
hardisFo.foFloat |
flow |
hardisFo.foFlow |
footnote |
hardisFo.foFootnote |
footnote-body |
hardisFo.foFootnoteBody |
inline |
hardisFo.foInline |
inline-container |
hardisFo.foInlineContainer |
instream-foreign-object |
hardisFo.foInstreamForeignObject |
layout-master-set |
hardisFo.foLayoutMasterSet |
leader |
hardisFo.foLeader |
list-block |
hardisFo.foListBlock |
list-item |
hardisFo.foListItem |
list-item-body |
hardisFo.foListItemBody |
list-item-label |
hardisFo.foListItemLabel |
marker |
hardisFo.foMarker |
multi-case |
hardisFo.foMultiCase |
multi-switch |
hardisFo.foMultiSwitch |
page-number |
hardisFo.foPageNumber |
page-number-citation |
hardisFo.foPageNumberCitation |
page-number-citation-last |
hardisFo.foPageNumberCitationLast |
page-sequence |
hardisFo.foPageSequence |
page-sequence-master |
hardisFo.foPageSequenceMaster |
region-after |
hardisFo.foRegionAfter |
region-before |
hardisFo.foRegionBefore |
region-body |
hardisFo.foRegionBody |
region-end |
hardisFo.foRegionEnd |
region-start |
hardisFo.foRegionStart |
repeatable-page-master-alternatives |
hardisFo.foRepeatablePageMasterAlternatives |
repeatable-page-master-reference |
hardisFo.foRepeatablePageMasterReference |
retrieve-marker |
hardisFo.foRetrieveMarker |
retrieve-table-marker |
hardisFo.foRetrieveTableMarker |
root |
hardisFo.foRoot |
simple-page-master |
hardisFo.foSimplePageMaster |
single-page-master-reference |
hardisFo.foSinglePageMasterReference |
static-content |
hardisFo.foStaticContent |
table |
hardisFo.foTable |
table-body |
hardisFo.foTableBody |
table-cell |
hardisFo.foTableCell |
table-column |
hardisFo.foTableColumn |
table-footer |
hardisFo.foTableFooter |
table-header |
hardisFo.foTableHeader |
table-row |
hardisFo.foTableRow |
title |
hardisFo.foTitle |
wrapper |
hardisFo.foWrapper |
↑ Top of page
hardisFo.foXXX macro parameter naming convention.
Each <fo:XXX> tag attribute corresponds to a parameter of the corresponding hardisFo.foXXX macro. The renaming rule is as follows: the attribute name is converted from its Kebab case notation to lower Camel case notation.
For example: the <fo:static-content> tag has an attribute called "flow-name". In the corresponding hardisFo.foStaticContent macro, the attribute is represented by the "flowName" parameter.
N.B: the value assigned to a parameter must be a type that can be automatically converted to an alphanumeric string by FreeMarker.
Special case:
Certain XSL-FO attributes have "." or ":" characters. For example, block-progression-dimension.optimum, fox:border-radius.
The rule states that the "." character must be converted into a "Dot" string and the ":" character must be converted into a "Colon" string. For example, "block-progression-dimension.optimum" is converted into "blockProgressionDimensionDotOptimum" and "fox:border-radius" is converted into "foxColonBorderRadius".
Example of XSL-FO document template written entirely with the macros:
<?xml version="1.0" encoding="utf-8"?> <#-- XSL-FO document using hardisFo macros --> <@hardisFo.foRoot xmlns\:fox="http://xmlgraphics.apache.org/fop/extensions"> <@hardisFo.foLayoutMasterSet> <@hardisFo.foSimplePageMaster masterName="sampleLayout" pageHeight="29.7cm" pageWidth="21cm" marginTop="2.5cm" marginBottom="2.5cm" marginLeft="1cm" marginRight="1cm"> <@hardisFo.foRegionBody/> </@hardisFo.foSimplePageMaster> </@hardisFo.foLayoutMasterSet> <@hardisFo.foPageSequence masterReference="sampleLayout"> <@hardisFo.foFlow flowName="xsl-region-body"> <@hardisFo.foBlock fontSize="14pt" border="solid red 3pt" textAlign="center" foxColonBorderRadius="5pt"> Sample of CSS use</@hardisFo.foBlock> <@hardisFo.foBlock> In this block, every inline text is <@hardisFo.foInline textTransform="uppercase">uppercase</@hardisFo.foInline> <@hardisFo.foBlock> This is the <@hardisFo.foInline textTransform="uppercase">second</@hardisFo.foInline> sentence. </@hardisFo.foBlock> <@hardisFo.foBlock> This is the third sentence with a particular <@hardisFo.foInline id="specialText" textTransform="uppercase" color="green">inline text</@hardisFo.foInline>. </@hardisFo.foBlock> </@hardisFo.foBlock> </@hardisFo.foFlow> </@hardisFo.foPageSequence> </@hardisFo.foRoot>
The use of hardisCSS and hardisAdv libraries in a template requires the XSL-FO document to be entirely written using hardisFo macros.