XSL avancé XSL-FO - INFO0406 -...

Preview:

Citation preview

XSL avancéXSL-FOINFO0406

Luiz Angelo Steffenel

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 1 / 49

Plan

1 XSL et XSLTRappelInstructions évoluéesLes transformations client et serveur

2 XSL-FO

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 2 / 49

Plan

1 XSL et XSLTRappelInstructions évoluéesLes transformations client et serveur

2 XSL-FO

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 3 / 49

Rappel de XSL

eXstensible Stylesheet Languagelangage de transformation de de document XMLtransformation vers :

XMLHTMLRTF...

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 4 / 49

Notre premier exemple

<?xml vers ion=" 1.0 " encoding="UTF−8" standalone=" no " ?><?xml−s t y l eshee t href=" video . x s l " type=" t e x t / x s l " ?><videotheque>

< f i l m >< t i t r e > Pulp f i c t i o n < / t i t r e >< r e a l i s a t e u r > Quentin Tarant ino < / r e a l i s a t e u r ><annee> 1994 < / annee><acteurs>

<acteur> John Travo l ta < / ac teur><acteur> Uma Thurman < / ac teur><acteur> Bruce W i l l i s < / ac teur><acteur> Samuel L . Jackson < / ac teur>

< / acteurs>< / f i l m >

. . .< f i l m >

< t i t r e > Imp i toyab le < / t i t r e >< r e a l i s a t e u r > C l i n t Eastwood < / r e a l i s a t e u r ><annee> 1992 < / annee><acteurs>

<acteur> C l i n t Eastwood < / ac teur><acteur> Gene Hackman < / ac teur><acteur> Morgan Freeman < / ac teur>

< / acteurs>< / f i l m >

< / videotheque>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 5 / 49

Un XSL associé

<?xml vers ion=" 1.0 " encoding="UTF−8" ?>< x s l : s t y l eshee t vers ion=" 1.0 " xmlns : x s l = " h t t p : / / www.w3 . org /1999/XSL / Transform ">< x s l : template match=" / videotheque "><html>

<head>< t i t l e > XSL < / t i t l e >< / head><body>< table border=" 1 ">

< t r ><td> T i t r e < / td><td> Réa l i sa teu r < / td>

< / t r >< x s l : for−each select=" f i l m ">

< t r ><td> < x s l : value−of select=" t i t r e " / > < / td><td> < x s l : value−of select=" r e a l i s a t e u r " / > < / td>

< / t r >< / x s l : for−each>

< / table>< / body>

< / html>< / x s l : template>< / x s l : s t y l eshee t >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 6 / 49

Résultat

Affichage dans le navigateur

Traitementsur le navigateurcode source : fichier XML !

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 7 / 49

Structure de notre document XSL

Déclaration et en-têtedéfinition d’un fichier XML

<?xml vers ion=" 1.0 " encoding="UTF−8" ?>

Définition du type de fichier< x s l : s t y l eshee t vers ion=" 1.0 " xmlns : x s l = " h t t p : / / www.w3 . org /1999/XSL / Transform ">. . .< / x s l : s t y l eshee t >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 8 / 49

Structure de notre document XSL (suite)

Transformationdéfinition de la transformation

< x s l : template match=" / videotheque ">. . .< / x s l : template>

Attention : l’expression XPATH ne définit pas 1 élément unique,mais tous les éléments qui peuvent être adressés !

match="/" la racinematch="/videotheque" accès à videothequematch="/videotheque/film" tous les films !

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 9 / 49

Structure de notre document XSL (fin)

Code des transformationscode HTMLcode spécifique XSL

< x s l : for−each select=" f i l m ">< t r >

<td> < x s l : value−of select=" t i t r e " / > < / td><td> < x s l : value−of select=" r e a l i s a t e u r " / > < / td>

< / t r >< / x s l : for−each>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 10 / 49

Accèsaccès et affichage de la valeur associée à une expression XPATH

< x s l : value−of select=" expressionXPATH " / >

Itérationsbalayage successif des éléments d’une expression XPATH

< x s l : for−each select=" expressionXPATH ">. . .< / x s l : for−each>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 11 / 49

Choixcomparaison avec une expression XPATH

< x s l : i f t e s t = " expressionXPATH ">. . .< / x s l : i f >

Triutilisation d’une instruction de triattention aux types des données

