PREVIOUS UP   Technologies Internet et Education, © TECFA
  6. XML + XSL avec Cocoon

6. XML + XSL avec Cocoon

6.1 Cocoon (simple) @ TECFA

Voici la procédure:
 <xsl:processing-instruction name="cocoon-format">type="text/html"
</xsl:processing-instruction>

6.2 Exemples

Exemple 6-1: Sensibilisation XML + XSLT

A. La grammaire (le DTD)

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<!ELEMENT page (title, content, comment?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ELEMENT comment (#PCDATA)>

B. Le fichier XML

 
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="hello-page-html.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
 
<page>
 <title>Hello Cocoon friend</title>
 <content>
  Here is some content. Olé !
 </content> 
 <comment>
      Written by DKS/Tecfa, adapted from S.M./the Cocoon samples
 </comment>
</page>

C. Le fichier XSLT

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="page">
   <xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction>
   <html>
    <head>
     <title> <xsl:value-of select="title"/> </title>
    </head>
    <body bgcolor="#ffffff">
     <xsl:apply-templates/>
    </body>
   </html>
 
  </xsl:template>
  <xsl:template match="title">
   <h1 align="center">
    <xsl:apply-templates/>
   </h1>
  </xsl:template>
  <xsl:template match="content">
   <p align="center">
     <xsl:apply-templates/>
   </p>
  </xsl:template>
  <xsl:template match="comment">
   <hr />
     <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>

Exemple 6-2: Plans de cours

Exemple 6-3: Project Management


PREVIOUS UP -- TIE