Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014...

46
Lexique Langages & Documents Réfs Techs Smmaire . . . . . . Paul Franchi SI 5 2013-14 03/07/22 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation par règles XSL: Programmation fonctionnelle Production de Documents XSL-FO Processeurs XSLT révision Nov 2013: "trucs": ; nav, uri policy etc. XSL_ASSIST vers text av 
 vers HTML5 mode "toc" call template w. param if test ="Xpath"

Transcript of Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014...

Page 1: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

Langages & Documents RéfsRéfs

TechsTechs

SmmaireSmmaire

..

..

..

..

.

..

Paul FranchiSI 5

2013-14

11/04/23 Transparent - 1

Chap IX -

XSL Transformations

Chap IX -

XSL Transformations

XSL: Programmation par règles

XSL: Programmation fonctionnelle

Production de Documents

XSL-FO

Processeurs XSLT

XSL: Programmation par règles

XSL: Programmation fonctionnelle

Production de Documents

XSL-FO

Processeurs XSLT

révision Nov 2013:"trucs": ; nav, uri policy etc.XSL_ASSISTvers text av 
vers HTML5mode "toc"call template w. paramif test ="Xpath"

Page 2: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

SmmaireSmmaire

LexiqueLexique

RéfsRéfs

TechsTechs

..

..

..

..

.

..

Transparent 211/04/23

Sommaire du Cours

Chap I - Documents: Historique, Modèles, Standards et Références

Chap II - HTML: voir le cours CIP1-CMD & HTML5

Chap III - XML: "eXtensible Markup Language", les Bases

Chap IV - DTD: "Document Type Definition"

Chap V - CSS: Feuilles de Styles en Cascades& CSS3

Chap VI - DOM, DHTML: "Domain Object Model "& Programmation

Dynamique en HTML & SPRY & JQuery

Chap VII - XSD: Schémas XML

Chap VIII - XML "Advanced" Processeurs et Dialectes: XPath, Xlink

Chap IX - XSLT: Transformations XML

Chap X - RDF: "Resource Description Framework"

Chap IX - AJAX: "Asynchronous JavaScript And XML"

Savoir-Faire: Know Hows

HTML XHTML CSS JS+DOM MATHML XPATH XLINK XSLT

Etat de l'art:

HTML5 CSS3 SPRY SVG RDF AJAX XUL

Page 3: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

SmmaireSmmaire

LexiqueLexique

RéfsRéfs

TechsTechs

..

..

..

..

.

..

Transparent 311/04/23

Web XSLT ASSIST (SI4 - Polytech)

W3C tutorial : http://www.w3schools.com/

Mozilla Development Center http://developer.mozilla.org/en/docs/Main_Page

W3C, http://www.w3.org/ Edutech XSL tutoriel, edutechwiki Webucator Tutorial http://www.learn-xslt-tutorial.com Web Developer's Bookmarks http://antriksh.com/resources/

Biblio: XSLT(pdf) XSLT xsltfondamental.pdf many issues at EPU's lib

Some Références

Page 4: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

SmmaireSmmaire

LexiqueLexique

RéfsRéfs

TechsTechs

..

..

..

..

.

..

Transparent 411/04/23

Documentation et Manuels Documents du web

liste de balises HTML

code des couleurs RVB

code HTML des caractères ISO

liste des extensions de fichiers (formats)

Expressions Rationnelles

Manuels. Expressions régulières sous Em

acs

Recherche et remplacement sous Emacs

compléments Emacs

grep sous Unix

Tutoriaux du Web W3C : http://www.w3schools.com/

CSS Play : http://www.cssplay.co.uk/index

Zen Garden :

http://www.csszengarden.com/tr/francais/

CSS in10 steps :

http://www.barelyfitz.com/screencast/html-training/css/positioning/

Edutech XSL tutoriel, edutechwiki

Page 5: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

SmmaireSmmaire

LexiqueLexique

RéfsRéfs

TechsTechs

..

..

..

..

.

..

Transparent 511/04/23

Références Web

Page 6: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

SmmaireSmmaire

LexiqueLexique

RéfsRéfs

TechsTechs

..

..

..

..

.

..

Transparent 611/04/23

