cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@dti.net>
Subject Re: Generators.. was: Re: What is Cocoon good for???
Date Wed, 14 Nov 2001 14:42:41 GMT
I would imagine that SAX would perform much better:

* Doesn't need to build a DOM tree in memory, so less memory usage

* Doesn't need to wait till the DOM tree is built; can start processing from the first root
element


DR


At 03:43 PM 11/14/01 -0800, you wrote:
>Yes I think so too, but it also works for me if just return a
>org.w3c.dom.Node to C2, and since my controller works with XML internally
>this is a smooth solution I think :) However I dont know if you solution has
>better performance, so I might just convert to your solution anyway. Does
>anybody know which solution performs better?
>
>/Soren
>
>-----Oprindelig meddelelse-----
>Fra: Karl Oie [mailto:karl@gan.no]
>Sendt: 14. november 2001 06:07
>Til: cocoon-users@xml.apache.org
>Emne: RE: Generators.. was: Re: SV: What is Cocoon good for???
>
>
>thank you, very enlighting! :-D i think this is the answer to Soren Neigards
>problems with SAX yesterday!
>
>mvh karl oie
>
>
>
>-----Original Message-----
>From: aaldridg@csc.com [mailto:aaldridg@csc.com]
>Sent: 14. november 2001 15:00
>To: cocoon-users@xml.apache.org
>Subject: RE: Generators.. was: Re: SV: What is Cocoon good for???
>
>
>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> 


---------------------------------------------------------------------
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