You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Naquin, Beth" <Be...@morpho.com> on 2002/07/02 00:52:33 UTC

[doc] Request feedback on Draft: Parameter Selector user doc

Hi all,

Below is a draft of a document on the ParameterSelector for possible
inclusion in the userdocs/Selectors section.  I thought I'd post it here to
get some feedback first.

Could you please give it a quick review for:  accuracy/correctness,
understandability (esp to a newbie),  additional info to add ??

Thanks a bunch,
Beth

================================================================
Parameter Selector
applies to:  cocoon 2.0.2, ?????????????? DOES THIS APPLY TO OTHER VERSIONS
OF COCOON ALSO??

Name: Parameter Selector
Class:  org.apache.cocoon.selection.ParameterSelector
Cacheable:  ????????  CAN SOMEONE ANSWER THIS, OR IS IT NONAPPLICABLE??


This Selector matches a string, in the Parameters object passed to the
selector, against a specified Cocoon internal parameter.  It performs a
case-sensitive string comparison between the value of the
'parameter-selector-test' parameter and the value of the 'test' attribute of
the <map:when ...> element.

This internal parameter could be:
-- A sitemap parameter from the map:match portion of the pipeline
-- A sitemap parameter set by an action

Reasons to use ParameterSelector
-----------------------------------------

One purpose of this selector is to select between different pipeline
configurations based on sitemap parameters set by an action.  This would
allow the action to control the logic required to set one or more
parameters, which can then be used by this selector to control pipeline
processing.  Thus, complex decision-making logic can be contained in
actions, while the sitemap simply uses the results of the actions (the
parameters) to determine pipeline processing.

Parameter Selector can also be used to select on the value of 'keys' (such
as {1} or {../2} ) from the wildcard matcher.  Information in the URI, such
as part of a filename, can then be used to determine pipeline processing.   

Examples
------------

Add the component to your sitemap.xmap:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <map:components>
 ...
  <map:selectors>
  ...
    <map:selector
	name="parameter"
      	logger="sitemap.selector.parameter"
      	src="org.apache.cocoon.selection.ParameterSelector"/>
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use a parameter set by an action:

Assume there is an action (named MyAction) that sets a parameter (named
MyRegion) to several possible values.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<map:match pattern="*.xml">
  <map:act type="MyAction">
    <map:generate src="{1}.xml"/>

    <map:select type="parameter">
      <map:parameter name="parameter-selector-test" value="{MyRegion}"/>
      
      <!-- executes iff the value of MyRegion equals "United States"
(without quotes) -->
      <map:when test="United States">
        <map:transform src="stylesheets/us.xsl"/>
      </map:when>

      <map:when test="South_America">
        <map:transform src="stylesheets/southamerica.xsl"/>
      </map:when>

      <map:when test="Europe">
        <map:transform src="stylesheets/europe.xsl"/>
      </map:when>

      <map:otherwise>
        <map:transform src="all_others.xsl"
      </map:otherwise>

    </map:select>
  </map:act>
  <map:serialize/>
</map:match>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use values from the URI:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<map:pipeline>
  <map:match pattern="**/*/myfile.xml"> <!-- {1}/{2}/myfile.xml -->
   
    <!-- Use ParameterSelector -->
    <map:select type="parameter">
        <map:parameter name="parameter-selector-test" value="{2}"/>

       <!-- executes iff the value of {2} equals "basic" (without quotes);
the requested URI
              could be **/basic/myfile.xml -->
        <map:when test="basic">
            <map:generate src="{1}/myfile.xml"/>
            <map:transform src="stylesheets/basic.xsl">
                <map:parameter name="use-request-parameters" value="true"/>
                <map:parameter name="resource" value="{2}.html"/>
            </map:transform>
            <map:serialize/>
        </map:when>

        <map:when test="aggregate">
            <map:aggregate element="site">
        	<map:part src="cocoon:/{1}/sidebar-{1}/{2}.xml"/>
        	<map:part src="cocoon:/body-{1}/{2}.xsp"/>
            </map:aggregate>
            <map:transform src="stylesheets/aggregate2xhtml.xsl"/>
            <map:serialize/>
        </map:when>

        <map:otherwise>
            <map:redirect-to uri="other_URI"/>
        </map:otherwise>

    </map:select>
