cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Homeijer <M.Homei...@devote.nl>
Subject RE: XML-Based Selection (feedback needed)
Date Wed, 27 Feb 2002 20:24:30 GMT
Hi,

I'd like to know what other people think of this solution, as I didn't see
it in current RTs about incoming and outgoing data, sources and drains and
writable sources and I too really mis something like this in Cocoon.

When an action to store data from a form fails (through a transformer or
writable source), you may want to show the same form with the data coming
from another source/pipeline than where the original data came from. This
could be handled very nice by a solution like this.

TIA,
Michael

-----Original Message-----
From: Bruno.Dumon@the-ecorp.com
To: cocoon-dev@xml.apache.org
Sent: 27-2-2002 2:00 
Subject: RE: XML-Based Selection (Redirect Serializer?)

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:act>
<map:select type="XPathSelector"
  <map:parameter name="xmlName" value="foo">
  <map:when test="/some/node = 'xyz'">
    <map:redirect-to uri="somewhere">
  </map:when>
  <map:otherwise>
    <map:generate type="XSLTGenerator" src="stylesheetsource">
      <map:parameter name="xmlName" value="foo">
    </map:generate>
    <map:serialize/>
  </map:otherwise>
</map:select>


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 [mailto:strangegames@yahoo.com]
> Sent: Wednesday, February 27, 2002 12:10 PM
> To: cocoon-dev@xml.apache.org
> 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!
> http://greetings.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 

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

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


Mime
View raw message