dims        01/06/12 09:02:38

  Modified:    src/org/apache/cocoon/components/language/markup/sitemap/java
                        Tag: cocoon_20_branch sitemap.xsl
  Log:
  - Allow embedded map:match'es.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.11.2.7  +88 -1     
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.11.2.6
  retrieving revision 1.11.2.7
  diff -u -r1.11.2.6 -r1.11.2.7
  --- sitemap.xsl       2001/06/11 13:32:55     1.11.2.6
  +++ sitemap.xsl       2001/06/12 16:02:31     1.11.2.7
  @@ -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.11.2.6 2001/06/11 13:32:55 dims Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.11.2.7 2001/06/12 16:02:31 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"/>";
  @@ -530,6 +530,93 @@
         </xsl:for-each>
       }
     </xsl:template> <!-- match="map:sitemap" -->
  +
  +  <!-- 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 -->
  +        // handle embedded match for "<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 -->
  
  
  

----------------------------------------------------------------------
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