Hi,

first i would like to thank you all for your pointers to a solution. I'm happy that it works now.

The solution is to put a DOM object instead of a JDOM object into the request. That was easy to create by using the DOMOutputter from JDOM. Now i get the xml fragment i wanted, with both access methods, <jx:out .../> and ${request...}.

Thanks,
Tino



Kris Schneider schrieb:
As an example, we do something similar for wrapping XMLBeans objects:

public class XMLBeansXMLizableWrapper implements XMLizable {

    private final XmlTokenSource source;

    public XMLBeansXMLizableWrapper(XmlTokenSource source) {
        this.source = source;
    }

    public void toSAX(ContentHandler contentHandler) throws SAXException {
        LexicalHandler lexicalHandler = null;
        if (contentHandler instanceof LexicalHandler) {
            lexicalHandler = (LexicalHandler)contentHandler;
        }
        this.source.save(contentHandler, lexicalHandler);
    }

    public XmlTokenSource getWrappedObject() {
        return this.source;
    }
}

For JDOM, I assume you could use something like SAXOutputter.output(Document).

On 2/2/06, Bruno Dumon <[EMAIL PROTECTED]> wrote:
On Thu, 2006-02-02 at 07:33 -0700, Jason Johnston wrote:
Andre Juffer wrote:
Tino Breddin wrote:
Hi,

i tried your way:

Request request = ObjectModelHelper.getRequest(objectModel);
       Session session = request.getSession(true);
       session.setAttribute("testparamsession",doc);

Then:
${session.getAttribute('testparamsession')}
It should be something like

${cocoon.session.getAttribute("testparamsession")}

assuming that you doc in the action contains a proper (J)DOM document
and the session was properly created.
Before we go any farther down this path, I don't think getting access to
the object is the problem; it seemed pretty clear from his original
example that he was already successfully getting access to the object,
but it is just not being serialized in the way he expects.

I haven't tried it to verify, but I believe to have a DOM document get
serialized into the XML stream you need to use <jx:out
value="${request.getAttribute('testparamrequest')}" /> since the jx:out
element treats certain objects like DOM documents specially whereas the
${} expression just calls toString() or something like that.
${} should also work. The problem is rather that it is a JDOM object,
not a DOM object. JXTemplate does not recognize JDOM objects.

What you could do is wrap the JDOM object in an object that implements
the XMLizable interface, that is:

org.apache.excalibur.xml.sax.XMLizable

this is a simply interface with just a toSAX method.

--
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[EMAIL PROTECTED]                          [EMAIL PROTECTED]

--
Kris Schneider <mailto:[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]