< x s l : s o r t select=" expressionXPATH "[ data−type=" t e x t | number " ][ order= " ascending | descending " ] / >

. . .

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 12 / 49

Plan

1 XSL et XSLTRappelInstructions évoluéesLes transformations client et serveur

2 XSL-FO

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 13 / 49

Les instructions évoluées

Transformation d’un document complexePrincipe : Diviser pour régner

1 Identifier les blocs de donnéesrègles "match"

2 Attribuer des transformations différentes selon le contextetemplates avec mode

3 Appeler les transformations adéquates (structure dynamique)xsl :apply-templatesxsl :call-template

Possibilité de reutilisation de templates

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 14 / 49

Un autre XML

Code XML

<?xml vers ion=" 1.0 " encoding="UTF−8" ?><?xml−s t y l eshee t href=" exercice3_1 . x s l " type=" t e x t / x s l " ?>< l i s t e >

< l i v r e >< t i t r e genre=" jeu ">Le Texas Hold ’Em Poker on l i ne < / t i t r e ><auteur>Mark Stohan< / auteur><auteur>Robert Bluman< / auteur>

<paru t i on >2006< / pa ru t i on >< / l i v r e >< l i v r e >

< t i t r e genre=" jeu ">Sudoku Manga< / t i t r e ><auteur>Sudoku f a c t o r y < / auteur><paru t i on >2007< / pa ru t i on >

< / l i v r e >< l i v r e >

< t i t r e genre=" jeu ">Kakoku< / t i t r e ><auteur> H i z i Kagochi< / auteur><paru t i on >2005< / pa ru t i on >

< / l i v r e >< l i v r e >

< t i t r e genre=" photo ">Manuel de l a photo< / t i t r e ><auteur>Jack ie Cont iboeuf< / auteur><auteur>A la in Mocney< / auteur><paru t i on >2006< / pa ru t i on >

< / l i v r e >< / l i s t e >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 15 / 49

Objectif

Reutilisation de templatesDefinir des templates différents pour

L’affichage des auteursL’affichage des titresLa description d’un livreUn tableau de livres

et les associer selon le besoin

Sortie

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 16 / 49

Solution

Définition de templates et appel avec xsl :apply-templates

<?xml vers ion=" 1.0 " encoding=" ISO−8859−1" ?>< x s l : s t y l eshee t vers ion=" 1.0 " xmlns : x s l = " h t t p : / / www.w3 . org /1999/XSL / Transform ">< x s l : template match=" / ">

<html><head>

< t i t l e > L i b r a i r e < / t i t l e >< / head><body>< table border=" 1 ">< t r ><th> T i t r e < / th><th>Auteurs< / th>< / t r >

< x s l : apply−templates / >< / table>< / body>< / html>

< / x s l : template>

< x s l : template match=" l i v r e ">< t r >

<td>< x s l : apply−templates select=" t i t r e " / >< / td><td>< x s l : apply−templates select=" auteur " / >< / td>

< / t r >< / x s l : template>

< x s l : template match=" t i t r e ">< x s l : value−of select=" . " / >

< / x s l : template>

< x s l : template match=" auteur ">< x s l : value−of select=" . " / >< x s l : text> < / x s l : text>

< / x s l : template>< / x s l : s t y l eshee t >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 17 / 49

Encore plus loin

Appel de templates "nommés"Si une même opération est utilisé pour différents modèles, nouspouvons les regrouperSimilaire à des fonctions en programmation

Code source

<?xml vers ion=" 1.0 " encoding="UTF−8" ?><?xml−s t y l eshee t href="exemplenomme . x s l " type=" t e x t / x s l " ?>< b i b l i o >

< l i v r e >< t i t r e >Les Misérables< / t i t r e ><auteur> V i c t o r Hugo< / auteur><nb_tommes>3< / nb_tommes>< l o c a l i s a t i o n t ravee=" 1 " armoire=" 4 " etagere=" 2 " / >

< / l i v r e >. . .

< / b i b l i o >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 18 / 49

Objectif

Rendre les noms des auteurs et des oeuvres en gras

<?xml vers ion=" 1.0 " encoding=" ISO−8859−1" ?>< x s l : s t y l eshee t vers ion=" 1.0 " xmlns : x s l = " h t t p : / / www.w3 . org /1999/XSL / Transform ">< x s l : template match=" b i b l i o ">

