cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: XML-Based Selection (Redirect Serializer?)
Date Wed, 27 Feb 2002 13:00:19 GMT
I've had a similar situation, i.e. the need to make flow decision based on
data generated in a pipeline. My solution was to create an action that
executes another pipeline (using the cocoon:/ protocol), and stores its
result as a (saxon)dom tree in the request object. Then there's a
xpath-based selector to query that dom-tree, so that it's possible to
redirect to another resource/url. Finally I've made an XSLTGenerator, that
can apply an XSL to the dom-tree in the request object.

A typical pipeline looks like:

<map:act type="FetchAndStoreXml" src="cocoon:/something">
  <map:parameter name="storeAs" value="foo">
<map:select type="XPathSelector"
  <map:parameter name="xmlName" value="foo">
  <map:when test="/some/node = 'xyz'">
    <map:redirect-to uri="somewhere">
    <map:generate type="XSLTGenerator" src="stylesheetsource">
      <map:parameter name="xmlName" value="foo">

I've based the implementation on saxon, because there doesn't seem to be a
way to build DTM trees and then feed them to xalan afterwards.

The XSLTGenerator is to avoid the need to stream the dom tree again which
would then be build again by the XSLT processor. Of course if you don't need
XSLT you'll have to make a generator that streams the domtree to sax events.

A completely other solutions, less nice and performant, but easier to
implement is to use an XSLT that generates some HTML with some javascript in
the onload event that will do the redirection.

Bruno Dumon

> -----Original Message-----
> From: James Burton []
> Sent: Wednesday, February 27, 2002 12:10 PM
> To:
> Subject: XML-Based Selection (Redirect Serializer?)
> Hi all!  We're working on a Cocoon 2 project and
> *very* strongly need the ability to "branch" to a
> different pipeline or part of a pipeline based on the
> XML output of a Transformer.  This is because we use a
> custom Transformer for communicating with an EJB back
> end.  Originally I thought to use an XML selector like
> this:
> <map:match pattern="example">
>   <map:generate src="..." />
>   <map:transform type="custom-ejb-interface">
>     ...
>   </map:transform>
>   <map:select type="xml" node="/result/flag">
>     <map:when test="normalResult">
>       <map:transform src="styles/normal.xsl" />
>     </map:when>
>     <map:when test="specialResult">
>       <map:transform type="custom-ejb-interface">
>         ...
>       </map:transform>
>       <map:transform src="styles/special.xsl" />
>     </map:when>
>   </map:select>
>   <map:serialize />
> </map:match>
> However I found in the mail archives (Subject: XML
> selector) that this method does not work because
> Selectors have no access to the XML results of
> Transformers.  For similar reason a custom Matcher
> wouldn't work either.  But this functionality is
> crucial!
> Therefore, I wondered if it would be possible for me
> to create a "redirecting serializer": one that would
> call a different pipe (or a different resource) based
> on the final XML feed.  In other words something like
> this:
> <map:match pattern="example">
>   <map:generate src="..." />
>   <map:transform type="custom-ejb-interface">
>     ...
>   </map:transform>
>   <map:serialize type="redirector">
>     <map:parameter name="node" value="result/flag" />
>     <map:parameter name="match1" value="normal" />
>     <map:parameter name="call1" value="normal-pipe" />
>     <map:parameter name="match2" value="special" />
>     <map:parameter name="call2" value="special-pipe"
> />
>   </map:select>
> </map:match>
> Can someone give me a hint for how to start
> implementing this?  I know how to make a Serializer,
> but don't know what it would call to start invoking a
> pipe with a different URL (I imagine it must be
> similar to the implementation of <map:call>).  Or, if
> this is not going to work, could somebody let me know?
>  In that case, I think the only alternative left is to
> make a serializer that issues an HTTP redirect to a
> given URL based on its parameters; i.e. a
> "RedirectSerializer".  I would be happy to contribute
> this serializer if I can get it to work.
> Many thanks from Prague,
> James Burton
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Greetings - Send FREE e-cards for every occasion!
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, email:

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

View raw message