cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@rsv.ricoh.com (Stephen R. Savitzky)
Subject Re: Easy to maintain Web applications?
Date Thu, 16 Dec 1999 01:35:12 GMT
Brett McLaughlin <bmclaugh@algx.net> writes:

> Greg Wolff wrote:

> > In a nutshell, here's the difference:
> > 
> > PIA:
> > <define element="foo" handler="org.risource.dps.handler.Foo">
> >    <doc> The action for foo the specified in a java class called Foo </doc>
> > </define>
> > 
> > XSP:
> >   <xsp:foo language="java">
> >    <xsp:logic>
> >     private static int counter = 0;
> >     private synchronized int currentCount() {
> >       return ++counter;
> >     }
> >    </xsp:logic>
> >   </xsp:foo>
> 
> Your XSP here is in a logicsheet, separate from content.  I actually
> think this is an even better approach, because if there was ever a need
> for C/C++/Perl/whatever, an appropriate stylesheet could be created with
> that code in it, and the XML document is absolutely untouched.

The PIA <define> element is normally found in a ``tagset,'' roughly
equivalent to a logicsheet.  The difference in our languages is that you
don't normally need to drop down into Java:

<define element="foo">
  <action>
    <set name="counter"><add><get name="counter"/> 1</add></set>
    <get name="counter"/>
  </action>
</define>

> If you have problems with code in the stylesheet/logicsheet, then I think
> you are in the wrong market - a stylesheet changes a _lot_, every time the
> HTML spec changes, every time look/feel changes, etc.  It is meant to be
> malleable, because your nice clean XML document is still unchanged.

But that's just why code -- Java code, specifically -- in a stylesheet is a
problem.  With a suitable set of definitions, you can give the people who
have to customize and update the application a mini-language that does just
what they need.  For example, we can simplify the example above even more:

<define element="foo">
  <action>
    <increment var="counter" initialvalue="0"/>
  </action>
</define>

where the <increment> element is defined thus:

<define element="increment">
  <action>
    <if><get name="&attr:var;"/>
        <then>
          <set name="&attr:var;"><add><get name="&attr:var;"/> 1</add></set>
        </then>
	<else>
          <set name="&attr:var;"><get name="&attr:initialvalue;"/></set>
	</else>
    </if>
    <get name="&attr:var;"/>
  </action>
</define>

> Maybe you thought the xsp namespace tags were in the XML itself?  No.

In our case, they could be (and I think it might be possible to do the same
in XSL as well), using a suitable tagset.  It may not be what you want in
all cases, but it can come in handy.  It's particularly useful to be able to
put conditionals and includes into configuration files, for example.

-- 
Stephen R. Savitzky  <steve@rsv.ricoh.com>  <http://rsv.ricoh.com/~steve/>
Platform for Information Applications:      <http://RiSource.org/PIA/>
Chief Software Scientist, Ricoh Silicon Valley, Inc. Calif. Research Center
 voice: 650.496.5710  front desk: 650.496.5700  fax: 650.854.8740 
  home: <steve@theStarport.org> URL: http://theStarport.org/people/steve/

Mime
View raw message