Products Downloads


French version


Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Pas de format
<@hardisCSS.toolMacro parameters>...</@hardisCSS.toolMacro>
 ${ hardisCSS.toolFunction(...) }

...

CSS knowledge is required in order to use this library. 


The macros and functions of this library can only be used with XSL-FO document templates defined entirely with the aid of hardisFo library macros (and not with the standard XSL-FO tags <fo:xxx>). 


This library is used to define layout style rules. Unlike HTML, XSL-FO does not have its own style definition language: XSL-FO style rules will be based directly on XSL-FO tag attributes (e.g. font-family, padding, text-align, etc.).

 


Each style rule selector must be written using the CSS 2.1. specification. Certain HTML-specific selectors or child selectors are not supported, namely:

  • Pseudo-classes (e.g. :hover, :visited, :focus, :nth-last-of-type(), :last-child, etc.),
  • Pseudo-elements (e.g. ::after, ::first-letter, etc.).

 


The other selectors are supported, namely:

  • (Tag) element selectors. For example "foBlock" for all hardisFo.foBlock elements of the document.
  • Class selectors. For example ".greenClass". hardisFo macros representing an XSL-FO tag have a "class" attribute enabling a class to be associated with it.
  • ID (identifier) selectors. For example "#totalBlock". hardisFo macros representing an XSL-FO tag have an "id" attribute enabling an identifier to be associated with it.
  • The universal selector "*".
  • Attribute selectors. For example [break-after], [character=C].
  • Combination selectors. For example A, B or A B or A > B or A + B or A ~ B where A and B are selectors.

 


