Cocoon est un "publishing framework" basé XML et écrit en Java
Philosophie de base = séparation des tâches:
Résumé: Cocoon/XSP permet de séparer contenu, "logique" et style.
Vous faites un fichier *.sxml (contenu) et un fichier *.xsl (style)
Vous devez indiquer à Cocoon comment traiter le fichier xml et comment utiliser la feuille de style dans le fichier xsl selon les règles ci-dessous
Fichier XML (extension = *.sxml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="VOTRE_FICHER_XSL.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
Fichier XSL (extension = .xsl):
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
// doit aller DANS le template pour la racine XML !!!
<xsl:template match="VOTRE_RACINE">
<xsl:processing-instruction name="cocoon-format">type="text/html" </xsl:processing-instruction>
......
<?xml version="1.0"?>
<?xml-stylesheet href="hello-page-html.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>
<title>Hello Cocoon friend</title>
<content> ...... </content>
<comment> Written by DKS/Tecfa, adapted from S.M./the Cocoon samples
</comment>
</page>
<?xml version="1.0"?>
<xsl:stylesheet 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:stylesheet>
<?xml version="1.0"?>
<?xml-stylesheet href="ldap.xsl" type="text/xsl"?>
<?cocoon-process type="ldap"?>
<?cocoon-process type="xslt"?>
<page>
<ldap-defs>
<ldap-server name="tecfa">
<initializer>com.sun.jndi.ldap.LdapCtxFactory</initializer>
<ldap-serverurl>ldap://tecfa2.unige.ch:389</ldap-serverurl>
</ldap-server>
<ldap-querydefs name="standard" default="yes"/>
</ldap-defs>
<ldap-query server="tecfa" ldap-searchbase="o=tecfa.unige.ch" defs="standard">
givenname=Daniel
</ldap-query>
</page>
<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet href="dtd/evallist.xsl" type="text/xsl"?>
<?cocoon-process type="xinclude"?>
<?cocoon-process type="xslt"?>
<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"/>
<specification>
<include xinclude:parse="xml" xinclude:href="proj/proj12/specification.xml#xpointer(//specification/evaluation)"/>
</specification>
</page>