API – Application Programming Interface ANSI – American National Standards Institute ASCII – American Standard Code for Information Interchange (128 car.) AJAX – Asynchronous JavaScript & XML CSS – Cascading Style Sheets DHTML – Dynamic HTML DOM – Document Object Model DTD – Document Type Definition HTML – HyperText Markup Language HTTP – HyperText Transfer Protocol ISO - International Standards Organization Mozilla - Fondation (global community for free and open Internet software)) MVC - Model View Controler RDF - Resource Description Framework REST - Representational State Transfer RIA - Rich Internet Application RSS - Really Simple Syndication SGML - Standard Generalized Markup Language SOAP - Simple Access Object Protocol SPRY - Extensions JS pour HTML - Adobe Lab. SVG - Scalable Vector Graphics UNICODE – World wide Code (16 bits) UTF-8 – Unicode version 8 bits URL / URI – Uniform Resource Locator / Identifier XML – eXtensible Markup Language XBL – XML Binding Language (Mozilla) XForms – XML Forms XHTML – HTML 4 en XML XLink – XML Linking Language XPath – XML Path Language XPointer – XML Pointer Language XSL - eXtensible Stylesheet Language XSLT – XSL Transformations XSL-FO – XSL Formatting Objects XSD – XML Schémas Définition Language XUL – XML User Language (Mozilla) W3C – World Wide Web Consortium Web2.0 – Web dit "sémantique" WHATWG - Web Hypertext Application Technology Working Group WSDL - Web Service Description Language

Lexique

Page 7: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

Langages & Documents RéfsRéfs

TechsTechs

SmmaireSmmaire

..

..

..

..

.

..

Paul FranchiSI 5

2013-14

11/04/23 Transparent - 7

Chap IX -

XSL Transformations

Chap IX -

XSL Transformations

XSL: Programmation par règles

XSL: Programmation fonctionnelle

Production de Documents

XSL-FO

Processeurs XSLT

XSL: Programmation par règles

XSL: Programmation fonctionnelle

Production de Documents

XSL-FO

Processeurs XSLT

Page 8: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 811/04/23

XSLT – Xml Transformations (W3C 1999)

Un langage de haut niveau pour spécifier des transformations de documents Xml par remplacement de sous-arbres ("tree templates")

Affichage, présentation, etc vers HTML, XHTML, PDF, etc. Echange de données au format XML Autres besoins: requêtes, contrôles, etc.

Proc. XSLT: MSN, Oracle, Saxon, Xalan, xsltproc()

Un langage de haut niveau pour spécifier des transformations de documents Xml par remplacement de sous-arbres ("tree templates")

Affichage, présentation, etc vers HTML, XHTML, PDF, etc. Echange de données au format XML Autres besoins: requêtes, contrôles, etc.

Proc. XSLT: MSN, Oracle, Saxon, Xalan, xsltproc()

Doc

Source

XML

Parseur

XML

Source XSLT

Doc

Rés.

Code

Html

Xml

Proc.XSLT

XPath

DOM

XSL-FO

Page 9: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 911/04/23

XSLT - une transformation simple

Le source XML en entrée ../XML_CSS/XSLT.xml

Le résultat recherché (en XHTML)

Le source XML en entrée ../XML_CSS/XSLT.xml

Le résultat recherché (en XHTML)

<?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet type="text/xsl" href="message.xsl"?><doc><choix>ROUGE </choix> <choix> VERT </choix> <choix> BLEU </choix></doc>

<html><head> <title>Palette de Couleurs</title> </head><body>

<h1> Palette </h1> <h3> Couleurs possibles </h3> <p> ROUGE </p> <p> VERT </p> <p> BLEU </p>

</body></html>

Page 10: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1011/04/23

XSLT – une transformation simple

Le source XSL ../XML_CSS/XSLT.xml Le source XSL ../XML_CSS/XSLT.xml

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/"><html> <head> <title> Palette de Couleurs</title> </head><body>

<h1> Palette </h1> <h3> Couleurs possibles </h3> <xsl:apply-templates select="choix"/>

</body></html>

</xsl:template>

<xsl:template match="choix"><p><xsl:value-of select="."/></p>

</xsl:template>

</xsl:stylesheet>

Page 11: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1111/04/23

XSL - eXtensible Stylesheet Language.

Eléments Racine (2) <xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:transform version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Eléments "top-level" (12) <xsl:include> <xsl:import> <xsl:output> <xsl:template> <xsl:attribute-set> <xsl:param> <xsl:variable><xsl:preserve-space> <xsl:strip-space> <xsl:key> <xsl:namespace-alias> <xsl:decimal-format>

