Hi.

Current sitemap.xsl presents three problems:

1) in matchers type is erroneously converted but compared to
   unconverted type

2) in matchers name2 is erroneously not converted thus trying to
   define java variables containing " " or "-".

   Since it appears code was copied for selectors the same problems
   occur there too.

3) If an actions has parameters defined, they are inserted before and
   after the action is called (several places).

The attached patch fixes the above.

In addition it enables parameter substitution on <map:redirect-to resource="" 
target="{parameter}">

        Chris.

PS: Any comments on the patch I submitted on thursday? Seems not to
    have made it. (message-id 
[EMAIL PROTECTED])

-- 
C h r i s t i a n       H a u l
[EMAIL PROTECTED]
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
Index: src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
===================================================================
RCS file: 
/home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
retrieving revision 1.20
diff -u -r1.20 sitemap.xsl
--- src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl   
2001/06/22 02:47:40     1.20
+++ src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl   
+2001/06/26 14:32:28
@@ -148,19 +148,20 @@
           <xsl:value-of select="@src"/>
         </xsl:variable>
         <xsl:if test="XSLTFactoryLoader:isFactory($factory-loader, string($src))">
+          <xsl:variable name="name" select="@name"/>
           <xsl:variable name="type" select="translate(@name, '- ', '__')"/>
-          <xsl:variable name="default" select="$type = ../@default"/>
+          <xsl:variable name="default" select="@name = ../@default"/>
           <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
           private Map <xsl:value-of select="$type"/>Match (<xsl:value-of 
select="XSLTFactoryLoader:getParameterSource($factory-loader, string($src),$config)"/> 
pattern, Map objectModel, Parameters parameters) {
             <xsl:value-of select="XSLTFactoryLoader:getMethodSource($factory-loader, 
string($src),$config)"/>
           }
           <!-- process all map:match elements with a type attribute refering to the 
current matcher factory iteration -->
-          <xsl:for-each 
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:match[@type=$type
 or (not(@type) and $default)]">
+          <xsl:for-each 
+select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:match[@type=$name
+ or (not(@type) and $default)]">
             <xsl:call-template name="line-number"/>
             <xsl:variable name="matcher-name">
               <xsl:call-template name="generate-name">
                 <xsl:with-param name="prefix">matcher_</xsl:with-param>
-                <xsl:with-param name="suffix"><xsl:value-of 
select="$type"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
+                <xsl:with-param name="suffix"><xsl:value-of 
+select="$name"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
               </xsl:call-template>
             </xsl:variable>
             // The generated matcher for a pattern of "<xsl:value-of 
select="@pattern"/>"
@@ -189,7 +190,7 @@
             <xsl:variable name="selector-name">
               <xsl:call-template name="generate-name">
                 <xsl:with-param name="prefix">selector_</xsl:with-param>
-                <xsl:with-param name="suffix"><xsl:value-of 
select="$type"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
+                <xsl:with-param name="suffix"><xsl:value-of 
+select="$name"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
               </xsl:call-template>
             </xsl:variable>
             <!-- produce a definition for this test string -->
@@ -471,7 +472,7 @@
                 </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(.)"/>(
+              if(<xsl:value-of select="translate($matcher-type, '- ', 
+'__')"/>Match<xsl:value-of select="generate-id(.)"/>(
                                                     environment, pipeline, 
eventPipeline,
                                                     internalRequest,listOfMaps))
                 return true;
@@ -897,7 +898,7 @@
          }
          getLogger().debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
           listOfMaps.add (map);
-          <xsl:apply-templates/>
+      <xsl:apply-templates 
+select="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0' and local-name() 
+!= 'parameter']"/>
           listOfMaps.remove(listOfMaps.size()-1);
         }
          if (redirector.hasRedirected()) {
@@ -957,7 +958,7 @@
         if ((map = <xsl:value-of select="$action-name"/> (redirector, environment, 
objectModel, substitute(listOfMaps,<xsl:value-of select="$action-source"/>), 
<xsl:value-of select="$component-param"/>)) != null) {
          getLogger().debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
           listOfMaps.add (map);
-          <xsl:apply-templates/>
+          <xsl:apply-templates 
+select="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0' and local-name() 
+!= 'parameter']"/>
           listOfMaps.remove(listOfMaps.size()-1);
         }
       </xsl:when>
@@ -1029,7 +1030,7 @@
           }
          getLogger().debug("Action <xsl:value-of 
select="translate($action-name,'&quot;',' ')"/>");
           listOfMaps.add (map);
-          <xsl:apply-templates/>
+          <xsl:apply-templates 
+select="./*[namespace-uri()='http://apache.org/cocoon/sitemap/1.0' and local-name() 
+!= 'parameter']"/>
           listOfMaps.remove(listOfMaps.size()-1);
         }
           if (redirector.hasRedirected()) {
@@ -1179,7 +1180,7 @@
         </xsl:variable>
         <xsl:if test="string-length($target) > 0 and string($target) != 
'&quot;&quot;'">
           map = new HashMap(1);
-          map.put("target","<xsl:value-of select="$target"/>");
+          map.put("target",substitute(listOfMaps,"<xsl:value-of select="$target"/>"));
           listOfMaps.add(map);
         </xsl:if>
          Class[] argTypes = new Class[] {StreamPipeline.class, EventPipeline.class, 
List.class, Environment.class, String.class, Boolean.TYPE};
@@ -1518,7 +1519,7 @@
   <xsl:template name="generate-name">
     <xsl:param name="prefix"/>
     <xsl:param name="suffix"/>
-    <xsl:value-of select="$prefix"/><xsl:value-of select="$suffix"/>
+    <xsl:value-of select="translate(concat($prefix,$suffix),'- ','__')"/>
   </xsl:template>
 
   <!-- These are the usual utility templates for logicsheets -->

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to