cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "michael bolger" <mpbol...@earthlink.net>
Subject Re: Nobody likes newbiis :(
Date Fri, 23 Jun 2000 05:00:07 GMT
Søren Neigaard wrote>

>
> What is a xsp file, is it the same as an producer? Could you please give
me
> a example of an xsp file, I cant seem to figure it out.
>
> Med Venlig Hilsen / Kind regards
> Søren Neigaard

i think Ricardo Rocha wrote this ? - last fall  :)michael

Consider the following XML source document:

     <?xml version="1.0"?>

    <page>
      <title>A Simple XSP Page</title>
      <p>Hi, I've been hit <counter/> times.</p>
    </page>




This simple example shows the power of content/logic/style separation. While
the <<title>> tag has a very special meaning in the page document type,
indicating the page title, the <<counter>> element is needs to be
dynamically substituted by the number of times the document has been
requested. The logic that performs such behavior is included in tag itself,
but unlike other existing server side technologies, the behavior is not
defined in the page itself, but on the logic sheet that is applied to
evaluate this behavior. In fact, the same page may have a totally different
behavior depending on the logicsheet that is applied to the page. Note that
it's beyond the scope of this specification to define a way to associate
transformation sheets to pages. The associated logicsheet that uses the Java
language as logic definition may look like:


 <?xml version="1.0"?>
<xsl:transformation
 xmlns:xsl="http://www.w3.org/1999/XSL/tranform"
 xmlns:xsp="http://www.apache.org/1999/XSP/Layer1"
 result-ns="http://www.apache.org/1999/XSP/Layer1"
>

 <xsl:template match="page">
  <xsp:page language="java">

   <xsp:structure>
    <xsp:include>java.lang.*</xsp:include>
   </xsp:structure>

   <xsp:logic>
    private static int counter = 0;

    private synchronized int currentCount()

      return ++counter;
    }
   </xsp:logic>

   <xsp:content>
    <page>
     <xsl:apply-templates/>
    </page>
   </xsp:content>
  </xsp:page>
 </xsl:template>

 <xsl:template match="counter">
  <xsp:expr>currentCount()</xsp:expr>
 </xsl:template>

 <!-- Transcribe everything else verbatim -->
 <xsl:template match="*|@*|comment()|pi()|text()">
  <xsl:copy>
   <xsl:apply-templates/>
  </xsl:copy>
 </xsl:template>
</xsl:transformation>




After applying the above logic sheet, the resulting document would be
equivalent to the following:


 <xsp:page
 result-ns="http://www.dummy.org/SimpleHomepageDTD"
 language="java">

 <xsp:structure>
  <xsp:include>java.lang.*</xsp:include>
 </xsp:structure>

 <xsp:logic>
  private static int counter = 0;

  private synchronized int currentCount()

    return ++counter;
  }
 </xsp:logic>

 <xsp:content>
  <page>
   <title>A Sample XSP Page</title>
   <p>
    Hi, I've been hit
     <xsp:expr>currentCount()</xsp:expr>
    times.
   </p>
  </page>
 </xsp:content>
</xsp:page>






Mime
View raw message