<html><head>< t i t l e >Exemple d ’ appels nommés< / t i t l e >< / head>

<body>< x s l : apply−templates select=" l i v r e " / >< / body>< / html>

< / x s l : template>

< x s l : template match=" t i t r e ">< x s l : c a l l−template name=" gras " / ><BR/ >

< / x s l : template>

< x s l : template match=" auteur ">< x s l : c a l l−template name=" gras " / ><BR/ >

< / x s l : template>

< x s l : template match=" nb_tomes ">< / x s l : template>

< x s l : template name=" gras "><B>< x s l : value−of select=" . " / >< /B>

< / x s l : template>< / x s l : s t y l eshee t >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 19 / 49

Encore plus loin

Les modesLes éléments <xsl :template> et <xsl :apply-templates> possèdentun attribut modepermet la différentiation du traitement selon la "position" dans ledocument rendu

Code source

<?xml vers ion=" 1.0 " encoding=" ISO−8859−1" ?><?xml−s t y l eshee t href=" exemplemode . x s l " type=" t e x t / x s l " ?>< chap i t r e t i t r e = " Les f e u i l l e s de s t y l e XSLT">

<sec t ion >< t i t r e > I n t r o d u c t i o n < / t i t r e ><paragraphe>Un des problèmes majeurs de ces dern iè res années est l ’ i n t e r o p é r a b i l i t é desapp l i ca t i ons , c ’ est−à−d i r e l a p o s s i b i l i t é de f a i r e communiquer ent re e l l e s des a p p l i c a t i o n sd iverses e t var iées . < / paragraphe>

< / sec t ion ><sec t ion >

< t i t r e >Première approche de XSLT< / t i t r e ><paragraphe>Le langage de t rans fo rma t i on XSLT est u t i l i s é pour t rans fo rmer un document XMLen d i ve rs documents au format XML, HTML, RTF ( Rich Text Format ) ou aut res formats tex tes .< / paragraphe>

< / sec t ion >< / chap i t r e >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 20 / 49

Objectif

Créer une table de matières et le corps du texte

<?xml vers ion=" 1.0 " encoding=" ISO−8859−1" ?>< x s l : s t y l eshee t vers ion=" 1.0 " xmlns : x s l = " h t t p : / / www.w3 . org /1999/XSL / Transform ">< x s l : template match=" / "><html> <body><h1>Table des mat ières< / h1><ul>< x s l : apply−templates select=" chap i t r e / sec t ion / t i t r e " mode=" tdm " / >< / ul><h1>< x s l : value−of select=" chap i t r e / @t i t re " / >< / h1>< x s l : apply−templates select=" chap i t r e / sec t ion / t i t r e " mode=" corps " / >< / body>< / html>< / x s l : template>

< x s l : template match=" chap i t r e / sec t ion / t i t r e " mode=" tdm ">< l i ><a href=" { concat ( ’ # ’ , p o s i t i o n ( ) ) } ">< x s l : value−of select=" . " / >< / a>< / l i >< / x s l : template>

< x s l : template match=" chap i t r e / sec t ion / t i t r e " mode=" corps "><h2><a name=" { p o s i t i o n ( ) } ">< x s l : value−of select=" . " / >< / a>< / h2>< x s l : apply−templates select=" . . / paragraphe " / >< / x s l : template>

< x s l : template match=" chap i t r e / sec t ion / paragraphe "><p>< x s l : value−of select=" . " / >< / p>< / x s l : template>< / x s l : s t y l eshee t >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 21 / 49

Résultat

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 22 / 49

Plan

1 XSL et XSLTRappelInstructions évoluéesLes transformations client et serveur

2 XSL-FO

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 23 / 49

Utilisations de XSL

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 24 / 49

Les transformations

Types de transformationssur le client

requête vers le fichier XMLrequête vers le fichier XSLtraitement sur le navigateur

sur le serveurrequête vers un fichier PHPlecture des fichiers XML et XSL sur le serveurtraitement sur le serveur

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 25 / 49

Transformation sur le client

Fonctionnementrapatriement de tous les fichiers sur le clientutilisation du parser / moteur XSL du clientpas de charge d’exécution sur le serveur

Problèmesaccès à la totalité du XML sur le clientproblèmes de compatibilité entre les parser des navigateurs

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 26 / 49

Transformation sur le serveur

Fonctionnementexécution dirigée de la transformation par un script PHPutilisation de l’extension php5-xsl de PHPenvoie au client du résultat HTML produit

