cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ricardo Rocha" <>
Subject RE: xBug related XSP Questions
Date Thu, 20 Jan 2000 18:57:06 GMT
On Jan-20-2000 Michael Glenn wrote:

> I starting to see how this would work, but my understanding of XSP is
> still very rusty. I'm hoping you can confirm and clarify my analysis
> then perhaps I can be of some use. Using this as a real world example
> will help me to grasp the XSP concept.

> <xbug:add-bug>
>     <xbug:platform>
>       <request:get-parameter name="platform"/>
>     </xbug:platform>
>     <xbug:version>
>       <request:get-parameter name="version"/>
>      </xbug:version>
>     <xbug:component>
>       <request:get-parameter name="component"/>
>      </xbug:component>
>     . . .
>   </xbug:add-bug>

> I understand <xbug:add-bug> to be a library tag as well as
> <xbug:platform> and <request:...>, correct?
> Some of this code resides within the XSPRequest library, referenced
> using <xsp:page>, correct?

Yes. In general, each library defines its own namespace (though
this restriction is likely to be lifted in the near future).

Thus, the example <xbug:> namespace would be supported by
the corresponding xBug library.

The same is true of <request:>, which is one of XSP's built-in
libraries. XSP provides libraries for all servlet objects: request,
response, session, servletContext and Cookie. There's also a
(demo) Util library containing general-purpose file, URL and
date dynamic tags.

> Where would the code to add the retrieved information into the database
> reside and how would it be referenced?

XSP follows a layered (TM by Stefano Mazzocchi) approach where
libraries are applied in sequence so that the "output" of one library
becomes the "input" of another, not unlike the good ole' Unix pipeline

Thus, xBug could well be expressed in terms of Donald's upcoming SQL
XSP library.

Violating the sacrosanct principle of wrapping all business logic as
Java Beans and also improvising a SQL library syntax Donald is sure
to denounce as ridiculous, the following example illustrates the point:

1) "User" XSP Page:

      Error loading generated Java classes after restarting
      servlet engine

2) <xbug:> Library

  <xsl:template match="xbug:add-bug">
    <sql:do-insert table-name="bugs" connection="xbugConnection">
      <sql:column name="platform">
        <xsl:value-of select="xbug:platform"/>
      <sql:column name="version">
        <xsl:value-of select="xbug:version"/>
       <sql:column name="platform">
        <xsl:value-of select="xbug:component"/>
       <sql:column name="platform">
        <xsl:value-of select="xbug:summary"/>

3) <sql:> library

    <xsl:template match="sql:do-insert">
      <xsp:logic> {
        Connection connection = <xsl:value-of select="@connection"/>;
        String sqlText =
          "INSERT INTO <xsl:value-of select="@table-name"/> ( " +
            <xsl:for-each select="sql:column">
              <!-- Warning: generates a spurious trailing comma! -->
              "<xsl:value-of select="@name">, " +
          ") VALUES ( " +
            <xsl:for-each select="sql:column">
              <!-- Warning: generates a spurious trailing comma! -->
              "'<xsl:value-of select=".">', " +
        Statement statement = connection.createStatement();
      } </xsp:logic>

After applying libraries, the resulting code would look like:

        Connection connection = myConnection;
        String sqlText =
          "INSERT INTO bugs ( " +
              "platform , " +
              "version, " +
              "component, " +
              "summary "
          ") VALUES ( " +
              "'Linux', " +
              "'1.6', " +
              "'XSP', " +
              "'Error loading generated Java classes after restarting
servlet engine'" +
        Statement statement = connection.createStatement();

Again, this is _NOT_ the idea!!! I've used this form because
of its relative simplicity.

I'm preparing a document about library authoring where
the "true path" is introduced. The above example is too
ASP-like, :-(

ASPers of the world: repent before it's too late! Eschew ASP
and look-alikes, embrace the shining path of true dynamic XML
authoring!! :-)


View raw message