When processing a template, all the "rule" macros defining the XSL-FO style rules must be executed before the XSL-FO document the FreeMarker engine must know the style rules before processing the XSL-FO document): the "rule" macros need to be placed "before" the hardisFo.foRoot macro either by inserting them in the header (between the XML prolog and the hardisFo.foRoot macro) in the main template (by analogy with CSS, in a <style> tag contained in the <head> tag), or by placing them in an .ftlx sub-template, which will be included (via the <#include> directive) in the header of the main template (by analogy with CSS, in a style sheet included via the <link> tag).

Hardis - Haut de page

↑ Top of page

Template example

Pas de format
<?xml version="1.0" encoding="utf-8"?><#>
<#-- CSS rules declaration --><@hardisCSS>
<@hardisCSS.rule selectors = ".title" ><@hardisCSS>
	<@hardisCSS.declaration property = "font-size" >14pt</@hardisCSS.declaration><@hardisCSSdeclaration>
	<@hardisCSS.declaration property = "border" >solid red 3pt</@hardisCSS.declaration><@hardisCSSdeclaration>
	<@hardisCSS.declaration property = "text-align" >center</@hardisCSS.declaration><@hardisCSSdeclaration>
	<@hardisCSS.declaration property = "fox:border-radius" >5pt</@hardisCSS.declaration><declaration>
</@hardisCSS.rule><@hardisCSSrule>
<@hardisCSS.rule selectors = "foBlock foInline" ><@hardisCSS>
	<@hardisCSS.declaration property = "text-transform" >uppercase</@hardisCSS.declaration><declaration>
</@hardisCSS.rule><@hardisCSSrule>
<@hardisCSS.rule selectors = "#specialText" ><@hardisCSS>
	<@hardisCSS.declaration property = "color" >green</@hardisCSS.declaration><declaration>
</@hardisCSS.rule><#rule>
<#-- XSL-FO document using hardisFo macros --><@hardisFo>
	<@hardisFo.foRoot xmlns\:fox = "http://xmlgraphics.apache.org/fop/extensions" ><@hardisFo.foLayoutMasterSet><@hardisFo>
		<@hardisFo.foLayoutMasterSet>
			<@hardisFo.foSimplePageMaster masterName = "sampleLayout" pageHeight = "29.7cm" pageWidth = "21cm" marginTop = "2.5cm" marginBottom = "2.5cm" marginLeft = "1cm" marginRight = "1cm" ><@hardisFo>
				<@hardisFo.foRegionBody/><>
			</@hardisFo.foSimplePageMaster><foSimplePageMaster>
	</@hardisFo.foLayoutMasterSet><@hardisFofoLayoutMasterSet>
	<@hardisFo.foPageSequence masterReference = "sampleLayout" ><@hardisFo>
		<@hardisFo.foFlow flowName = "xsl-region-body" ><@hardisFo>
				<@hardisFo.foBlock class = "title" > Sample of CSS use</@hardisFo.foBlock><@hardisFo.foBlock>InfoBlock>
				<@hardisFo.foBlock>
					In this block, every inline text is <@hardisFo.foInline>uppercase</@hardisFo.foInline><@hardisFo.foBlock>ThisfoInline>
				<@hardisFo.foBlock>
					This is the <@hardisFo.foInline>second</@hardisFo.foInline> sentence.
				</@hardisFo.foBlock><@hardisFo.foBlock>ThisfoBlock>
				<@hardisFo.foBlock>
					This is the third sentence with a particular <@hardisFo.foInline id = "specialText" >inline text</@hardisFo.foInline>.
				</@hardisFo.foBlock><foBlock>
			</@hardisFo.foBlock><foBlock>
		</@hardisFo.foFlow><foFlow>
	</@hardisFo.foPageSequence><foPageSequence>
</@hardisFo.foRoot>
Hardis - Haut de page

↑ Top of page

Macros

declaration

Associates a value with an XSL-FO tag attribute name. The attribute name is the value of the "property" parameter and the attribute value is the tag content. The attribute value must correspond to the attribute type as defined in the Extensible Stylesheet Language (XSL) Version 1.1 specification (click here for more details). By analogy with CSS, this macro defines a CSS declaration (CSS property: value).

...

Like in CSS, the XSL-FO attribute value can be suffixed with "!important": this indicates that this attribute (and its value) has a higher priority than any other attribute of the same name (and of a different value) from another applicable rule on a given tag.


Empty directive: No

 


Parameters

Hardis - Tableau personnalisé
marginLeft30px

String

property

XSL-FO tag attribute name

Mandatory


 For example

Pas de format
<#-- Associate the "green" value with the color attribute --><@hardisCSS>
<@hardisCSS.declaration property="color">green</@hardisCSS.declaration><#declaration>
<#-- Associate the "14p" value with the font-size attribute --><@hardisCSS>
<@hardisCSS.declaration property="font-size">14pt</@hardisCSS.declaration><#declaration>
<#-- Associate the "solid red 10pt" value with the "fox:border-radius" attribute --><@hardisCSS>
<@hardisCSS.declaration property="fox:border-radius">solid red 10pt</@hardisCSS.declaration><#declaration>
<#-- Associate the "#a1e2bc" value with the "background-color" attribute with a stronger priority --><@hardisCSS>
<@hardisCSS.declaration property="background-color">#a1e2bc !important</@hardisCSS.declaration>
Hardis - Haut de page

↑ Top of page

rule

Defines an XSL-FO-style rule. By analogy with CSS, a rule is defined by:

  • selectors,
  • a block or set of declarations.

 


With this macro, the selectors are defined by the "selectors" parameter. Each declaration is defined by a call to the "declaration" macro, which should be found inside the "declaration" macro. 


Example of syntax:

Pas de format
<#-- Defines a rule associated with the .greenTitleClass selector --><@hardisCSS>
<@hardisCSS.rule selectors=".greenTitleClass"><#>
<#-- which contains 3 declarations --><@hardisCSS>
<@hardisCSS.declaration property="text-align">center</@hardisCSS.declaration><@hardisCSSdeclaration>
<@hardisCSS.declaration property="font-style">italic</@hardisCSS.declaration><@hardisCSSdeclaration>
<@hardisCSS.declaration property="color">green</@hardisCSS.declaration><declaration>
</@hardisCSS.rule>

 



Empty directive: No


Parameters

Hardis - Tableau personnalisé
marginLeft30px

String

selectors

CSS syntax rule selector or set of selectors

Mandatory


For example

Pas de format
<@hardisCSS.rule selectors=".class1"><@hardisCSS>
<@hardisCSS.declaration property="color">red</@hardisCSS.declaration><declaration>
</@hardisCSS.rule><@hardisCSSrule>
<@hardisCSS.rule selectors=".class2"><@hardisCSS>
<@hardisCSS.declaration property="background-color">pink</@hardisCSS.declaration><@hardisCSSdeclaration>
<@hardisCSS.declaration property="color">blue</@hardisCSS.declaration><declaration>
</@hardisCSS.rule><@hardisCSSrule>
<@hardisCSS.rule selectors=".class2 > .class1"><@hardisCSS>
<@hardisCSS.declaration property="background-color">aqua</@hardisCSS.declaration><declaration>
</@hardisCSS.rule><@hardisCSSrule>
<@hardisCSS.rule selectors=".class3 , .class4 > foBlock "><@hardisCSS>
<@hardisCSS.declaration property="display-align">center</@hardisCSS.declaration><@hardisCSSdeclaration>
<@hardisCSS.declaration property="text-align">center</@hardisCSS.declaration><declaration>
</@hardisCSS.rule>
 

Functions

None.

Hardis - Haut de page

↑ Top of page