thank you, very enlighting! :-D i think this is the answer to Soren Neigards
problems with SAX yesterday!

mvh karl oie



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 14. november 2001 15:00
To: [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> on 14/11/2001 12:57:36

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>







---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>


---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to