Hi all,
 
I have a question that's related to the "Inserting / Comining XML data"
thread, but which I believe is slightly different.  Here's the situation.
 
SCENARIO
-----------------
We are using Cocoon 2, and we would like to use an XSP doc as a "shell" that
aggregates XML data from one or more Java objects (the objects would
actually output XML strings).  These Java objects (possibly EJB's) would
need access to the Request object in order to do their processing.  So,
here's what we originally tried (most of you will probably see the flaw
pretty quickly).
 
PROBLEM
----------------
We have a Java object like this (this sample is a simplified version of what
we're actually planning to do, but it illustrates the problem we're running
into):
 
    public class Foo {
        public getXML(Request req) {
            return "<foo>This is a foo tag.</foo>";
        }
    }
 
And we have this XSP doc:
 
    <xsp:page language="java" xmlns:xsp=" http://apache.org/xsp
<http://apache.org/xsp> ">
        <xsp:structure>
            <xsp:include>com.coremetrics.test.Foo</xsp:include>
        </xsp:structure>
        <xsp:logic>
            Foo f = new Foo();
        </xsp:logic>
    
        <page>
            <xsp:expr>f.getXML(request)</xsp:expr>
        </page>
    </xsp:page>
 
Unfortunately, <xsp:expr> renders the return value as a text node, so we got
the text content "&lt;foo%gt;..." as the content of our page node in the
resulting xml.  SO...
 
We considered using the document() function with the custom URI handlers (as
discussed in the aforementioned thread), but while we could render the
request parameters out as string args for the URI, we would lose any other
info on the request (such as cookies, attributes, etc.).
 
PROPOSED SOLUTION
-----------------------------------
So we're thinking about modifying cocoon as follows:
 
1) Define a new xsp tag "xsp:exprXml" that operates like xsp:expr but treats
its content as xml.
2) Define a new method (or set of methods) in XSPObjectHelper.  This method
will take a ContentHandler
    and an xml String.  It will either instantiate or get a SAX parser
(maybe a pool), and set the parser's
    content handler to the ContentHandler passed in.  It will then use the
SAX parser to parse the String.
3) Add a template for xsp:exprXml in xsp.xsl, and have it use the new
XSPObjectHelper method.
 
My question is, does this approach sound right?  Are there better ways we
can do this?  Are there ways we can do this without modifying cocoon?  I'm a
cocoon newbie, so any advice would be much appreciated.  Thanks!
 
Harry

-------------- 
Harry Lai 
[EMAIL PROTECTED] 
512.342.2623 x2170 

 

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