You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robin Green <gr...@hotmail.com> on 2000/04/02 21:17:05 UTC

Could someone explain the concept of logicsheets?

I'm still stumbling around in the dark quite a bit with Cocoon. I've heard 
of logicsheets, but I'm not sure what they are or what they do. Yes, I know, 
there are examples - but they're not very well-commented yet, so I thought 
I'd ask, to avoid blind alleys (I've been down enough blind alleys in the 
past few weeks! :) )

This is what I do so far. This is part of an unfinished web-bulletin-board 
app (a bit like Ultimate Bulletin Board or WebX) - the page in question just 
displays a thread. Like I said, I'm stumbling around in the dark, not sure 
if this is a good method.

Is my stylesheet similar to a logicsheet? How would using the 
<?xml-logicsheet?> sheet tag change how I do this?

Here is my "producer" page:

<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="xsl/fypUtils-xsp.xsl" type="text/xsl"?>
<postprocess stylesheet="xsl/ThreadToHTMLCSS1.xsl">
  <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
    <thread>
      <add-node-if-not-null>new ThreadToXML ().getAllPosts (document)
      </add-node-if-not-null>
    </thread>
  </xsp:page>
</postprocess>

This is not ready to be compiled into Java by XSP yet. It is first 
transformed by this XSLT stylesheet (which I created in order to reuse stuff 
across pages):

?xml version="1.0"?>

<!-- Generic utility tags -->

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>

  <xsl:template match="postprocess">

    <xsl:processing-instruction name="cocoon-process">type="xsp"
    </xsl:processing-instruction>

    <xsl:processing-instruction name="cocoon-process">type="xslt"
    </xsl:processing-instruction>

    <xsl:processing-instruction name="xml-stylesheet">
      href="<xsl:value-of select="@stylesheet"/>"
      type="text/xsl"
    </xsl:processing-instruction>

    <xsl:apply-templates/>

  </xsl:template>

  <xsl:template match="xsp:page">
    <xsl:copy>
      <xsp:structure>
        <xsp:include>fyp.*</xsp:include>
      </xsp:structure>

      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="add-node">
    <xsp:logic>
      xspCurrentNode.appendChild(
	<xsl:apply-templates/>
      );
    </xsp:logic>

  </xsl:template>

  <xsl:template match="add-node-if-not-null">
    <xsp:logic>
      Element e = <xsl:apply-templates/>;
      if (e != null) xspCurrentNode.appendChild (e);
    </xsp:logic>
  </xsl:template>

  <!-- Copy everything else: -->
  <xsl:template match="@*" priority="-100">
    <xsl:copy/>
  </xsl:template>

  <xsl:template match="*" priority="-100">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com