<xsl:apply-templates select="title"/>
<xsl:apply-templates select="tc-courses/tc-course[position()=1]/course-module[position()=2]"/>
<!ENTITY pm "Patrick Mendelsohn">
<!ENTITY acirc "Â">
<!ENTITY espace " ">
<!ENTITY copyright "©">
<!ENTITY explication SYSTEM "citation.xml">
Ensuite, on fait une référence du style "&nom_paramètre;":
<para> ± sort du château <para>
<para>Il lit &explication </para>
<para> Patrick Mendelsohn sort du château<para>
<para> Il lit:
<citation> blabla bla </citation>
<!-- (le contenu du fichier citation.xml -->
</para>
<page xmlns:xinclude ="http://www.w3.org/1999/XML/xinclude">
<include xinclude:parse ="xml" xinclude:href ="proj/proj1/info.xml"/>
<specification>
<include xinclude:parse ="xml" xinclude:href ="proj/proj1/ specification.xml#xpointer(//specification/evaluation)"/>
</specification>
.....
<include xinclude:parse="xml" xinclude:href="proj/proj12/info.xml"/>
......
</page>
<commentaire> xxxx </commentaire>
<DL>
<DT>Commentaire </DT>
<DD> xxxx </DD>
</DL>
<xsl:template match="/">
<html> <body>
<xsl:apply-templates/>
</body> </html>
</xsl:template>
<xsl:template match="page">
<xsl:apply-templates select="title"/>
</xsl:template>
<xsl:template match="project">
<P>
<xsl:value-of select="problem/title"/>
</P>
</xsl:template>
Syntaxe spéciale pour insérer la valeur d'un objet dans un string d'attribut utilisé dans l'output d'un template: {....}
<xsl:template match="contact-info">
....
<a href="mailto:{@email}"><xsl:value-of select="@email"/></a>
...
<xsl:template match="p">
<xsl:copy> <xsl:apply-templates/> </xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>Garbage: <i> <xsl:apply-templates/> </i> </xsl:copy>
</xsl:template>
<xsl:template match="animal">
Nom:<xsl:value-or select="@name"/>
<br> Couleurs:
<xsl:value-of select="couleur"/>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:template>
<animal name="zebre"> <couleur>noir</couleur> <couleur>blanc</couleur> <couleur>bleu</couleur> </animal>
Nom: zebre
Couleur: noir, blanc, bleu
<xsl:template match="animal">
<xsl:choose>
<xsl:when test="@couleur='noir'">
<P style="color:black">
<xsl:value-of select="."/>
</P>
</xsl:when>
<xsl:when test="@couleur='bleu'">
<P style="color:blue">
<xsl:value-of select="."/>
</P>
</xsl:when>
<xsl:when test="pattern">
...
</xsl:when>
<xsl:otherwise>
<P style="color:green">
<xsl:value-of select="."/>
</P>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ROWSET">
<table border="2" cellspacing="1" cellpadding="6">
<xsl:for-each select="ROW"> <tr>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="login"/></td>
<td><xsl:value-of select="fullname"/></td>
<td bgcolor="tan"><a href="{url}"><xsl:value-of select="url"/></a></td>
<td><xsl:value-of select="food"/></td>
<td><xsl:value-of select="work"/></td>
<td><xsl:value-of select="love"/></td>
<td><xsl:value-of select="leisure"/></td>
</tr> </xsl:for-each>
</table>
</xsl:template>
<page>
<title>Hello Apache/FOP and Apache/Cocoon friends</title>
<content>
Here is some content. It should work with FOP 0.18 (and hopefully above).
It is totally uninteresting. It is totally uninteresting. ... </content>
<content>
Here is some more content.
It is slightly uninteresting. .... :)
</content>
<comment>Written by DKS/Tecfa 6/01</comment>
</page>
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0" >
<!-- rule for the whole document: root element is page -->
<xsl:template match="page">
<fo:root>
<fo:layout-master-set>
<!-- Definition of a single master page. It is simple (no headers etc.) -->
<fo:simple-page-master
master-name="first "
margin-left="2cm" margin-right="2cm"
margin-bottom="0.5cm" margin-top="0.75cm"
page-width="21cm" page-height="29.7cm"
>
<!-- required element body -->
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- Definition of a page sequence -->
<fo:page-sequence master-name="first">
<fo:flow flow-name="xsl-region-body" font-size="14pt" line-height="14pt">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!-- A series of XSLT rules that produce fo:blocks to be inserted above -->
<xsl:template match="page/title">
<fo:block font-size="36pt" text-align="center" line-height="40pt" space-before="0.5cm" space-after="1.0cm">
<xsl:apply-templates/></fo:block>
</xsl:template>
<xsl:template match="content">
<fo:block text-align="justify" space-before="0.5cm">
<xsl:apply-templates/></fo:block>
</xsl:template>
<xsl:template match="comment">
<fo:block font-size="12pt" text-align="start" space-before="0.7cm" font-style="italic">
<xsl:apply-templates/></fo:block>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="page">
<fo:root>
<fo:layout-master-set>
<!-- Definition of a single master page. It is simple (no headers etc.) -->
<fo:simple-page-master
master-name="first " >
<!-- required element body -->
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- Definition of a page sequence -->
<fo:page-sequence master-name="first">
<fo:flow flow-name="xsl-region-body" font-size="14pt" line-height="14pt">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</fo:layout-master-set>
.......
<fo:page-sequence-master master-name="run">
<fo:repeatable-page-master-alternatives maximum-repeats="no-limit" >
<fo:conditional-page-master-reference
master-name="left"
odd-or-even="even" />
<fo:conditional-page-master-reference
master-name="right"
odd-or-even="odd" />
<fo:conditional-page-master-reference
master-name="title"
/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
page > title {
display: block;
text-align: center; line-height: 40pt; ....
}
<xsl:template match="page/title">
<fo:block font-size="36pt" text-align="center"
line-height="40pt" space-before="0.5cm"
space-after="1.0cm">
<xsl:apply-templates/></fo:block>
</xsl:template>
<fo:block font-size="36pt" text-align="center"
line-height="40pt" space-before="0.5cm"
space-after="1.0cm">
Hello Apache/FOP and Apache/Cocoon friends
</fo:block>