You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Marcus Crafter <cr...@fztig938.bank.dresdner.net> on 2001/03/05 20:25:28 UTC

Re: Action ... (new question inside ;))

Hi Giacomo,

	Sorry for the late reply - I've actually been at home in Australia for
	the past couple of months and have only just recently returned to
	Europe. My apologies! :-)

> Klaus Drechsler wrote:
> >
> >   <map:match pattern="sm/*">
> >    <map:act set="mytest">
> >
> >        <map:when {test}=true>   <!-- HOW DO I DO THIS? -->
> >           <map:generate type="serverpages" > src="dbprakhouse/{test}.xsp"/>
> >           <map:transform src="dbprakhouse/sm-logicsheet.xsl"/>
> >           <map:serialize type="html"/>
> >        </map:when>
> >
> >    </map:act>
> >   </map:match>
> 
> No, there is no such thing like what you are expecting. There was a
> Selector called CodedSelectorFactory but unfortunately I've missed the docs
> from Marcus Crafter. Maybe you'll find there what you are looking for. I
> think you can always use an action to do your checking and return an
> appropriate value to the sitemap to be used as a replacement for resources.
> 
> Marcus, did you post the docs for your Selector?

	I didn't post any docs other than the example and discussion Sylvain
	and I had via the dev list. I'll put together an example page for the
	webapp over the next few days and send it in.

	The CodedSelector came from a discussion about testing external
	variables for truthness such as request parameters, session values,
	etc. 2 implementations were done, one interpreted, the other
	compiled. The CodedSelector is the latter.

	The CodedSelector allows one to embed Java code directly in the
	sitemap. The embedded code is compiled along with the sitemap
	directives for optimal performance.

	Here is an example:

<map:select type="coded">
  <map:when test="request.getParameter(&quot;myparameter&quot;).equals(&quot;string&quot;)">
    <map:transform src="stylesheet-string.xsl"/>
  </map:when>
</map:select>

	This example tests whether the request parameter 'myparameter' equals
	the string 'string'. Should that comparison be true, the data is
	transformed using the named stylesheet. Looks kind of ugly I know, but
	that's the trade off. (the interpreted version which is more readable,
	at the cost of slower performance).

	You can add any Java code you like to the sitemap, as long as it can
	evaluate to a boolean value. One needs to exercise control though, as
	adding Java code willy nilly to the sitemap will deter from it's
	readability and make it look like a program rather than a map. That
	said, it gives you the ability to add one-liner tests to your
	pipelines that would otherwise require the development a dedicated
	selector.
	
	I also added courtesy variables context, request, response and
	session, which point to the named respective objects.

	Klaus, you would be able to do your test using the coded selector, but
	it would most likely bypass actions all together.

	Hope this information helps.

	Cheers,

	Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   Open Software Associates GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'     Email : Marcus.Crafter@osa.de
          &&&&.        Business Hours : +49 69 9757 200
    &&&&&&&:           After Hours    : +49 69 49086750