Avantagesémission juste du HTML générépas de problème de compatibilité entre les navigateurs

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 27 / 49

Principe de la transformation sur le serveur

Chaîne de développement1 création d’objet XML (DOMDocument) pour le fichier XSL2 création d’objet XML (DOMDocument) pour le fichier XML3 création d’un objet processeur XSLT (XSLTProcessor)4 intégration de la feuille de style XSL dans le processeur XSLT5 application du processeur XSLT aux données (objet XML)

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 28 / 49

Exemple

Script PHP

<?php

$xslDoc = new DOMDocument ( ) ;$xslDoc−>load ( " v ideo . x s l " ) ;

$xmlDoc = new DOMDocument ( ) ;$xmlDoc−>load ( " videotheque . xml " ) ;

$proc = new XSLTProcessor ( ) ;$proc−>impor tS ty leshee t ( $xslDoc ) ;echo $proc−>transformToXML ( $xmlDoc ) ;

?>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 29 / 49

Plan

1 XSL et XSLTRappelInstructions évoluéesLes transformations client et serveur

2 XSL-FO

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 30 / 49

Présentation

XSL-FO (XSL Formatting Objects) permet d’exprimer de manièretrès précise le rendu d’un document

gestion de la pagination d’un document, les notes de bas de page,les marges, ...possible de préciser avec exactitude l’emplacement des différentsobjets sur la page, les polices des caractères, l’affichage detableaux, etc.

Un document XSL-FO est assez pénible à réaliser à la main.on utilise XSLT dans le but de générer du XSL-FO à partir dedonnées au format XML

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 31 / 49

Génération d’un PDF

ÉtapesLes données à présenter sont en XML.A partir d’une feuille de style XSLT, on génère un documentXSL-FO, à l’aide d’un processeur XSLT.On utilise ensuite un processeur FOP pour convertir le documentXSL-FO en PDF.

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 32 / 49

Démarrage

Un document XML de base

<?xml vers ion=" 1.0 " encoding=" ISO−8859−1" ?><?xml−s t y l eshee t href=" r e c e t t e f o . x s l " type=" t e x t / x s l " ?><?cocoon−process type=" x s l t " ?>< !DOCTYPE r e c e t t e SYSTEM " r e c e t t e . dtd ">< r e c e t t e >

< t i t r e >Les Bonnes Recettes de Cuis ine< / t i t r e ><gateau photo=" gateau . g i f ">

<type>Gâteau aux Noix e t au Chocolat blanc< / type>< i n g r e d i e n t s >

< i n g r e d i e n t >250g de choco la t blanc< / i n g r e d i e n t >< i n g r e d i e n t >60g de noix< / i n g r e d i e n t >.< i n g r e d i e n t >10g de levure chimique< / i n g r e d i e n t >

< / i n g r e d i e n t s >

<prepara t ion>Fa i tes r a m o l l i r l e beurre dans un p e t i t bol , l u i même dans un grand bo l d ’ eau t r è s chaude .f oue t t ez l e beurre énergiquement e t y a jou tez les sucres . a jou tez l ’ oeuf e n t i e r .< / p repara t ion>

< i n t e r n e t > h t t p : / / www. medi1 . com/ s c r i p t s / r ece t t es . php3? r =616< / i n t e r n e t >< / gateau>

< / r e c e t t e >

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 33 / 49

Démarrage

l’entête d’un document XSL-FO

<?xml vers ion=" 1.0 " encoding=" ISO−8859−1" ?>< x s l : s t y l eshee t vers ion=" 1.0 "xmlns : x s l = " h t t p : / / www.w3 . org /1999/XSL / Transform "xmlns : fo= " h t t p : / / www.w3 . org /1999/XSL / Format ">

< x s l : template match=" r e c e t t e ">< x s l : processing−i n s t r u c t i o n name=" cocoon−format ">type=" t e x t / x s l f o "< / x s l : processing−i n s t r u c t i o n >< fo : roo t xmlns : fo= " h t t p : / / www.w3 . org /1999/XSL / Format ">

La racine FOSous la racine fo :root il y a toujours :

un fo :layout-master-set qui définit un ou plusieurs page layoutdéfinis avec fo :simple-page-masterdes déclarations à option fo :declarationsune séquence d’un ou plusieurs fo :page-sequences quicontiennent du texte (littéralement ou fournis par XSLT) et desinstructions de formatage

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 34 / 49

