cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@apache.org>
Subject Re: stream in flowscript
Date Fri, 25 Feb 2005 08:29:24 GMT
Conal Tuohy wrote:
>  
> 
> luca morlando wrote:
> 
> 
>>I've the following problem with Control Flow:
>>I was able to read a stream in the sitemap using <map:match 
>>pattern="*/getSomething">
>>   <map:generate type="stream">
>>        <map:parameter name="defaultContentType" value="text/xml"/>
>>   </map:generate>
>> 
>>...
>>
>></map:match>
>>
>>But now I need to read the same stream into flowscript 
>>function and I don't know how to do that!
>>
>>I wrote this in sitemap:
>><map:match pattern="*/getSomething">
>>      <map:call function="main">
>>     <map:parameter name="request" value="I'm able to give 
>>you a parameter but not a stream!"/>
>>      </map:call>
>>    </map:match>
>>
>>but ... how to post stream?
> 
> 
> If your flowscript needs access to the xml stream, try using
> processPipelineTo in your flowscript to invoke the stream-generator.
or do the following:

importClass( Packages.org.apache.excalibur.source.SourceResolver );
importClass( Packages.org.apache.excalibur.source.Source );
importClass( Packages.org.apache.cocoon.components.source.SourceUtil );
importClass( Packages.org.apache.cocoon.xml.dom.DOMUtil );

function getRequestBodyDocument() {
	var resolver = null;
	var source = null;
	try {
		resolver = cocoon.getComponent( SourceResolver.ROLE );
		source = resolver.resolveURI(
                                        "module:request:inputStream" );
		var document = SourceUtil.toDOM( source );
		return document;
	} finally {
		if ( resolver != null ) {
			if ( source != null )
				resolver.release( source );
			cocoon.releaseComponent( resolver );
		}
	}
}


-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message