You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Hugh Sparks <hu...@csparks.com> on 2007/06/28 10:01:06 UTC
Help using xmodule
In my application, I need to send a large xml DOM thing back
to the pipeline from flowscript. To simplify the question, I
created a short but tested example:
In flowscript, I create a doc from a string and try to send it back:
var str = "<test>This is a test</test>" ;
var parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
var reader = new Packages.java.io.StringReader(str) ;
var source = new Packages.org.xml.sax.InputSource(reader) ;
var doc = parser.parseDocument(source);
cocoon.releaseComponent(parser);
cocoon.sendPage("makedomReply", {message: doc}) ;
In the sitemap:
<map:match pattern="makedomReply">
<map:generate src="xmodule:flow-attr:message"/>
<map:serialize type="xml"/>
</map:match>
Browser error:
org.xml.sax.SAXException: The object type: class java.lang.String
could not be serialized to XML: This is a test
>From the stacktrace and source code, it is clear that XModuleSource.toSAX
got a java String instead of the Document I tried to send.
Using module with a plain javascript string works without an error:
doc = "<test>This is a test</test>" ;
cocoon.sendPage("downloadReply", {message: doc}) ;
<map:match pattern="downloadReply">
<map:generate src="module:flow-attr:message"/>
<map:serialize type="xml"/>
</map:match>
I guess I'm confused about what xmodule is supposed to deal
with. Or perhaps I'm not making the dom object correctly.
Thanks to all and greetings to the list,
-Hugh Sparks
Version: Cocoon 2.1.11-dev svn export from 2007-06-11
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org