Éléments du layout d’une page

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 35 / 49

Démarrage

Squelette XSL-FO de base

< x s l : template match=" page ">< fo : roo t >

< fo : layout−master−set>

< !−− D e f i n i t i o n o f a s i n g l e master page . I t i s s imple ( no headers etc . ) −−><fo : simple−page−master master−name=" f i r s t " >

< !−− requ i red element body −−><fo : region−body / >< / fo : simple−page−master>< / fo : layout−master−set>

< !−− D e f i n i t i o n o f a page sequence −−><fo : page−sequence master−name=" f i r s t ">

< fo : f l ow f low−name=" xs l−region−body " font−size=" 14 pt " l i n e−height=" 14 pt ">< x s l : apply−templates / >

< / fo : f l ow>< / fo : page−sequence>

< / fo : roo t >< / x s l : template>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 36 / 49

Notre page

Pagination

<fo : layout−master−set>

< fo : simple−page−master master−name=" f i r s t "page−height=" 29.7cm"page−width=" 21cm"margin−top=" 1cm"margin−bottom=" 2cm"margin−l e f t = " 2.5cm"margin−r i g h t = " 2.5cm">

< fo : region−body margin−top=" 1cm" / >< fo : region−before ex ten t= " 1cm" / >< fo : region−a f t e r ex ten t= " 1.5cm" / >

< / fo : simple−page−master>

< fo : simple−page−master master−name=" r i g h t "page−height=" 29.7cm"page−width=" 21cm"margin−top=" 1cm"margin−bottom=" 2cm"margin−l e f t = " 2.5cm"margin−r i g h t = " 2.5cm">

< fo : region−body margin−top=" 1cm" / >< fo : region−before ex ten t= " 1cm" / >< fo : region−a f t e r ex ten t= " 1.5cm" / >

< / fo : simple−page−master>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 37 / 49

Notre page

Pagination (cont)

<fo : simple−page−master master−name=" l e f t "page−height=" 29.7cm"page−width=" 21cm"margin−top=" 1cm"margin−bottom=" 2cm"margin−l e f t = " 2.5cm"margin−r i g h t = " 2.5cm">

< fo : region−body margin−top=" 1cm" / >< fo : region−before ex ten t= " 1cm" / >< fo : region−a f t e r ex ten t= " 1.5cm" / >

< / fo : simple−page−master>

< fo : page−sequence−master master−name=" run ">< fo : repeatable−page−master−a l t e r n a t i v e s maximum−repeats=" no−l i m i t " >< fo : c o n d i t i o n a l−page−master−re ference master−re ference=" l e f t " odd−or−even=" even " / >< fo : c o n d i t i o n a l−page−master−re ference master−re ference=" r i g h t " odd−or−even=" odd " / >< fo : c o n d i t i o n a l−page−master−re ference master−re ference=" t i t l e " / >

< / fo : repeatable−page−master−a l t e r n a t i v e s >< / fo : page−sequence−master>

< / fo : layout−master−set>

< !−− end : de f ines page layou t −−>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 38 / 49

Notre page

Pagination (fin)

< !−− ac tua l l ayou t −−>

<fo : page−sequence master−re ference=" run " i n i t i a l −page−number=" 1 ">

< fo : s t a t i c−content f low−name=" xs l−region−before ">< fo : b lock text−al ign=" end " font−size=" 10 pt " font−f a m i l y = " sans−s e r i f " l i n e−height=" 11 pt "

color=" l i g h t s l a t e g r a y " >< x s l : value−of select=" t i t r e " / > −

<fo : page−number / >< / fo : b lock>< / fo : s t a t i c−content>

<fo : f l ow f low−name=" xs l−region−body " font−size=" 12 pt " l i n e−height=" 11 pt ">

< x s l : apply−templates / >< / fo : f l ow>< / fo : page−sequence>

< / fo : roo t >< / x s l : template>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 39 / 49

Les Listes

Création de listes (bullets, numérotées, etc.)

fo :list-block : contient la liste et contient quelques définitions pour la géométrie

fo :list-item : enfants de fo :list-item, c.a.d. des items qui contiennent un label etun body (voir ci-dessous)

fo :list-item-label : contient le contenu du label (typiquement un fo :block avecun nombre, un caractère dingbat, etc.)