</map:match>
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




RE: [doc] Request feedback on Draft: Parameter Selector user doc

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Diana Shannon [mailto:shannon@apache.org]
> 
> 
> On Monday, July 1, 2002, at 06:52  PM, Naquin, Beth wrote:
> 
> Thanks Beth for your great work so far. Here's a few ideas how I would
> find answers to your questions.
> 
> > Parameter Selector
> > applies to:  cocoon 2.0.2, ?????????????? DOES THIS APPLY TO OTHER
> > VERSIONS OF COCOON ALSO??
> 
> Are you working with CVS? If not, you can use ViewCVS.
>    http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/
> 
> Well, a quick check in my cvs copy at
>    src/java/org/apache/cocoon/selection/
> in both HEAD and 2.0.3 branches shows the file ParameterSelector.java
> still exists.
> Looking into the source code itself, I don't see any deprecated
javadoc
> comments.
> Also, a diff of the version in release and the version in Head shows
no
> substantive difference.
> Safe bet to assume this applies all versions of Cocoon.

Yes.

 
> > Name: Parameter Selector
> > Class:  org.apache.cocoon.selection.ParameterSelector
> > Cacheable:  ????????  CAN SOMEONE ANSWER THIS, OR IS IT
NONAPPLICABLE??

N/A.

> I would say nonapplicable. How to check: To be cacheable, a sitemap
> component must either
> implement the Cacheable (deprecated) or the
CacheableProcessingComponent
> interface.
> This includes generators, transformers, and serializers -- *not*
> selectors.
> Reason: Selectors help control flow of a pipeline. Values of selectors
                         ^^^^^^^^^^^^^^^

"Help choose components of a pipeline", "help build a pipeline".


Vadim

> don't represent the XML
> content (the "stuff" flowing through the pipelines) which is the
actual
> target of caching mechanisms.
> 
> At least that's my interpretation...
>
> Diana


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: [doc] Request feedback on Draft: Parameter Selector user doc

Posted by Diana Shannon <sh...@apache.org>.
On Monday, July 1, 2002, at 06:52  PM, Naquin, Beth wrote:

Thanks Beth for your great work so far. Here's a few ideas how I would 
find answers to your questions.

> Parameter Selector
> applies to:  cocoon 2.0.2, ?????????????? DOES THIS APPLY TO OTHER 
> VERSIONS OF COCOON ALSO??

Are you working with CVS? If not, you can use ViewCVS.
   http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/

Well, a quick check in my cvs copy at
   src/java/org/apache/cocoon/selection/
in both HEAD and 2.0.3 branches shows the file ParameterSelector.java 
still exists.
Looking into the source code itself, I don't see any deprecated javadoc 
comments.
Also, a diff of the version in release and the version in Head shows no 
substantive difference.
Safe bet to assume this applies all versions of Cocoon.

> Name: Parameter Selector
> Class:  org.apache.cocoon.selection.ParameterSelector
> Cacheable:  ????????  CAN SOMEONE ANSWER THIS, OR IS IT NONAPPLICABLE??

I would say nonapplicable. How to check: To be cacheable, a sitemap 
component must either
implement the Cacheable (deprecated) or the CacheableProcessingComponent 
interface.
This includes generators, transformers, and serializers -- *not* 
selectors.
Reason: Selectors help control flow of a pipeline. Values of selectors 
don't represent the XML
content (the "stuff" flowing through the pipelines) which is the actual 
target of caching mechanisms.

At least that's my interpretation...

Diana


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>