You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tino Breddin <s9...@inf.tu-dresden.de> on 2006/02/02 18:59:58 UTC
Re: How to return a JDom document from a action? [SOLVED]
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 <br...@outerthought.org> 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
>> bruno@outerthought.org bruno@apache.org
>>
>
> --
> Kris Schneider <ma...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to return a JDom document from a action? [SOLVED]
Posted by Kris Schneider <ks...@gmail.com>.
On 2/3/06, Bruno Dumon <br...@outerthought.org> wrote:
> On Thu, 2006-02-02 at 18:59 +0100, Tino Breddin wrote:
> > 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...}.
>
> The XMLizable approach should be more efficient though, especially for
> non-trivial trees.
Not to mention the horrible irony of having to turn a JDOM doc into a
DOM doc just to use it...
> --
> Bruno Dumon http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org bruno@apache.org
--
Kris Schneider <ma...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to return a JDom document from a action? [SOLVED]
Posted by Bruno Dumon <br...@outerthought.org>.
On Thu, 2006-02-02 at 18:59 +0100, Tino Breddin wrote:
> 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...}.
The XMLizable approach should be more efficient though, especially for
non-trivial trees.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org bruno@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org