Eléments "instructions" (22) <xsl:fallback> <xsl:comment> <xsl:processing-instruction> <xsl:element> <xsl:apply-templates> <xsl:value-of> <xsl:attribute> <xsl:number> <xsl:variable> <xsl:text> <xsl:call-template> <xsl:for-each> <xsl:choose> <xsl:if><xsl:otherwise> <xsl:when> <xsl:with-param><xsl:sort> <xsl:copy> <xsl:copy-of> <xsl:message>

Eléments Racine (2) <xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:transform version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Eléments "top-level" (12) <xsl:include> <xsl:import> <xsl:output> <xsl:template> <xsl:attribute-set> <xsl:param> <xsl:variable><xsl:preserve-space> <xsl:strip-space> <xsl:key> <xsl:namespace-alias> <xsl:decimal-format>

Eléments "instructions" (22) <xsl:fallback> <xsl:comment> <xsl:processing-instruction> <xsl:element> <xsl:apply-templates> <xsl:value-of> <xsl:attribute> <xsl:number> <xsl:variable> <xsl:text> <xsl:call-template> <xsl:for-each> <xsl:choose> <xsl:if><xsl:otherwise> <xsl:when> <xsl:with-param><xsl:sort> <xsl:copy> <xsl:copy-of> <xsl:message>

Page 12: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1211/04/23

XSL – Programmation par Règles

racine < xsl:stylesheet … > … </xsl:stylesheet>

Inclusion & Importation de règles< xsl:import href="Package.xsl" />< xsl:include href="Package.xsl" />

application des règles à un noeud< xsl:apply-templates select="A/B" />< xsl:apply-import />

sélection d'un nœud de contexte< xsl:template match= "catalog/cd" > … </ xsl:template >

extraction de valeurs<xsl:value-of-select="." /><xsl:value-of-select="catalog/cd/artist" />

commentaire<xsl:comment> … </xsl:comment>

racine < xsl:stylesheet … > … </xsl:stylesheet>

Inclusion & Importation de règles< xsl:import href="Package.xsl" />< xsl:include href="Package.xsl" />

application des règles à un noeud< xsl:apply-templates select="A/B" />< xsl:apply-import />

sélection d'un nœud de contexte< xsl:template match= "catalog/cd" > … </ xsl:template >

extraction de valeurs<xsl:value-of-select="." /><xsl:value-of-select="catalog/cd/artist" />

commentaire<xsl:comment> … </xsl:comment>

Page 13: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1311/04/23

XSL – Programmation Fonctionnelle (Impérative) définition d'un template

< xsl:template name= "Lister" > … </ xsl:template >

application par appel< xsl:call-templates name="Lister" />

affectation de variables<xsl:variable name='nom_var' select="val" /><xsl:variable name='nom_var' select="pathExp" /><xsl:variable name='epreuve_s' select="//Epreuve" />

utilisation de variables<xsl:value-of select="sum($epreuve_s/Note) div $coeff " />

test < xsl:if test ="ANNEE &gt; 2000 " > …< /xsl:if >< xsl:choose>

…<xsl:when test =" " >…< /xsl:when >…</xsl:choose >

itération<xsl:for-each> …</xsl:for-each >

définition d'un template< xsl:template name= "Lister" > … </ xsl:template >

application par appel< xsl:call-templates name="Lister" />

affectation de variables<xsl:variable name='nom_var' select="val" /><xsl:variable name='nom_var' select="pathExp" /><xsl:variable name='epreuve_s' select="//Epreuve" />

utilisation de variables<xsl:value-of select="sum($epreuve_s/Note) div $coeff " />

test < xsl:if test ="ANNEE &gt; 2000 " > …< /xsl:if >< xsl:choose>

…<xsl:when test =" " >…< /xsl:when >…</xsl:choose >

itération<xsl:for-each> …</xsl:for-each >

Page 14: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1411/04/23

XSLT - le XML

catalogCD.xml catalogCD.xml

<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="catalogCD.xsl"?><catalog>

<cd> <title>Empire Burlesque</title><artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year>

</cd> . ..</catalog>

Page 15: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1511/04/23

XSLT – (v1: incomplet)

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0"

encoding="UTF-8" indent="yes"/><xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> <tr> <td><xsl:value-of select="catalog/cd/title"/></td> <td><xsl:value-of select="catalog/cd/artist"/></td> </tr> </table> </body> </html></xsl:template></xsl:stylesheet> •xsl

Page 16: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1611/04/23

XSLT – (v2: impérative, avec test)<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr>

