UP PREVIOUS NEXT   Technologies Internet et Education, © TECFA
  5. Formattage des blocs et éléments spéciaux

5. Formattage des blocs et éléments spéciaux

Exemple 5-1: Formattage CSS vs. XSL

CSS:

page > title {
		display: block;
		text-align: center; line-height: 40pt; ....
}
 

XSLT/FO:

 <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 simple:

 <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>

5.1 Listes

 

Exemple 5-2: Une simple "bullet-list"

 
 <xsl:template match="session-materials">
 
  Matériaux de cours:    
  <fo:list-block
 space-before.optimum="6pt">
   <xsl:apply-templates select="session-material"/>
  </fo:list-block
>
 </xsl:template>
 
 <xsl:template match="session-material">
  <fo:list-item
 space-before.optimum="8pt">
    <fo:list-item-label
 end-indent="label-end()">
    <fo:block>&#x2022;</fo:block>
   </fo:list-item-label
>
   <fo:list-item-body
 start-indent="body-start()">
    <fo:block text-align="justify">
     <xsl:value-of select="@material-title"/>
    </fo:block>
    <fo:block text-align="justify" font-size="10pt">
     (URL:<xsl:value-of select="@material-url"/>)
     <xsl:value-of select="@material-comment"/>
    </fo:block>
   </fo:list-item-body
>
  </fo:list-item>
</xsl:template>

5.2 Tables

 

Exemple 5-3: Table à deux colonnes fixes

 <xsl:template match="session">
  <fo:table
 space-before.optimum="6pt" text-align="center">
   <fo:table-column
 column-width="3cm"/> <fo:table-column
 column-width="13cm"/>
   <fo:table-body>
    <fo:table-row 
space-before.optimum="6pt">
     <fo:table-cell
>
      <fo:block font-size="12pt" text-align="start" space-before.optimum="5pt"><xsl:value-of select="session-date/@session-day"/>/<xsl:value-of select="session-date/@session-month"/>/<xsl:value-of select="session-date/@session-year"/></fo:block>
      <fo:block font-size="12pt" text-align="start" space-before.optimum="5pt"><xsl:value-of select="session-component[position()=1]/starthour"/> - 
       <xsl:value-of select="session-component[position()=last()]/endhour"/>    </fo:block>
     </fo:table-cell
>
     <fo:table-cell
>
      <fo:block color="olive" font-size="12pt" text-align="start" space-before.optimum="5pt"><xsl:value-of select="session-title"/>
      </fo:block>
      <fo:block font-size="12pt" text-align="start" space-before.optimum="5pt"><xsl:apply-templates select="session-component"/>
      </fo:block>
     </fo:table-cell
>
    </fo:table-row
>
   </fo:table-body
>  </fo:table>

UP PREVIOUS NEXT -- TIE