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