<xsl:for-each select="catalog/cd"> <xsl:if test="price &gt; 10"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:if> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet>

•xsl

Page 17: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1711/04/23

XSLT – (v3: impérative, avec tri)<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> <xsl:for-each select="catalog/cd"> <xsl:sort select="artist"/> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet>

•xsl

Page 18: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1811/04/23

XSLT – (v4, avec choix)

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td> <xsl:value-of select="title"/> </td> <xsl:choose> <xsl:when test="price &gt; 10"> <td bgcolor="#ff00ff"> <xsl:value-of select="artist"/> </td> </xsl:when> <xsl:otherwise> <td> <xsl:value-of select="artist"/> </td> </xsl:otherwise> </xsl:choose> </tr> </xsl:for-each> </table> </body> </html></xsl:template> </xsl:stylesheet>

•xsl

Page 19: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 1911/04/23

XSLT – (v5& v6: déclarative)

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html> <body> <h2>My CD Collection</h2> <xsl:apply-templates/> </body> </html></xsl:template><xsl:template match="cd"> <p><xsl:apply-templates select="title"/> <xsl:apply-templates select="artist"/></p> </xsl:template><!-- essayer sans les 2 règles ci-dessous --><xsl:template match="title"> Title: <span style="color:#ff0000"> <xsl:value-of select="."/></span> <br /></xsl:template><xsl:template match="artist"> Artist: <span style="color:#00ff00"> <xsl:value-of select="."/></span><br /></xsl:template></xsl:stylesheet>

•xsl

•xsl

Page 20: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2011/04/23

XSL – Règles par défaut pour <xsl:apply-templates>

R1: En l'absence de règle applicable à un élément, la recherche ("matching") s'applique récursivement au

source (dfs: nœuds fils,…) jusqu'aux éléments terminaux ("feuilles" du source XML)

R2: En l'absence de règle applicable, sur un nœud terminal de type texte,

