giacomo 01/05/18 07:16:56
Modified: src/org/apache/cocoon/matching Matcher.java
RequestParamMatcher.java
src/org/apache/cocoon/components/language/markup/sitemap/java
sitemap.xsl
Log:
Matchers can have <parameter> element as well now.
Revision Changes Path
1.2 +3 -2 xml-cocoon2/src/org/apache/cocoon/matching/Matcher.java
Index: Matcher.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/Matcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Matcher.java 2001/05/09 20:49:39 1.1
+++ Matcher.java 2001/05/18 14:16:30 1.2
@@ -9,11 +9,12 @@
import java.util.Map;
import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.parameters.Parameters;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:39 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/05/18 14:16:30 $
*/
public interface Matcher extends Component {
/**
@@ -31,7 +32,7 @@
* contained in the pattern.
* If the return value is null there was no match.
*/
- Map match (String pattern, Map objectModel);
+ Map match (String pattern, Map objectModel, Parameters parameters);
}
1.2 +4 -3
xml-cocoon2/src/org/apache/cocoon/matching/RequestParamMatcher.java
Index: RequestParamMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/RequestParamMatcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RequestParamMatcher.java 2001/05/15 11:34:21 1.1
+++ RequestParamMatcher.java 2001/05/18 14:16:34 1.2
@@ -18,6 +18,7 @@
import org.apache.cocoon.matching.Matcher;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.Constants;
+import org.apache.avalon.framework.parameters.Parameters;
/**
* This class allows for matching based on a request parameter.
@@ -29,9 +30,9 @@
* <map:match type="request" pattern="dest">
* <map:redirect-to uri="{1}"/>
* </map:match>
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
- * @version CVS $Revision: 1.1 $
+ * @version CVS $Revision: 1.2 $
*/
public class RequestParamMatcher implements Matcher {
/**
@@ -43,7 +44,7 @@
* @param objectModel environment passed through via cocoon
* @returns null or map containing value of request parameter 'pattern'
*/
- public Map match(String pattern, Map objectModel) {
+ public Map match(String pattern, Map objectModel, Parameters parameters)
{
Request request =
(Request) objectModel.get(Constants.REQUEST_OBJECT);
String param = request.getParameter(pattern);
1.5 +27 -5
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- sitemap.xsl 2001/05/18 11:04:17 1.4
+++ sitemap.xsl 2001/05/18 14:16:48 1.5
@@ -99,7 +99,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.4 2001/05/18 11:04:17 dims Exp $
+ * @version CVS $Id: sitemap.xsl,v 1.5 2001/05/18 14:16:48 giacomo 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"/>";
@@ -132,7 +132,7 @@
<xsl:variable name="type" select="translate(@name, '- ', '__')"/>
<xsl:variable name="default" select="$type = ../@default"/>
<xsl:variable name="config"><xsl:copy-of
select="."/></xsl:variable>
- private Map <xsl:value-of select="$type"/>Match (<xsl:value-of
select="java:getParameterSource($factory-loader, string($src),$config)"/>
pattern, Map objectModel) {
+ private Map <xsl:value-of select="$type"/>Match (<xsl:value-of
select="java:getParameterSource($factory-loader, string($src),$config)"/>
pattern, Map objectModel, Parameters parameters) {
<xsl:value-of select="java:getMethodSource($factory-loader,
string($src),$config)"/>
}
<!-- process all map:match elements with a type attribute refering
to the current matcher factory iteration -->
@@ -535,15 +535,37 @@
</xsl:choose>
</xsl:variable>
+ <!-- test if we have to define parameters for this matcher -->
+ <xsl:if test="count(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(parameter)>0">
+ param
+ </xsl:when>
+ <xsl:otherwise>
+ emptyParam
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- collect the parameters -->
+ <xsl:apply-templates select="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="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)
+ ((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>
@@ -597,7 +619,7 @@
<!-- modification end -->
<!-- Modified 20010510 L.Sutic Changed to pass sitemap parameters. -->
-
+
<!-- test if we have to define parameters for this action -->
<xsl:if test="count(parameter)>0">
param = new Parameters ();
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]