You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Steven D. Majewski" <sd...@virginia.edu> on 2007/03/03 16:37:27 UTC

request-parameters selector usage

In the docs and examples for the request-parameter selector,
the selection tests are done on the value of a particular request- 
parameter

<map:select type="request-parameter">
   <map:parameter name="parameter-name" value="command"/>
   <map:when test="list">
   ....
   </map:when>
   <map:when test="create">
   ...
   </map:when>
   ...
   <map:otherwise>
   ...
   </map:otherwise>
</map:select>


But what I want to do is select different processing
depending on the presence of a request parameter:
  if no parameter exists, then process document normally;
  if parameter exists, do something with that parameter.

What is the best way to do that?

Will  <map:when test="">  work when there's no parameter
as well as a null parameter ?
( Then I could have normal document processing under
   that test and  parameter processing under <map:otherwise>


Is there any way to select in the sitemap based on the
presence of ANY request parameters ?

I tried adding  "*.*?**" as a pattern before my "*.*" pattern
but this didn't seem to work.

-- Steve Majewski





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


Re: request-parameters selector usage [ & unparsed-entity-uri() hack ]

Posted by "Steven D. Majewski" <sd...@virginia.edu>.
Thanks to both Grzegorz Kossakowski and Andrew Stevens
who both pointed me to RequestParameterExistsAction.

This does exactly what I want:

   <map:match pattern="*/*.*">
      <map:act type="req-params" >
         <map:parameter name="parameters" value="unparsed-entity-uri" />
         <map:redirect-to
		uri="cocoon://vivaead/entity-resolver?document=published/{../1}/{../ 
2}.xml&amp;entity=unparsed-entity-uri" />
      </map:act>
      <map:generate src="published/{1}/{2}.xml" />

	... normal document processing ...



BTW: this is  part of a hack to work around the (many-times-reported)
bug that cocoon seems to break unparsed-entity-uri() in the xslt  
pipeline.

I'll post more on this later, as I know others have run into this  
problem.

This hack doesn't fix what's wrong in the processing pipeline. It's a  
hack
around the problem: I changed my stylesheets to output relative uri's
with the entity name as a request parameter.

The map above redirects those uri's to a flowscript resolver that
     parses the xml and does a redirectTo().

  (I'ld like to figure out how to short-circuit the xml parser after
    it has finished the entities and before it starts on the body of
    the document. All of the other handlers are default/null handlers,
    but it still parses the whole document. )


-- Steve Majewski




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


Re: request-parameters selector usage

Posted by Andrew Stevens <at...@hotmail.com>.
>From: "Steven D. Majewski" <sd...@virginia.edu>
>Date: Sat, 3 Mar 2007 10:59:51 -0500
>
>In fact, this didn't work:
>
><map:select type="request-parameter">
><map:parameter name="parameter-name" value="external-entity-uri" />
><map:when test="">
>   <!-- normal document processing -->
></map:when>
><map:otherwise>
>   <!-- process request parameter -->
></map:otherwise>
></map:select>
>
>It seems to always do the otherwise.
>
>Is there another way to select on the presence
>( rather than the value ) of a request param ?

How about
org.apache.cocoon.acting.RequestParameterExistsAction
?

" * This action simply checks to see if a given request parameter
* exists. It takes an arbitrary number of default parameters to check
* named 'parameter-name'. Non-default parameters need to be separated
* by spaces and passed as value of a sitemap parameter named
* 'parameters'. The action returns a map with all parameters if all
* of them exist and null otherwise."


Andrew.
--
http://pseudoq.sourceforge.net/  Open source java Sudoku application

>
>-- Steve Majewski
>
>On Mar 3, 2007, at 10:37 AM, Steven D. Majewski wrote:
>
>>
>>In the docs and examples for the request-parameter selector,
>>the selection tests are done on the value of a particular request- 
>>parameter
>>
>><map:select type="request-parameter">
>>   <map:parameter name="parameter-name" value="command"/>
>>   <map:when test="list">
>>   ....
>>   </map:when>
>>   <map:when test="create">
>>   ...
>>   </map:when>
>>   ...
>>   <map:otherwise>
>>   ...
>>   </map:otherwise>
>></map:select>
>>
>>
>>But what I want to do is select different processing
>>depending on the presence of a request parameter:
>>  if no parameter exists, then process document normally;
>>  if parameter exists, do something with that parameter.
>>
>>What is the best way to do that?
>>
>>Will  <map:when test="">  work when there's no parameter
>>as well as a null parameter ?
>>( Then I could have normal document processing under
>>   that test and  parameter processing under <map:otherwise>
>>
>>
>>Is there any way to select in the sitemap based on the
>>presence of ANY request parameters ?
>>
>>I tried adding  "*.*?**" as a pattern before my "*.*" pattern
>>but this didn't seem to work.
>>
>>-- Steve Majewski

_________________________________________________________________
Get Messenger FREE on your Mobile https://livemessenger.mobile.uk.msn.com/


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


Re: request-parameters selector usage

Posted by "Steven D. Majewski" <sd...@virginia.edu>.
In fact, this didn't work:

<map:select type="request-parameter">
<map:parameter name="parameter-name" value="external-entity-uri" />
<map:when test="">
   <!-- normal document processing -->
</map:when>
<map:otherwise>
   <!-- process request parameter -->
</map:otherwise>
</map:select>


It seems to always do the otherwise.

Is there another way to select on the presence
( rather than the value ) of a request param ?

-- Steve Majewski

On Mar 3, 2007, at 10:37 AM, Steven D. Majewski wrote:

>
> In the docs and examples for the request-parameter selector,
> the selection tests are done on the value of a particular request- 
> parameter
>
> <map:select type="request-parameter">
>   <map:parameter name="parameter-name" value="command"/>
>   <map:when test="list">
>   ....
>   </map:when>
>   <map:when test="create">
>   ...
>   </map:when>
>   ...
>   <map:otherwise>
>   ...
>   </map:otherwise>
> </map:select>
>
>
> But what I want to do is select different processing
> depending on the presence of a request parameter:
>  if no parameter exists, then process document normally;
>  if parameter exists, do something with that parameter.
>
> What is the best way to do that?
>
> Will  <map:when test="">  work when there's no parameter
> as well as a null parameter ?
> ( Then I could have normal document processing under
>   that test and  parameter processing under <map:otherwise>
>
>
> Is there any way to select in the sitemap based on the
> presence of ANY request parameters ?
>
> I tried adding  "*.*?**" as a pattern before my "*.*" pattern
> but this didn't seem to work.
>
> -- Steve Majewski
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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


Re: request-parameters selector usage

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Steven D. Majewski napisaƂ(a):
>
> [...]
>
>
> Is there any way to select in the sitemap based on the
> presence of ANY request parameters ?
>
The current situation is little bit confusing and limited because null 
values and empty strings usually are treated as equal in sitemap's 
expressions/conditions. It would be great to improve it but it demands 
rather major refactoring so it's not likely to happen quickly.

Anyway there is solution, see this: 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/acting/RequestParameterExistsAction.html

-- 
Grzegorz Kossakowski

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