le texte (#PCDATA) est recopié dans le nœud courant de l'arbre généré

R3: Les nœuds de type "processing-instruction" et "commentaire" sont ignorés.

Remarque: les nœuds "indentation" ou "espaces" du document XML source sont examinés suivant le mode de "matching" ("select", "(strip | preserve)-space")

R1: En l'absence de règle applicable à un élément, la recherche ("matching") s'applique récursivement au

source (dfs: nœuds fils,…) jusqu'aux éléments terminaux ("feuilles" du source XML)

R2: En l'absence de règle applicable, sur un nœud terminal de type texte,

le texte (#PCDATA) est recopié dans le nœud courant de l'arbre généré

R3: Les nœuds de type "processing-instruction" et "commentaire" sont ignorés.

Remarque: les nœuds "indentation" ou "espaces" du document XML source sont examinés suivant le mode de "matching" ("select", "(strip | preserve)-space")

Page 21: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2111/04/23

XSLT – Le source XML

catalogCD.xml catalogCD.xml

<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="catalogCD.xsl"?><catalog>

<cd> <title>Empire Burlesque</title><artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year>

</cd> . ..</catalog>

Page 22: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2211/04/23

XSLT – XML vers XML

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="ISO-8859-1" />

<xsl:template match="/"><catalog>

<titre> Mon catalogue de CD </titre> <liste>

<xsl:apply-templates></liste></catalog>

</xsl:template>

</xsl:stylesheet>

Version 1 : "matching" par défaut total Version 1 : "matching" par défaut total

•xsl

Page 23: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2311/04/23

XSLT – XML vers XML

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="ISO-8859-1" /><xsl:template match="/">

<catalog><titre> Mon catalogue de CD </titre> <liste><xsl:apply-templates select=".//ARTIST" /></liste>

</catalog> </xsl:template>

<xsl:template match="ARTIST"><artiste><xsl:apply-templates /></artiste>

</xsl:template>

</xsl:stylesheet>

Version 2 : "matching" par défaut avec "select" Version 2 : "matching" par défaut avec "select"

•xsl

Page 24: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2411/04/23

XSLT – Le source XML (W3C )

CartePtitDej.xml CartePtitDej.xml

<?xml version="1.0" encoding="ISO-8859-1"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price>$7.95</price> <description>light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food><food> <name>Berry-Berry Belgian Waffles</name> <price>$8.95</price> <description>light Belgian waffles covered with fresh berries and whipped cream</description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>$4.50</price> <description>thick slices made from our homemade sourdough bread</description> <calories>600</calories> </food> <food> <name>Homestyle Breakfast</name> <price>$6.95</price> <description>two eggs, bacon or sausage, toast, and our popular hash browns</description> <calories>950</calories> </food> </breakfast_menu>

•xml

Page 25: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2511/04/23

XSLT – Le source XSL

<html xsl:version="1.0"><body style="font-family:Arial,sans-serif;

font-size:12pt; background-color:#EEEEEE"><xsl:for-each select="breakfast_menu/food">

<div style="background-color:teal;color:white;padding:4px"><span style="font-weight:bold;color:white">

<xsl:value-of select="name"/></span><xsl:value-of select="price"/></div><div style="margin-left:20px;margin-bottom:1em;font-size:10pt">

<xsl:value-of select="description"/><span style="font-style:italic">( <xsl:value-of select="calories"/> calories per serving)</span></div>

</xsl:for-each></body></html>

•xsl

CartePtitDej.xsl CartePtitDej.xsl

•xsl

Page 26: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2611/04/23

XSL – Production de Documents Définition du format de sortie

< xsl:output method= " " version=" "encoding=" "indent=" " />

Duplication<xsl:copy> … </xsl:copy><xsl:copy-of> … </xsl:copy-of>

Création de noeuds<xsl:text> … </xsl:text><xsl:element> … </xsl:element><xsl:attribute name="att" > … </ xsl:attribute ><xsl:comment> … </xsl:comment>

Création de liens<xsl:key name=" " match= "/A/B" clé="@att"/> <a href="#{generate-id(artist)}">

Intégration multi-documents avec document (')<xsl:value-of select="document('celsius.xml')/celsius/result[@value=$value]"/>

Définition du format de sortie< xsl:output method= " "

version=" "encoding=" "indent=" " />

Duplication<xsl:copy> … </xsl:copy><xsl:copy-of> … </xsl:copy-of>

Création de noeuds<xsl:text> … </xsl:text><xsl:element> … </xsl:element><xsl:attribute name="att" > … </ xsl:attribute ><xsl:comment> … </xsl:comment>

Création de liens<xsl:key name=" " match= "/A/B" clé="@att"/> <a href="#{generate-id(artist)}">

Intégration multi-documents avec document (')<xsl:value-of select="document('celsius.xml')/celsius/result[@value=$value]"/>

Page 27: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2711/04/23

XSL – Transformations vers Text, Html, Xml

Xml Text <xsl:output method="text" encoding="UTF-8" />

Xml Html <xsl:output method=" html" encoding=" UTF-8 " />

Xml Xml <xsl:output method="xml" encoding=" UTF-8 " />

Xml Xhtml <xsl:output method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional-dtd"doctype-public="-//W3C/DTD XHTML1.0Transitional//EN"encoding=" UTF-8 " indent="yes" />

Xml Text <xsl:output method="text" encoding="UTF-8" />

Xml Html <xsl:output method=" html" encoding=" UTF-8 " />

Xml Xml <xsl:output method="xml" encoding=" UTF-8 " />

Xml Xhtml <xsl:output method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional-dtd"doctype-public="-//W3C/DTD XHTML1.0Transitional//EN"encoding=" UTF-8 " indent="yes" />

Page 28: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2811/04/23

XSLT – XML vers XML + CSS

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="ISO-8859-1" /><xsl:template match="/"><xsl:processing-instruction name="xml-stylesheet">href="catalogCD.css" type="text/css"</xsl:processing-instruction>

<catalog><titre> Mon catalogue de CD </titre>

<liste><xsl:apply-templates>

</liste></catalog>

</xsl:template></xsl:stylesheet>

en associant une feuille CSS en associant une feuille CSS

•xsl

Page 29: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 2911/04/23

XSLT – call template with parameters

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

.... <xsl:template match="CD" > <xsl:if test="ARTIST/@adr"> <xsl:call-template name="faireunlien"> <xsl:with-param name="texte" select="concat(TITLE,' - ', ARTIST)" /> <xsl:with-param name="url" select="ARTIST/@adr" /> </xsl:call-template></xsl:if> </xsl:template>

<xsl:template name="faireunlien"> <xsl:param name="url" /> <xsl:param name="texte" /> <a href="{$url}"> <xsl:value-of select="$texte" /> </a></xsl:template>

</xsl:stylesheet>•xsl

Page 30: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3011/04/23

<?xml version="1.0" encoding="UTF-8"?>

<xsl:template match="/"

°°° <toc> Table of Liens <xsl:apply-templates select="//CD" mode="toc"/> </toc> <xsl:apply-templates />

°°°</xsl:template>

<xsl:template match="CD" mode="toc">

<xsl:call-template name="faireunlien">

°°°</xsl:call-template></xsl:template>.... </xsl:stylesheet>

XSLT – "Double Passe pour ToC"

<xsl:template match="CD"> <node><xsl:value-of select="TITLE" /> [<xsl:value-of select="ARTIST" />] <xsl:apply-templates select="YEAR | COUNTRY | COMPANY " /> </node></xsl:template></xsl:stylesheet>

•xsl

Page 31: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3111/04/23

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text"/>

.... <xsl:template match="CATALOG//*">

<xsl:for-each select="ancestor::*"> <xsl:text>&#09;</xsl:text> <!-- tabulation --></xsl:for-each><xsl:number level="multiple" count="*" from="CATALOG"/> <xsl:number level="multiple" count="*" format="I.A.i.a. "/>

<xsl:value-of select="text()"/> <xsl:text>&#10; </xsl:text> <!-- retour chariot -->

</xsl:template>.... </xsl:stylesheet>

XSLT – Numérotation

•xsl

Page 32: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3211/04/23

XSLT – la copie "intégrale" Xml vers Xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- copie XSL "intégrale" de XML vers XML les instructions de styles d'origine CSS sont recopiées mais non interprétées pendant la transformation XSL-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" indent="yes"/>

<xsl:template match="*|@*"> <!-- tous les types de nœuds --> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>

</xsl:stylesheet> •xsl

Page 33: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3311/04/23

XSLT – la copie "rebalisée" Xml vers Xml

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" indent="yes"/><xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>

<xsl:template match="comment()" ><COM> <xsl:value-of select="." /> </COM></xsl:template>

<xsl:template match="processing-instruction()" ><STYLE> <xsl:value-of select="." /> </STYLE></xsl:template>

</xsl:stylesheet> •xsl

Page 34: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3411/04/23

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" indent="yes"/><xsl:template match="*|@*"> <xsl:processing-instruction name="xml-stylesheet">href="bib.css" type="text/css"</xsl:processing-instruction><html xmlns="http://www.w3.org/1999/xhtml"><style>COM{} STYLE{} Authors Author{} </style><body> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </body></html><xsl:template match="comment()" ><COM><xsl:value-of select="." /> </COM></xsl:template>

<xsl:template match="processing-instruction()" ><STYLE> <xsl:value-of select="." /> </STYLE></xsl:template></xsl:stylesheet> •xsl

XSLT – la copie "reStylée"

Xml vers Xhtml

Page 35: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3511/04/23

XSLT – Variables

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" indent="yes"/>

<xsl:template match="Mois"><xsl:variable name="mID" select="@id"/><xsl:variable name="mHREF" select="@href"/>

<div class="Mois"><a href="{$mHREF}"><div id="{$mID}" class="Bouton"><xsl:value-of select="@id"/></div></a></div>

</xsl:template>

</xsl:stylesheet>

.xsl

Page 36: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3611/04/23

XSLT - Attributs

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" indent="yes"/>

<xsl:variable name="DIR"><xsl:value-of select="Bib/@cover"/></xsl:variable>

<xsl:element name="input" use-attribute-sets="attrs"/><xsl:template match="Bib"></xsl:template>

<xsl:attribute-set name="attrs"><xsl:attribute name="onClick">doIt(2, ' <xsl:value-of select="$DIR"/>/<xsl:value-of select="@img"/>') </xsl:attribute></xsl:attribute-set>

</xsl:stylesheet>.xsl

Page 37: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3711/04/23

XSLT - Réaliser une importation XML

<?xml version="1.0" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/

1999/XSL/Transform"><xsl:template match="/"> <xsl:variable name="imp" select="document(//import/@href)" /><liste># Auteurs: <xsl:value-of select="count(//Author)" /># <xsl:apply-templates select="$imp/*" /></liste>…</xsl:stylesheet >

<?xml version="1.0" encoding="ISO-8859-1"?><AuthorsIndex dom="XML"> <Author aut_id="1">Bernd Amann</Author> <Author aut_id="2">Philippe Rigaux</Author> </AuthorsIndex>

<?xml version="1.0" ?><?xml-stylesheet type="text/xsl" href="copieAvecImport.xsl"?><Bib dom="XML"><import href="auteurs.xml" /><Article> … </Article></Bib>

.xml

.xml

.xsl

Page 38: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3811/04/23

<html><body>

<script type="text/javascript">

// Load XML var xml = new ActiveXObject("Microsoft.XMLDOM")xml.async = falsexml.load("cdcatalog.xml")

// Load XSLvar xsl = new ActiveXObject("Microsoft.XMLDOM")xsl.async = falsexsl.load("cdcatalog.xsl")

// Transformdocument.write(xml.transformNode(xsl))

</script>

</body></html>

.xsl

XSLT – Appliquer avec JavaScript

Page 39: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 3911/04/23

XSLT "Fragment" avec JS+DOM function transform (xml, xsl, id) { try { // navigateur basé sur Gecko if (window.XSLTProcessor) { var fragment; var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); fragment = xsltProcessor.transformToFragment(xml, document); var target = document.getElementById(id); target.innerHTML = fragment.firstChild.innerHTML ; // pfz //target.appendChild(fragment); //orig //document.replaceChild(target, fragment); //orig

// ActiveX pour Internet Explorer } else if (window.ActiveXObject) { var target = document.getElementById(id); target.innerHTML = xml.transformNode(xsl); } } catch (e) {return e;}}

<script type="text/javascript">

var XML=

loadXML(xmlURL);

var XSL=

loadXML(xslURL);

function doTheJob()

{

transform (XML, XSL, 'ICI');

....

}

</script>

XSLT

.js

Page 40: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4011/04/23

XSL-FO – un dialecte de formatage pour Xml

Les modèles de mise en page< fo:layout-master-set >

orientation, tailles, découpage, marges, etc.

Les séquences de pages< fo:page-sequence >

chapitre ou ensemble continu du document qui doit être affiché sur autant de page que nécessaire

Les flux< fo:flow > un ou plusieurs flux sur la même séquence de

page

Les paragraphes (ou blocs)< fo:block > un paragraphe de texte

Les modèles de mise en page< fo:layout-master-set >

orientation, tailles, découpage, marges, etc.

Les séquences de pages< fo:page-sequence >

chapitre ou ensemble continu du document qui doit être affiché sur autant de page que nécessaire

Les flux< fo:flow > un ou plusieurs flux sur la même séquence de

page

Les paragraphes (ou blocs)< fo:block > un paragraphe de texte

Page 41: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4111/04/23

XSL-FO – un dialecte de formatage pour Xml Le modèle Le modèle

<?xml version="1.0" encoding="ISO-8859-1"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-set>

<!– ici les modèles de mise en page --></ fo:layout-master-set> <!– une suite de page --><fo:page-sequence master='ce_modele'>

<!– un flux --><fo:flow name='xsl-region' font-size='12pt' >

<!– un paragraphe --><fo:block >

ICI LE CONTENU TEXTE</fo:block >

</fo:flow ></fo:page-sequence ></fo:root>

Page 42: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4211/04/23

XSLT : savoir-faire

Production de Documents XML vers XML XML vers (X)HTML XML vers Text

Styler avec HTML+CSS avec XML + CSS

Transformer XML: Duplication, Extraction,

Filtrage, Importation RDF vers XML SVG vers XHTML MathML vers XHTML

XML vers DHTML avec JS+DOM

XML vers DXML modifier DOM du XML source modifier DOM du XSL source

Production de Documents XML vers XML XML vers (X)HTML XML vers Text

Styler avec HTML+CSS avec XML + CSS

Transformer XML: Duplication, Extraction,

Filtrage, Importation RDF vers XML SVG vers XHTML MathML vers XHTML

XML vers DHTML avec JS+DOM

XML vers DXML modifier DOM du XML source modifier DOM du XSL source

sur le Web W3Schools - XSL Tuto

rial XSLT- developpez.co

m XSL avec Café con lec

he Edutech XSL tutoriel,

edutechwiki

.xsl

.xsl

.xsl

.xsl

XSL

Page 43: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4311/04/23

XSLT "inside" RefsWeb TechnosWeb DocExShow

XSLT ASSIST ss PHP/SQL(SI4 project)

ShowML & SI4 Project Log

Rendus SI4

Sites Web (ébauches)

PFZ 2011 "state of the art" sous HTML5

RefsWeb TechnosWeb DocExShow

XSLT ASSIST ss PHP/SQL(SI4 project)

ShowML & SI4 Project Log

Rendus SI4

Sites Web (ébauches)

PFZ 2011 "state of the art" sous HTML5

XSL

XSL

XSL.xsl

Page 44: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4411/04/23

Quelques Environnements XSLT

Mozilla - Firefox 1.5 => 25.0

SAFARI 5.0

I.E. 6. = > I.E. 10, Google Chrome avec des restrictions sur les fichiers "locaux"

Editix XSLT 2.0 http://www.editix.com/ Altova XSLT 2.0 http://www.altova.com/

Le projet Apache – APIs Java http://xml.apache.org/ Xerces – analyseurs XML, Dom, Sax, Xpath Xalan – processeur XSLT 1.0 FOP – formateur XSL-FO vers PDF

Le projet Gnome (GNU) – Lib C/C++ http://xmlsoft.org/ libxml2 – analyseurs XML, Dom, Sax, Xpath libxslt – processeur XSLT 1.0 xmllint & xmlcatalog

Mozilla - Firefox 1.5 => 25.0

SAFARI 5.0

I.E. 6. = > I.E. 10, Google Chrome avec des restrictions sur les fichiers "locaux"

Editix XSLT 2.0 http://www.editix.com/ Altova XSLT 2.0 http://www.altova.com/

Le projet Apache – APIs Java http://xml.apache.org/ Xerces – analyseurs XML, Dom, Sax, Xpath Xalan – processeur XSLT 1.0 FOP – formateur XSL-FO vers PDF

Le projet Gnome (GNU) – Lib C/C++ http://xmlsoft.org/ libxml2 – analyseurs XML, Dom, Sax, Xpath libxslt – processeur XSLT 1.0 xmllint & xmlcatalog

Page 45: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4511/04/23

Quelques Processeurs XSLT

xsltproc() ss linuxhttp://linux.about.com/library/cmd/blcmdl1_xslthttp://xmlsoft.org/XSLT/

Saxon XSL 1.0 & Xpath 1.0http://saxon.sourceforge.net/

Xalan pour C++ & Javahttp://xml.apache.org/xalan-j/http://xml.apache.org/xalan-c/

XML Parser for C, for Java, for PL/SQLhttp://www.oracle.com/technology/

tech/xml

Koala XSL Engine avec Sax 1.0 et Dom 1.0http://koala.inria.fr/XML/xslProcessor/

xsltproc() ss linuxhttp://linux.about.com/library/cmd/blcmdl1_xslthttp://xmlsoft.org/XSLT/

Saxon XSL 1.0 & Xpath 1.0http://saxon.sourceforge.net/

Xalan pour C++ & Javahttp://xml.apache.org/xalan-j/http://xml.apache.org/xalan-c/

XML Parser for C, for Java, for PL/SQLhttp://www.oracle.com/technology/

tech/xml

Koala XSL Engine avec Sax 1.0 et Dom 1.0http://koala.inria.fr/XML/xslProcessor/

Page 46: Lexique Langages & Documents Réfs Techs Smmaire...... Paul Franchi SI 5 2013-14 13/01/2014 Transparent - 1 Chap IX - XSL Transformations XSL: Programmation.

LexiqueLexique

XSLT - une transformation simple

Programmation par Règles

XSLT – la copie "intégrale" Xml vers Xml

XSLT – Variables

XSL - eXtensible Stylesheet Language.

XSL – Règles par défaut pour <xsl:apply-templates>

XSLT - Attributs

XSLT "Fragment" avec JS+DOM

Programmation Fonctionnelle (Impérative)

RéfsRéfs

TechsTechs

SmmaireSmmaire

XSL-FO – un dialecte de formatage pour Xml

Transparent 4611/04/23

Quelques "trucs" à savoir ...

XSLT côté serveur Google Chrome ne supporte que les XSLT "servies",

donc pas de fichiers locaux I.E. refuse le mélange fichier locaux et distants dans

une XSLT

Exporter le bon type MIME peut nécessiter une défintion dans .htaccess côté

serveur

Dans FF, pour utiliser des feuilles XSL, non placées dans la sous arborescence XML Changer dans "about:config" "fileuri strict security

policy" à "false"

XSLT côté serveur Google Chrome ne supporte que les XSLT "servies",

donc pas de fichiers locaux I.E. refuse le mélange fichier locaux et distants dans

une XSLT

Exporter le bon type MIME peut nécessiter une défintion dans .htaccess côté

serveur

Dans FF, pour utiliser des feuilles XSL, non placées dans la sous arborescence XML Changer dans "about:config" "fileuri strict security

policy" à "false"