cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorg Heymans>
Subject Re: Injecting a String XML document into a pipeline
Date Sat, 04 Jun 2005 18:48:52 GMT

Sebastien Arbogast wrote:

> It depends on what you mean by "put the string in the request scope".
> I don't really understand how to translate that in code. Could you
> explain ?

1) Flow
// mystring contains your xml
cocoon.request.setAttribute("myxml", mystring);
// now forward to pipeline

2) Custom generator pipeline
<map:match pattern="mypipeline">
  <map:generate type="customgen"/>
  <map:serialize type="xml"/>

3) in your custom generator
 - grab the "myxml" from request scope in setup(). You can get the
request object from the objectModel map.
 - in generate() you do something like
XMLReader parser = XMLReaderFactory.createXMLReader(
parser.parse(new InputSource(new BufferedInputStream(
    new ByteArrayInputStream(this.myXml.getBytes()))));

I've seen people asking for this quite often. This little snippet is key
in understanding how to send xml content from a string or byte[] down
the pipeline. It probably warrants an entry in the FAQ under "How to
write my own generator" , but i'll leave that one up to you ;-)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message