Hi Richard,

It's actually not possible by design. Matchers, selectors and actions are evaluated in the pipeline setup phase to find the pipeline components. Only when the setup is finished the pipeline is executed and the SAX events sent through the pipeline. That's why you don't have access to pipeline content in a selector. Transformer (with access to SAX events) and flowscript (splitting the pipeline into 2) are the 2 already mentioned alternatives.

Joerg

On 23.07.2008 09:04, Richard McKenzie wrote:
Cheers Peter

Thanks for the advice, we are trying to avoid using flow script if
possible. I just thought I'd post the question in case anybody had
created a selector which did something similar, after decompiling all
the cocoon selectors I suspected that it was not possible to do
elegantly. Many Thanks
-----Original Message-----
From: Peter Hunsberger [mailto:[EMAIL PROTECTED] Sent: 22 July 2008 16:28
To: [email protected]
Subject: Re: Custom Xpath Selector

On Tue, Jul 22, 2008 at 10:04 AM, Richard McKenzie
<[EMAIL PROTECTED]> 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

Reply via email to