cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lai, Harry" <>
Subject RE: [doc] Request feedback on Draft: Parameter Selector user doc
Date Tue, 02 Jul 2002 13:43:14 GMT
Hi Beth,

Great doc!  I just saw one minor bug in the first example.  You have:

<map:match pattern="*.xml"> 
  <map:act type="MyAction"> 
    <map:generate src="{1}.xml"/>

Since the generate call is inside the act, the parameter you want is
actually {../1}, not {1}.  Aside from that, though, this looks good to me.


-----Original Message-----
From: Naquin, Beth []
Sent: Monday, July 01, 2002 5:53 PM
Subject: [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, 
Parameter Selector 
applies to:  cocoon 2.0.2, ?????????????? DOES THIS APPLY TO OTHER VERSIONS
Name: Parameter Selector 
Class:  org.apache.cocoon.selection.ParameterSelector 

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.   
Add the component to your sitemap.xmap: 
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 test="South_America"> 
        <map:transform src="stylesheets/southamerica.xsl"/> 
      <map:when test="Europe"> 
        <map:transform src="stylesheets/europe.xsl"/> 
        <map:transform src="all_others.xsl" 
Use values from the URI: 
  <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: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:transform src="stylesheets/aggregate2xhtml.xsl"/> 
            <map:redirect-to uri="other_URI"/> 

Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message