cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Billard <>
Subject Re: How can I extract values from XML within an Action?
Date Thu, 29 Jul 2004 08:11:18 GMT
Hi Jeff,

The source resolving mechanism is for you :).

SourceResolver resolver = null;
Source source = null;

try {
	resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
	processor =
		(XPathProcessor) manager.lookup(XPathProcessor.ROLE);

	source = resolver.resolveURI("cocoon://blah");
	// or source = resolver.resolveURI("http://blah");
	// then do what you want from your source : get the file, the	
	//input stream, and so on...
} catch (ComponentException e) {
	getLogger().error("Could not lookup for component : ", e);
	throw new CascadingRuntimeException(e.getMessage(), e);
} finally {
	if (resolver != null) {
		if (source != null)

Your Action must be Serviceable (ie must extend ServiceableAction) to 
get access to the cocoon component manager.

Olivier Billard

Jeff Jones wrote:
> I'm getting lost in Cocoon docs and could use a pointer or two. Could anyone
> help me out?
> I'm writing an Action to perform the following steps:
>    Pull a couple query parameter values from the request URI
>    Perform some simple Java manipulation on them
>    Use the manipulated values to request an XML document, either externally
> (http://) or internally (cocoon://)
>    Extract several values from the resulting XML document and insert them into
> the action result map
>    Return the map to the pipeline
> The only thing I don't see how to do is extract data from the XML document; or,
> to put it another way, I don't see how to use an XML document as the source of
> data for an Action. I realize I'm probably missing something simple, but I'm
> kind of stuck on this point... or maybe I should be using something other than
> an Action to begin with. Can anyone give me a push in the right direction?
> Many thanks,
> Jeff Jones
> The Weather Channel Interactive

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

View raw message