cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <dho...@csir.co.za>
Subject Re: html templates - best practise
Date Fri, 03 Oct 2003 11:11:26 GMT
Andrea
 
I agree that the generator will produce the xml data source 
(with the database rows, etc.) - a sample may look like:
 
<?xml version="1.0"?>
<institutionList>
  <institution>
    <institutionName1>testA1</institutionName1>
    <institutionName2>testA2</institutionName2>
  </institution>
  <institution>
    <institutionName1>testB1</institutionName1>
    <institutionName2>testB2</institutionName2>
  </institution>  
</institutionList>
 

Then the XSLT file to transform it might be:
 
<?xml version="1.0"?>
 
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
 
<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>
 
<xsl:template match="institutionList">
<html>
<body>
 
<table class="data">
  <tr>
   <th>Name1</th>
    <th>Name2</th>
    <th>&#160;</th>
  </tr>
  <xsl:for-each select="institution">
    <tr>
      <td><xsl:value-of select="institutionName1"/></td>
      <td><xsl:value-of select="institutionName2"/></td>
       <td>&#160;</td>
    </tr>
  </xsl:for-each>
</table>
 
</body>
</html>
</xsl:template>
 
</xsl:stylesheet> 
 

The designer can modify the XSLT file to create
different layouts as required...
 
Hope this helps.
 
Derek

>>> abo@online.de 03/10/2003 12:30:06 >>>

Thanks derek,
 
that was exactly what I like to know.
i will give you an example:
 
this is an tapestry html template:
<html>
<body>
 
<table class="data">
  <tr>
   <th>Name1</th>
    <th>Name2</th>
    <th>&nbsp;</th>
  </tr>
 <tr jwcid="@Foreach" source="ognl:institutionList" value="ognl:institution" element="tr">
     // iteration over database rows

        <td><span jwcid="@Insert" value="ognl:institution.institutionName1"/></td>
                          /
       <span jwcid="@Insert" value="ognl:institution.institutionName2"/></td>

 </tr>
</table>
 
</body>
</html>
 
this template can be modified by a html designer at any time during development!
If i get a hit on this page, I read the records from the database and tapestry will bind the
data. You may not be familiar with tapestry, but i hope this example is easy to guess.
 
My idea with cocoon was:
The generator will produce the xml data source (with the database rows, etc.) and during transformation
I would like to reference to the template file and bind the dynamic data.
 
 
andreas
 
----- Original Message ----- 
From: Derek Hohls 
To: users@cocoon.apache.org 
Sent: Friday, October 03, 2003 11:30 AM
Subject: Re: html templates - best practise


Andreas
 
Not sure I fully understand  - and so  I may be missing the point
completely... but Cocoon, unlike many other web application
systems does *not* work on a "template" system ... data is 
created in XML (from static and/or dynamic sources) and the
presentation (HTML page layout) is handled via XSLT - it is
likely that you & the designer need to agree as to what parts
of his/her layout need to be encapsulated into the XSLT code
and which parts will be created dynamically via Cocoon
 
Hope this helps - if not, you may have to supply some more
concrete examples of what you are trying to achieve.
 
Derek

>>> abo@online.de 03/10/2003 11:21:06 >>>

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
 

-- 
This message has been scanned for viruses and 
dangerous content by MailScanner, and is 
believed to be clean. 
Mailscanner thanks transtec Computers for their support. 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Mailscanner thanks transtec Computers for their support.


Mime
View raw message