cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaldr...@csc.com
Subject Re: Generators.. was: Re: SV: What is Cocoon good for???
Date Thu, 15 Nov 2001 17:02:32 GMT
Looks great, but doesn't this mean a less efficient system - ie isn't it
going through a number of extra steps to arrive at thge same functionality?

Regards,

Anthony Aldridge
Lead Application developer

Managed Intranet Hosting
CSC
JPMorganChase
Personal GDP: 325-8338
MIH Hotline: 876-1300





"Piroumian, Konstantin" <KPiroumian@flagship.ru> on 14/11/2001 14:39:11

Please respond to cocoon-users@xml.apache.org

To:   cocoon-users@xml.apache.org
cc:
Subject:  Re: Generators.. was: Re: SV: What is Cocoon good for???


This can be implemented as a logicsheet and you'll forget about pure Java
in
your XSPs and have much clear XSP pages. More over, if you develop a
transformer for this then you'll be able to apply it even to pure XML
files.
This way a logicsheet can be used:

 <?xml version="1.0" encoding="ISO-8859-1"?>
  <xsp:page
           language="java"
           xmlns:xsp="http://apache.org/xsp"
           xmlns:sax=http://anyhost/xmlize/1.0
>
      <xsp:logic>
          <![CDATA[
           Jbxsp jbxsp;
           int id = -1;]]>
      </xsp:logic>
   <page>
        <sax:to-sax src="request"
attribute="com.jpmorgan.mih.intranet.example.SimpleSite" />
   </page>
 </xsp:page>

And the transformer version:

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <page xmlns:sax=http://anyhost/xmlize/1.0>
        <sax:to-sax src="request"
attribute="com.jpmorgan.mih.intranet.example.SimpleSite" />
</page>

and use this sitemap configuration:
...
<map:match pattern="*.xml">
    <map:generate src="files/{1}.xml"/>
    <map:transform type="xmlize" />
    <map:serialize />
</map:match>

Of course, you should also declare your transformer in <map:transformers >
section.

Just my <i18n:currency value="0.02" />

Regards,
    Konstantin Piroumian

> Here's the xsp page:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xsp:page
>           language="java"
>           xmlns:xsp="http://apache.org/xsp"
> >
>      <xsp:structure>
>           <xsp:include>net.securinet.jbxsp.*</xsp:include>
>           <xsp:include>org.apache.cocoon.environment.http.*</xsp:include>
>      </xsp:structure>
>      <xsp:logic>
>          <![CDATA[
>           Jbxsp jbxsp;
>           int id = -1;]]>
>      </xsp:logic>
>   <page>
>     <xsp:logic>
>      <![CDATA[
>           jbxsp = new Jbxsp
> ( (org.apache.cocoon.environment.http.HttpRequest )(request) ,
> "com.jpmorgan.mih.intranet.example.SimpleSite");
>           jbxsp.toSAX(contentHandler);
>      ]]>
>
>     </xsp:logic>
>   </page>
> </xsp:page>
>
> **************************
>
> As you see, it includes my library (net.securinet.jbxsp.*) and the cocoon
> http environment stuff. It then instantiates a Jbxsp (java bean xsp)
class
> with the name of the component class (SAX and DOM aware). The whole thing
> is then asked to toSAX itself. This causes the Jbxsp class to ask the
named
> class to toSAX itself, which (as an awt container) asks its components to
> do the same - thus building the tree.
>
> In other words, in order to get a named component (or the main class you
> instantiate) to generate SAX (or DOM) events is to do you xml file
reading
> in the constructor, or in the toSAX method of that class.
>
> eg (forgive if that doesn't work without my libs - it just shows how I
play
> with these issues). I suspect this also shows why a custom generator
might
> be more useful in your case, as you'd have to analyse your xml doc into
its
> constituent parts in order to output it again as SAX events (although I'm
> sure there's an easy way to achieve this).
>
>     public void toSAX(ContentHandler handler) {
>         try{
>             this.contentHandler = handler;
>             AttributesImpl atts = new AttributesImpl();
>             start("jbxsp-id", atts);
>             characters("" + instanceId);
>             end("jbxsp-id");
>
>             start("jbxsp-screen-id", atts);
>             characters("" + screenId);
>             end("jbxsp-screen-id");
>
>             start("jbxsp-screen", atts);
>             characters("" + screenClass);
>             end("jbxsp-screen");
>
>             start("jbxsp-trail", atts);
>             characters("" + trail.getTrailId());
>             end("jbxsp-trail");
>
>         } catch(Exception e){
>             System.err.println("Error in SAX (toSAX) ");
>             e.printStackTrace();
>         }
>
>         instance.toSAX(handler);
>    //System.out.println("Finished converting to DOM");
>     }
>
>
>
>
>
>
>
> Karl Oie <karl@gan.no> on 14/11/2001 12:57:36
>
> Please respond to cocoon-users@xml.apache.org
>
> To:   cocoon-users@xml.apache.org
> cc:
> Subject:  RE: Generators.. was: Re: SV: What is Cocoon good for???
>
>
> >I'm happy to share some code with you if you need it.
> >
> >Regards,
> >
> >Anthony Aldridge
> >Lead Application developer
>
>
> please do, as i find working examples a great way to learn! :-)
>
> mvh karl oie
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>







---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message