cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Burton <strangega...@yahoo.com>
Subject RE: XML-Based Selection (Redirect Serializer?)
Date Wed, 27 Feb 2002 16:38:49 GMT
Hi Georg,

No, the problem is that there's no "XML selector" to
begin with.  If there was, problem solved.  Instead,
it appears that such a selector is impossible (I'd be
more than happy to make one if it was possible)
because the selector is executed while the pipe is
being set up, i.e. if I have sitemap code like this:

 <transform A>
 <select something>
   <when some condition>
     <transform B>

the select code is actually executed before *both*
transformations in the pipe.  This is a subtle
surprise that is making me tear my hair out.  What I
really need is a "switcher" component that lets me
choose the next transformation step based on the XML
already generated (of course this means that the SAX
events in the "pipe" must be partially or fully
buffered at the switching point, but that's a price
I'll have to pay one way or another), or short of
that, a reliable way to jump to an arbitrary
alternative pipe.

Best regards,
James

--- Georg Von Sperling <gvs@medaptus.com> wrote:
> Let's just try this again... ;)
>  
> James,
>  
> This is just a shot in the dark, but from the syntax
> below, the xslt migh barf. Isn't the syntax for
> conditionals in xslt as follows:
> 
> <map:select type="xml" node="/result">
> <map:choose>
>     <map:when test="flag='normalResult'">
>       <map:transform src="styles/normal.xsl" />
>     </map:when>
>     <map:when test="flag='specialResult'">
>       <map:transform type="custom-ejb-interface">
>         ...
>       </map:transform>
>       <map:transform src="styles/special.xsl" />
>     </map:when>
>     <map:otherwise>
>      {put in something that does the transformation
> in case all the above conditionals fail}
>     </map:otherwise>
> </map:choose>
> </map:select>
>  
> the single-line conditional could be
> <map:select type="xml" node="/result">
>   <map:if test="flag='normalResult'">
>       <map:transform src="styles/normal.xsl" />
>     </map:if>
>     <map:if test="flag='specialResult'">
>       <map:transform type="custom-ejb-interface">
>         ...
>       </map:transform>
>       <map:transform src="styles/special.xsl" />
>     </map:if>
> </map:select>
>  
> except that I have no idea as to what the net-effect
> of the 'if'-statements are.
>  
> Sincerely,
> Georg von Sperling
> MedAptus, Inc.
> www.medaptus.com <http://www.medaptus.com> 
> gvs@medaptus.com <mailto:gvs@medaptus.com> 
>  
>  
> 
> 	-----Original Message----- 
> 	From: James Burton [mailto:strangegames@yahoo.com] 
> 	Sent: Wed 2/27/2002 6:15 AM 
> 	To: cocoon-dev@xml.apache.org 
> 	Cc: 
> 	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


Mime
View raw message