cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Rocha <rica...@apache.org>
Subject Re: Comments on XSP 1.1 (long)
Date Tue, 31 Oct 2000 15:49:45 GMT
Oops! Sorry guys, I mistakenly hit the "send" button before the
message was complete. Here I go again...

*** Adding a logicsheet language (SiLLy, Simple Logicsheet Language) ***

This is probably the most important change in this proposal.

Being consistent with the spirit of the first XSP implementation,
logicsheets should be associated with XSP pages _only_ by means
of namespace reaction

This means we should deprecate the <?xml-logicsheet?> pi and relay
exclusively on namespaces as the only way to associate an XSP page
with one or more logicsheets.

Logicsheets can de described as a collection of rules that govern
the substitution of dynamic, namespace-qualified tags to equivalent
XSP code generation directives (<xsp:expr> and <xsp:logic>) as well
as to dynamic tags _defined by other logicsheets_.

This means that a logicsheet may depend on one or more other
logicsheets when one or more of its substitution rules emit markup
expressions containing dynamic tags defined, in turn, by another
logicsheet.

XSP pages need only include those logicsheets explicitly used by
the document. If any of these included logicsheet happens to include
another one in turn, this should be transparent to the original
XSP page. In particular, XSP's shouldn't need to declare namespaces
other than those corresponding to logicsheets explicitly used in
the document. This is also true of the XSP namespace itself.

Thus, given the following XSP page:

  <?xml version="1.0"?>
  <page xmlns:util="http://xml.apache.org/util">
    <title>A Simple XSP Page</title>
    <p>
      Hi! I'm an XSP page and, to the best of my knowledge,
      it's now <util:system-time format="hh:mm:ss"/>.
    </p>
  </page>

the corresponding "util.sll"
 logicsheet may look like:

  <sll:logicsheet namespace-uri="http://xml.apache.org/util"
     xmlns:sll="http://xml.apache.org/sll"
     xmlns:xsp="http://xml.apache.org/xsp"
     xmlns:util="http://xml.apache.org/util"
     xmlns:request="http://xml.apache.org/servlet/request">

    <xsp:structure>
      <xsp:import>Util</xsp:import>
    </xsp:structure>

    <sll:element name="system-time">
      <sll:parameter name="format">
        <sll:default>
          <request:parameter name="format" default="hh:mm:ss"/>
        </sll:default>
      </sll:parameter>
      <sll:body>
        <xsp:expr>
          Util.systemTime(<sll:parameter-value name="format"/>)
        </xsp:expr>
      </sll:body>
    </sll:element>
  </sll:logicsheet>


which, as can be seen, makes uses the "request" logicsheet to
attempt to use a format specified as an Http request parameter
(if provided).

SLL parameters may be specified as either attributes or nested
elements (depending on whether their value is known at compile
or request time). Thus, the following 3 forms are all correct:

  <!-- Attribute notation -->
  <util:system-time format="hh:mm:ss"/>

  <!-- Nested element notation, static value -->
  <util:system-time>
    <util:format>hh:mm:ss</util:format>
  </util:system-time>

  <!-- Nested element notation, dynamic value -->
  <util:system-time>
    <util:format>
      <request:parameter name="format" default="hh:mm:ss"/>
    </util:format>
  </util:system-time>

NOTE: Implementation-wise, logicsheets may be "preprocessed" to
      XSLT stylesheets, but this is not mandatory.

For any given XSP page, it could happen that the same logicsheet
is referenced more than once as a consequence of several logicsheets
depending (directly or indirectly) on a third, common logicsheet.

The XSP processor guarantees that each logicsheet will be applied
only once and in the appropriate order. For this to be possible,
the logicsheet dependency tree must have a single topological
ordering in which all intervening logicsheets will be applied (i.e.
the dependencies must define a _tree_, not a graph). It is an error
for dependencies to generate circular references.

A common pattern in logicsheets is to map dynamic tags to [static]
method calls defined in an accompanying class (such as the "Util.java"
class in the example above).

We're considering providing explicit support for this construct
in SLL so that no intervening <xsp:expr> or <xsp:logic> directives
are required.

Thus, if "Util.java" contains:

  package org.apache.cocoon.utils;
  import java.text.SimpleDateFormat;

  public class Util {
    public static systemTime(String formatMask) {
      return (new SimpleDateFormat(formatMask)).format(new Date());
    }
  }

then the corresponding SLL logicsheet may look like:

  <sll:logicsheet namespace-uri="http://xml.apache.org/util"
     xmlns:sll="http://xml.apache.org/sll"
     xmlns:xsp="http://xml.apache.org/xsp"
     xmlns:util="http://xml.apache.org/util"
     xmlns:request="http://xml.apache.org/servlet/request">

    <sll:base-class name="org.apache.cocoon.utils.Util"/>

    <sll:element name="system-time" method="systemTime">
      <sll:parameter name="format">
        <sll:default>
          <request:parameter name="format" default="hh:mm:ss"/>
        </sll:default>
      </sll:parameter>
    </sll:element>
  </sll:logicsheet>

Mime
View raw message