Le fo :list-item-body contient le corps d’un item, un ou plusieurs fo :block

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 40 / 49

Exemple

Une liste d’items

< x s l : template match=" i n g r e d i e n t s ">< fo : b lock color=" navy " font−size=" 12 pt " text−al ign=" j u s t i f y " space−before . optimum=" 15 pt "background−color=" lavender "> Ing réd ien t s : < / fo : b lock>< x s l : apply−templates select=" i n g r e d i e n t " / >< / x s l : template>< x s l : template match=" i n g r e d i e n t ">< fo : l i s t−block space−before . optimum=" 4 pt ">< fo : l i s t−i tem space−before . optimum=" 4 pt ">< fo : l i s t−i tem−label end−i nden t= " labe l−end ( ) ">< fo : b lock> ·< / fo : b lock>< / fo : l i s t−i tem−label><fo : l i s t−i tem−body s t a r t−i nden t= " body−s t a r t ( ) ">< fo : b lock text−al ign=" j u s t i f y " font−size=" 10 pt ">

< x s l : value−of select=" . " / >< / fo : b lock>< / fo : l i s t−i tem−body>< / fo : l i s t−i tem>< / fo : l i s t−block>< / x s l : template>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 41 / 49

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 42 / 49

Les Tables

fo :table-and-captionfo :table-caption : La caption d’une table

fo :table : la table proprement dite. Contient un header et un footer à option etun body.

fo :table-column : permet de specifier la longeur d’une colonne

fo :table-header : Ligne entête, contient des lignes ou cellules

fo :table-footer : Ligne "footer", contient des lignes ou cellules

fo :table-body : contient des lignes ou cellules

fo :table-row : contient des fo :table-cell qui contiennent des fo :blocks

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 43 / 49

Exemple

Un tableau à deux colonnes

< x s l : template match=" gateau ">< fo : table table−l ayou t = " f i x e d " space−before . optimum=" 15 pt ">< fo : table−column column−number=" 1 " column−width=" 5cm" / >< fo : table−column column−number=" 2 " column−width=" 10cm" / >

< fo : table−body><fo : table−row>

<fo : table−c e l l column−number=" 1 ">< fo : b lock space−before . optimum=" 12 pt ">

< fo : ex te rna l−graph ic src=" { @photo } " / >< / fo : b lock>

< / fo : table−c e l l >< fo : table−c e l l column−number=" 2 ">

< fo : b lock color=" navy " font−size=" 16 pt " text−al ign=" center "space−before . optimum=" 15 pt ">

< x s l : apply−templates select=" type " / >< / fo : b lock>

< / fo : table−c e l l >< / fo : table−row>

< / fo : table−body>< / fo : table>

< / x s l : template>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 44 / 49

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 45 / 49

Exemple

Insertion d’un lien

< x s l : template match=" i n t e r n e t ">< fo : b lock color=" navy " font−size=" 12 pt " text−al ign=" j u s t i f y " space−before . optimum=" 12 pt "background−color=" lavender ">S i t e I n t e r n e t :< / fo : b lock>< fo : b lock color=" navy " font−size=" 12 pt " text−al ign=" j u s t i f y " space−before . optimum=" 15 pt ">< fo : basic−l i nk ex te rna l−d e s t i n a t i o n =" { . } ">< x s l : value−of select=" . " / >< / fo : basic−l i nk >< / fo : b lock>< / x s l : template>

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 46 / 49

La moulinette

Comment créer une PDF avec FOPNous avons besoin des sources xml et xslfop.sh -xml name.xml -xsl name2fo.xsl -pdfname.pdfAutres formats : PS, PCL, PNG, RTF et TXT.

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 47 / 49

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 48 / 49

Les processeurs XSL-FO

Quelques outils free ou commerciauxApache Group : FOP

Formating Object ProcessorGénère du PDF http ://xmlgraphics.apache.org/fop/

Antenna HouseXSL Formatter http ://www.antennahouse.com

RenderXGénère du PDF http ://www.renderx.com

AltovaStyleVision http ://www.altova.com/products_xsl.html

XML Mind FO ConverterGénère du RTF http ://www.xmlmind.com/foconverter

AutresArbortext, Adobe, Scriptura, XMLPDF, APOC, XSL-FO to TeX

Luiz Angelo Steffenel (URCA) XSL avancé XSL-FO 49 / 49

Recommended