dims        01/06/12 10:18:01

  Modified:    src/org/apache/cocoon/components/language/markup/sitemap/java
                        sitemap.xsl
  Log:
  Sync with 2.0 b1 dev
  
  Revision  Changes    Path
  1.16      +98 -10    
xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- sitemap.xsl       2001/06/11 13:37:06     1.15
  +++ sitemap.xsl       2001/06/12 17:17:58     1.16
  @@ -127,7 +127,7 @@
        *
        * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
        * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  -     * @version CVS $Id: sitemap.xsl,v 1.15 2001/06/11 13:37:06 dims Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.16 2001/06/12 17:17:58 dims Exp $
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
         static final String LOCATION = "<xsl:value-of select="translate(@file-path, 
'/', '.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -192,6 +192,7 @@
                 </xsl:call-template>
               </xsl:variable>
               <!-- produce a definition for this test string -->
  +            // The generated selector for a pattern of "<xsl:value-of 
select="@test"/>"
               <xsl:value-of 
select="XSLTFactoryLoader:getClassSource($factory-loader,string($src),string($selector-name),string(@test),$config)"/>
             </xsl:for-each>
           </xsl:if>
  @@ -461,8 +462,8 @@
                     <xsl:with-param name="default"><xsl:value-of 
select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
                   </xsl:call-template>
                 </xsl:variable>
  -              // method for handling "<xsl:value-of select="@pattern"/>" 
  -              if(<xsl:value-of select="$matcher-type"/>Match<xsl:value-of 
select="generate-id(.)"/>( 
  +              // method for handling "<xsl:value-of select="@pattern"/>"
  +              if(<xsl:value-of select="$matcher-type"/>Match<xsl:value-of 
select="generate-id(.)"/>(
                                                       environment, pipeline, 
eventPipeline,
                                                       internalRequest,listOfMaps))
                   return true;
  @@ -477,9 +478,9 @@
                 <xsl:when test="(./map:handle-errors)">
                   getLogger().warn("Error, try to process the error page", e);
                   try {
  -                  return error_process_<xsl:value-of select="$pipeline-position"/> 
(environment, 
  -                                                                                    
environment.getObjectModel(), 
  -                                                                                    
e, 
  +                  return error_process_<xsl:value-of select="$pipeline-position"/> 
(environment,
  +                                                                                    
environment.getObjectModel(),
  +                                                                                    
e,
                                                                                       
internalRequest);
                   } catch (Exception ex) {
                     getLogger().warn("Sitemap Error Process", ex);
  @@ -533,6 +534,93 @@
   
     <!-- a match element calls a match method on a matcher component (or a inlined
          matcher method produced by a CodeFactory -->
  +  <xsl:template match="map:match//map:match">
  +
  +    <!-- get the type of matcher used -->
  +    <xsl:variable name="matcher-type">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="parname">type</xsl:with-param>
  +        <xsl:with-param name="default"><xsl:value-of 
select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <!-- get the pattern used -->
  +    <xsl:variable name="pattern-value">
  +      <xsl:call-template name="get-parameter">
  +        <xsl:with-param name="parname">pattern</xsl:with-param>
  +        <xsl:with-param name="required">true</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <!-- remove all invalid chars from the pattern. The result is used to form the 
name of the generated method
  +         in case this matcher is produced by a CodeFactory -->
  +    <xsl:variable name="matcher-name2">
  +      <xsl:call-template name="generate-name">
  +        <xsl:with-param name="prefix">matcher_</xsl:with-param>
  +        <xsl:with-param name="suffix"><xsl:value-of 
select="$matcher-type"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:variable>
  +
  +    <!-- check if this matcher is a factory ? -->
  +    <xsl:variable name="is-factory">
  +      <xsl:value-of select="XSLTFactoryLoader:isFactory($factory-loader, 
string(/map:sitemap/map:components/map:matchers/map:matcher[@name=$matcher-type]/@src))"/>
  +    </xsl:variable>
  +
  +    <!-- break on error when old parameter syntax exists -->
  +    <xsl:if test="parameter">
  +      <xsl:call-template name="error">
  +        <xsl:with-param name="message">Sitemap parameters should now be in the 
sitemap namespace (map:parameter).</xsl:with-param>
  +      </xsl:call-template>
  +    </xsl:if>
  +
  +    <!-- test if we have to define parameters for this matcher -->
  +    <xsl:if test="count(map:parameter)>0">
  +      param = new Parameters ();
  +    </xsl:if>
  +
  +    <!-- generate the value used for the parameter argument in the invocation of 
this matcher -->
  +    <xsl:variable name="component-param">
  +      <xsl:choose>
  +        <xsl:when test="count(map:parameter)>0">
  +          param
  +        </xsl:when>
  +        <xsl:otherwise>
  +          emptyParam
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +    <!-- collect the parameters -->
  +    <xsl:apply-templates select="map:parameter">
  +        <xsl:with-param name="param">param</xsl:with-param>
  +    </xsl:apply-templates>
  +
  +    <!-- gets the string how the matcher is to be invoked in java code -->
  +    <xsl:variable name="matcher-name">
  +      <!-- check if we have a matcher definition in this sitemap otherwise get it 
from the parent -->
  +      <xsl:choose>
  +        <xsl:when test="string($is-factory)='true'">
  +          <xsl:value-of select="translate($matcher-type, '- ', 
'__')"/>Match(<xsl:value-of select="$matcher-name2"/>_expr, objectModel, <xsl:value-of 
select="$component-param"/>)
  +        </xsl:when>
  +        <xsl:otherwise>
  +          ((Matcher)this.matchers.select("<xsl:value-of 
select="$matcher-type"/>")).match(substitute(listOfMaps,"<xsl:value-of 
select="$pattern-value"/>"), objectModel, <xsl:value-of select="$component-param"/>)
  +        </xsl:otherwise>
  +      </xsl:choose>
  +    </xsl:variable>
  +
  +
  +    <!-- this is the actual code produced -->
  +    // handling "<xsl:value-of select="@pattern"/>"
  +        if ((map = <xsl:value-of select="$matcher-name"/>) != null) {
  +          getLogger().debug("Matched <xsl:value-of select="$matcher-type"/> 
<xsl:value-of select="$matcher-name2"/>");
  +          listOfMaps.add (map);
  +          <xsl:apply-templates/>
  +          listOfMaps.remove (listOfMaps.size()-1);
  +        }
  +  </xsl:template> <!-- match="map:match//map:match" -->
  +
  +  <!-- a match element calls a match method on a matcher component (or a inlined
  +       matcher method produced by a CodeFactory -->
     <xsl:template match="map:match">
   
       <!-- get the type of matcher used -->
  @@ -609,11 +697,11 @@
   
   
       <!-- this is the actual code produced -->
  -    // method for handling "<xsl:value-of select="@pattern"/>" 
  +    // method for handling "<xsl:value-of select="@pattern"/>"
       private boolean <xsl:value-of select="$matcher-type"/>Match<xsl:value-of 
select="generate-id(.)"/>(
  -                                    Environment environment, StreamPipeline 
pipeline, 
  +                                    Environment environment, StreamPipeline 
pipeline,
                                       EventPipeline eventPipeline,
  -                                    boolean internalRequest, List listOfMaps) 
  +                                    boolean internalRequest, List listOfMaps)
               throws ConnectionResetException, ResourceNotFoundException, Exception {
           Map map;
           Parameters param;
  @@ -621,7 +709,7 @@
           SitemapRedirector redirector = new SitemapRedirector(environment);
           String cocoon_view = environment.getView();
           String cocoon_action = environment.getAction();
  -        
  +
           if ((map = <xsl:value-of select="$matcher-name"/>) != null) {
             getLogger().debug("Matched <xsl:value-of select="$matcher-type"/> 
<xsl:value-of select="$matcher-name2"/>");
             listOfMaps.add (map);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to