cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Hunsberger" <peter.hunsber...@gmail.com>
Subject Re: Custom Xpath Selector
Date Tue, 22 Jul 2008 15:28:17 GMT
On Tue, Jul 22, 2008 at 10:04 AM, Richard McKenzie
<Richard.McKenzie@bbc.co.uk> wrote:

<snip/>

> Perhaps I am barking up the wrong tree and a selector is not the best
> solution, it would be nice to be able to do different things bassed on the
> contents of the xml passed through a pipeline
>

If you have complicated use cases I suspect you're going to want to
use a Java transformer to inspect the XML in the pipeline and have it
make the decisions on what should be done.  This can be done from flow
script by firing off the pipeline at that point and then inspecting
some returned result.  I'm not sure about 2.1 but in 2.0 this looks
like

 var sourceURI = "run/_checkXML/";
    var destinationURI = "xmodule:request-attr:checkXMLresult";

    var resolver = null;
    var destination = null;
    var output = null;
    try {
        resolver = cocoon.getComponent(
Packages.org.apache.cocoon.environment.SourceResolver.ROLE );
        destination = resolver.resolveURI( destinationURI );
        output = destination.getOutputStream();
        cocoon.processPipelineTo( sourceURI, {}, output );
        output.close();

        if ( cocoon.request.getAttribute( "checkXMLresult" ) == ...) {
  //see what happened in the XML checking pipeline
           // Do whatever should be done based on the results...

            return true;
        }
    }
    finally {
        if (destination != null) {
            resolver.release( destination );
        }
        cocoon.releaseComponent( resolver );
    }
-- 
Peter Hunsberger

Mime
View raw message