cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ricardo Rocha" <rica...@apache.org>
Subject RE:xsp code sample
Date Thu, 13 Jan 2000 07:03:37 GMT
Donald Ball wrote:
> how does the XSP Processor determine the order in which to process the
> XSP-enabled namespace elements that occur inside an <xsp:page> element in
> an XML document? E.g. if I want processing of the 'request' namespace to
> occur before processing of the 'sql' namespace, how do I ensure that that
> will occur?

This is dictated by the order of appearance of the (library) namespace
declarations inside the <xsp:page> root element. For example, in:

    <xsp:page language="java"
      xmlns:xsp="http://www.apache.org/1999/XSP/Core"
      xmlns:request="http://www.apache.org/1999/XSP/Request"
      xmlns:sql="http://www.apache.org/1999/XSP/Sql"
     >

the "request" logicsheet will be applied _before_ "sql". Note, though,
that the "xsp" namespace is treated specially: it comes last regardless
of its position in the namespace list.

> What if I want the same namespace to be processed twice, with
> another namespace process pass between the two? Mind you, I can't think of
> an instance where that would be desirable offhand, but I think
> understanding the answer would help my comprehension of the flow control.

Oh, my friend! This very question has been tormenting me for a while.
Remember the old Unix days when you'd have to specify a C library
more than once in your cc/ld command line, precisely because of the
same problem? ("malloc.a" would typically need multiple inclusions)

There are cases in which inter-library dependencies don't yield a
_single_ topological ordering. Granted, such cases are not common,
but they may occur and we have to account for them.

This has led me to think we should probably replace namespace as
_the_ mechanism for library inclusion by some sort of processing
instruction or <xsp:> directive, so our example might look like:

  <?xsp-library
    name="sql"
    href="resource://org/apache/cocoon/processor/sql/sql-java.xsl"
  ?>
  <?xsp-library
    name="request"

href="resource://org/apache/cocoon/processor/xsp/library/java/request.xsl"
  ?>
  <!-- Namespaces included for resolution, not for library processing"
  <xsp:page language="java"
    xmlns:xsp="http://www.apache.org/1999/XSP/Core"
    xmlns:request="http://www.apache.org/1999/XSP/Request"
    xmlns:sql="http://www.apache.org/1999/XSP/Sql"
  >
    . . .
  </xsp:page>

or, possibly better:

  <!-- Namespaces included for resolution, not for library processing"
  <xsp:page language="java"
    xmlns:xsp="http://www.apache.org/1999/XSP/Core"
    xmlns:request="http://www.apache.org/1999/XSP/Request"
    xmlns:sql="http://www.apache.org/1999/XSP/Sql"
  >
    <xsp:library
href="resource://org/apache/cocoon/processor/xsp/library/java/request.xsl"/>
    <xsp:library
href="resource://org/apache/cocoon/processor/sql/sql-java"/>
    <xsp:library href="../lib/my-java-lib.xsl"/> <!-- Implicit file:/
protocol, à la stylesheet -->
    . . .
  </xsp:page>

I like the latter because:

1) It allows for dynamic, request-time library loading (and reloading!) as
opposed
    to static, initialization time processing
2) It decouples library from namespace usage thus making it possible to use
more
    than one namespace in a library or not use a namespace at all
3) It allows for the same library to be applied more than once, should the
need
    arise. This is _not_ possible with the current namespace-based mechanism
4) It allows for name resolution based on the current document path, handy
feature
    commonly used for stylsheets and external entity references

What do you guys think?

Ricardo


Mime
View raw message