home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / parameter-selector.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  5.5 KB  |  174 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "document-v10.dtd">
  18.  
  19. <document>
  20.  <header>
  21.   <title>Parameter Selector</title>
  22.   <subtitle>in @doctitle@</subtitle>
  23.   <version>0.9</version>
  24.   <type>Technical document</type>
  25.   <authors>
  26.    <person name="Beth Naquin" email="beth.naquin@morpho.com"/>
  27.   </authors>
  28.   <abstract>This document describes the Parameter Selector.</abstract>
  29.  </header>
  30.  <body>
  31.   <s1 title="Parameter Selector">
  32.    
  33.    <ul>
  34.     <li>Name : ParameterSelector</li>
  35.     <li>Class: org.apache.cocoon.selection.ParameterSelector</li>
  36.     <li>Cacheable: not applicable</li>
  37.    </ul>
  38.    
  39.    <p>
  40.     This Selector matches a string, in the Parameters object passed to the 
  41.     selector, against a specified Cocoon internal parameter.  It performs a 
  42.     case-sensitive string comparison between the value of the 
  43.     'parameter-selector-test' parameter and the value of the 'test' 
  44.     attribute of the <code><![CDATA[<map:when ...>]]></code> element.
  45.    </p>
  46.    
  47.    <p>
  48.    This internal parameter could be:
  49.    </p>
  50.    <ul>
  51.     <li>A sitemap parameter from the <code><![CDATA[<map:match ...>]]></code> portion of the pipeline</li>
  52.     <li>A sitemap parameter set by an action</li>
  53.    </ul>
  54.    </s1>
  55.    
  56.    
  57.    <s1 title="Reasons to use ParameterSelector">
  58.    <p>
  59.    One purpose of this selector is to choose between different components 
  60.    of a pipeline based on sitemap parameters set by an action.  This would 
  61.    allow the action to control the logic required to set one or more parameters, 
  62.    which can then be used by this selector to control pipeline processing.  
  63.    Thus, complex decision-making logic can be contained in actions, while the 
  64.    sitemap simply uses the results of the actions (the parameters) to determine 
  65.    pipeline processing.
  66.    </p>
  67.    <p>
  68.    Parameter Selector can also be used to select on the value of 'keys' 
  69.    (such as {1} or {../2} ) from the wildcard matcher.  Information in the 
  70.    URI, such as part of a filename, can then be used to determine pipeline 
  71.    processing.   
  72.    </p>
  73.    </s1>
  74.    
  75.    <s1 title="Examples">
  76.    <p>
  77.    Add the component to your sitemap.xmap:
  78.    </p>
  79.    <source><![CDATA[
  80.    <map:components>
  81.     ...
  82.     <map:selectors>
  83.      ...
  84.      <map:selector
  85.         name="parameter"
  86.           logger="sitemap.selector.parameter"
  87.           src="org.apache.cocoon.selection.ParameterSelector"/>
  88.      ...]]></source>
  89.    
  90.    <p>
  91.    Use a parameter set by an action:
  92.    </p>
  93.    <p>
  94.     Assume there is an action (named MyAction) that sets a parameter 
  95.     (named MyRegion) to several possible values.  For more information on actions, 
  96.     including a simple example of an action that creates a sitemap parameter, see
  97.     <link href="../concepts/actions.html">Creating and Using Actions</link>.
  98.    </p>
  99.    <source><![CDATA[
  100.    <map:match pattern="*.xml">
  101.     <map:act type="MyAction">
  102.       <map:generate src="{../1}.xml"/>
  103.  
  104.       <map:select type="parameter">
  105.         <map:parameter name="parameter-selector-test" value="{MyRegion}"/>
  106.       
  107.         <!-- executes iff the value of MyRegion equals 
  108.              "United States" (without quotes) -->
  109.         <map:when test="United States">
  110.           <map:transform src="stylesheets/us.xsl"/>
  111.         </map:when>
  112.       
  113.         <map:when test="South_America">
  114.           <map:transform src="stylesheets/southamerica.xsl"/>
  115.         </map:when>
  116.  
  117.         <map:when test="Europe">
  118.           <map:transform src="stylesheets/europe.xsl"/>
  119.         </map:when>
  120.  
  121.         <map:otherwise>
  122.           <map:transform src="all_others.xsl"
  123.         </map:otherwise>
  124.  
  125.       </map:select>
  126.     </map:act>
  127.     <map:serialize/>
  128.   </map:match>]]></source>
  129.    
  130.    <p>
  131.    Use values from the URI:
  132.    </p>
  133.    <source><![CDATA[
  134.    <map:pipeline>
  135.      <!-- {1}/{2}/myfile.xml -->
  136.      <map:match pattern="**/*/myfile.xml"> 
  137.    
  138.        <!-- Use ParameterSelector -->
  139.        <map:select type="parameter">
  140.         <map:parameter name="parameter-selector-test" value="{2}"/>
  141.  
  142.         <!-- executes iff the value of {2} equals 
  143.              "basic" (without quotes); the requested URI
  144.               could be **/basic/myfile.xml -->
  145.         <map:when test="basic">
  146.             <map:generate src="{1}/myfile.xml"/>
  147.             <map:transform src="stylesheets/basic.xsl">
  148.                 <map:parameter name="use-request-parameters" value="true"/>
  149.                 <map:parameter name="resource" value="{2}.html"/>
  150.             </map:transform>
  151.             <map:serialize/>
  152.         </map:when>
  153.  
  154.         <map:when test="aggregate">
  155.             <map:aggregate element="site">
  156.             <map:part src="cocoon:/{1}/sidebar-{1}/{2}.xml"/>
  157.             <map:part src="cocoon:/body-{1}/{2}.xsp"/>
  158.             </map:aggregate>
  159.             <map:transform src="stylesheets/aggregate2xhtml.xsl"/>
  160.             <map:serialize/>
  161.         </map:when>
  162.  
  163.         <map:otherwise>
  164.             <map:redirect-to uri="other_URI"/>
  165.         </map:otherwise>
  166.  
  167.       </map:select>
  168.     </map:match> 
  169.     ...]]></source>
  170.    </s1>
  171.    
  172.  </body>
  173. </document>
  174.