I believe I am doing exactly what you are asking.  We use an html skeleton that contains span tags wherever dynamic content is to go. We have a pipeline that aggregates the html (converted to XHTML by the HTMLGenerator) along with the XML form of our Data Transfer Objects as created by Betwixt.  This is then transformed by a stylesheet that imports the following stylesheet. This stylesheet echos all the html until it finds a span tag. It then uses the id to process the DTO using the stylesheet that imported this one.
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:template match="/">
  <xsl:apply-templates select="/page/html"/>
</xsl:template>
 
<xsl:template match="/page/html">
      <xsl:apply-templates select="@*|node()" />
</xsl:template>
 
<xsl:template match="/page/html//@*">
  <xsl:copy />
</xsl:template>
 
<xsl:template match="/page/html//node()">
  <xsl:choose>
    <xsl:when test="name()='span'">
      <span>
        <xsl:copy-of select="@*[not(name()='id')]"/>
        <xsl:variable name="actionName" select="@id"/>
        <xsl:apply-templates select="/page/*[name() = $actionName]"/>
      </span>
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy>
        <xsl:apply-templates select="@*|node()" />
      </xsl:copy>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
 
</xsl:stylesheet>
-----Original Message-----
From: Andreas Bohnert [mailto:[EMAIL PROTECTED]
Sent: Friday, October 03, 2003 2:21 AM
To: [EMAIL PROTECTED]
Subject: html templates - best practise

Hi,
 
i read a lot of tutorials and docs about cocoon and i really like it, but I still don't know, what's the best practise to handle html templates.
 
I get the static part of my html page from a html designer and I want to leave it untouched, so the designer can modify it later on. Of course, some place holders and template instructions should be in there, to put the dynamic part into the right place.
 
maybe this strict seperation( html design <-> java/xml programming) is against the philosophie of cocoon, because I understand:
all required data (static+dynamic) should be put in the xml datasource with the generator and during the transformation process this data will be mixed with html(or wap or pdf) language specific parts.
 
so, how do you handle this?
any suggestions/comments are welcome!!
 
thanks very much
Andreas
 

Reply via email to