haul 01/11/26 01:19:51
Modified: webapp sitemap.xmap
src/org/apache/cocoon/sitemap AbstractSitemap.java
src/org/apache/cocoon/matching
WildcardSessionAttributeMatcher.java
src/org/apache/cocoon/matching/helpers WildcardHelper.java
WildcardURIMatcher.java
src/org/apache/cocoon/components/language/markup/sitemap/java
sitemap.xsl
Log:
- Fixed stateful examples
- WildcardSessionAttributeMatcher hasn't declared to implement configurable (fixed)
- Added complete string in {0} for Wildcard(URI)?Matcher in addition to matches in
{1}...
- Added <map:dump-parameters/> in sitemap + method in AbstractSitemap to print out
current
sitemap parameters to log. Nice for debugging sitemaps + educational.
Revision Changes Path
1.63 +29 -14 xml-cocoon2/webapp/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/sitemap.xmap,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- sitemap.xmap 2001/11/23 09:25:55 1.62
+++ sitemap.xmap 2001/11/26 09:19:51 1.63
@@ -143,7 +143,7 @@
necessity, matchers can be nested while chaining does not work.
Related concepts are selectors and actions.
- Since this is important, let me repeat it: Selectors are executed
+ Since this is important, let me repeat it: Matchers are executed
during pipeline setup.
-->
@@ -203,7 +203,11 @@
pipelines. Use them to update databases, check external resources
etc. The execution may fail or complete successfully. Only if the
execution was successful, the pipeline fragment contained inside is
- used within the pipeline.
+ used within the pipeline. Related concepts are matchers and
+ selectors.
+
+ Since this is important, let me repeat it: Actions are executed
+ during pipeline setup.
-->
<map:actions>
@@ -268,9 +272,20 @@
</map:resource>
<map:resource name="dynamic-page1">
+ <map:dump-parameters/>
+ <!-- print all current sitemap parameters to log -->
<map:act type="session-state">
- <map:parameter name="new-state" value="{../next-state}"/>
- <map:redirect-to resource="dynamic-page"
target="{../target}/state{../../../org.apache.cocoon.SessionState}{../../next-state}"/>
+ <map:parameter name="new-state" value="{../0}"/>
+ <!--
+ use the complete string that was matched as a parameter. Compare
+ this with @target below. There the third sitemap parameter refers to
+ the very same string. Very this by looking at the log. This
+ irritating effect stems from the fact, that the above map:parameter
+ belongs conceptually still to the parent element while all other
+ nested tags are, well, nested.
+ -->
+ <map:dump-parameters/>
+ <map:redirect-to resource="dynamic-page"
target="{../target}/state{../../../0}{../../0}"/>
</map:act>
</map:resource>
@@ -332,7 +347,7 @@
You may have as many pipelines in your sitemap as you like. However,
it seems that the only purposes would be to specify different error
- handlers or mount subsitemaps.
+ handlers.
-->
<map:pipelines>
@@ -770,6 +785,7 @@
<!-- =========================== Dynamic ================================ -->
<map:match pattern="xsp/*">
+ <map:dump-parameters/>
<map:generate type="serverpages" src="docs/samples/xsp/{1}.xsp"/>
<map:transform src="stylesheets/dynamic-page2html.xsl">
<map:parameter name="view-source" value="docs/samples/xsp/{1}.xsp"/>
@@ -866,32 +882,31 @@
<!--
This example like the next one show, that matches can be
nested and don't need to match on URIs alone. By using a
- session attribute or the referer header for matches it is
+ session attribute or the referer header for matches it is
easy to model a state machine with the sitemap.
- There are user documents on this.
+ There are user documents on this.
-->
<map:act type="session-isvalid">
<!-- if session is valid ... -->
<map:match type="sessionstate" pattern="1">
- <!-- if a specific session attribute matches pattern "1" -->
+ <!-- if a specific session attribute matches pattern "1" -->
<map:match type="next-page" pattern="1">
- <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
- <!-- by redirecting to this resource, the rest
- of this fragment here is irrelevant -->
+ <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
+ <!-- by redirecting to this resource, the rest of this fragment here
is irrelevant -->
</map:match>
<map:match type="next-page" pattern="2">
- <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
+ <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
</map:match>
</map:match>
<map:match type="sessionstate" pattern="2">
<map:match type="next-page" pattern="1">
- <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
+ <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
</map:match>
<map:match type="next-page" pattern="2">
- <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
+ <map:redirect-to resource="dynamic-page1"
target="docs/samples/session-state"/>
</map:match>
</map:match>
1.20 +27 -1 xml-cocoon2/src/org/apache/cocoon/sitemap/AbstractSitemap.java
Index: AbstractSitemap.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/AbstractSitemap.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- AbstractSitemap.java 2001/10/11 07:28:23 1.19
+++ AbstractSitemap.java 2001/11/26 09:19:51 1.20
@@ -42,12 +42,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Iterator;
/**
* Base class for generated <code>Sitemap</code> classes
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.19 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.20 $ $Date: 2001/11/26 09:19:51 $
*/
public abstract class AbstractSitemap extends AbstractLoggable implements Sitemap,
Disposable, ThreadSafe {
private Context context;
@@ -319,6 +320,31 @@
getLogger().error("AbstractSitemap:substitute()", e);
throw new PatternException("error occurred during evaluation of
expression \"" + expr + "\" at position " +
(i + 1) + "\n" + e.getMessage());
+ }
+ }
+
+ /**
+ * Dumps all sitemap parameters to log
+ */
+ protected void dumpParameters(List list) {
+ if (getLogger().isDebugEnabled()) {
+ StringBuffer sb=new StringBuffer();
+ if (!list.isEmpty()) {
+ sb.append("\nCurrent Sitemap Parameters:\n");
+ String path="";
+ for (int i=list.size()-1; i>=0; i--) {
+ Map map=(Map)list.get(i);
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String)keys.next();
+ sb.append(path)
+ .append("PARAM: '").append(key)
+ .append("' VALUE:
'").append(map.get(key)).append("'\n");
+ }
+ path="../"+path;
+ }
+ }
+ getLogger().debug(sb.toString());
}
}
1.3 +6 -2
xml-cocoon2/src/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java
Index: WildcardSessionAttributeMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WildcardSessionAttributeMatcher.java 2001/10/22 10:17:46 1.2
+++ WildcardSessionAttributeMatcher.java 2001/11/26 09:19:51 1.3
@@ -26,15 +26,19 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/10/22 10:17:46 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:19:51 $
*/
-public class WildcardSessionAttributeMatcher extends WildcardURIMatcher {
+public class WildcardSessionAttributeMatcher
+ extends WildcardURIMatcher
+ implements Configurable
+{
private String defaultParam;
public void configure(Configuration config) throws ConfigurationException {
this.defaultParam = config.getChild("attribute-name").getValue(null);
+ getLogger().debug("attribute-name is = '"+this.defaultParam+"'");
}
protected String getMatchString(Map objectModel, Parameters parameters) {
1.2 +4 -1
xml-cocoon2/src/org/apache/cocoon/matching/helpers/WildcardHelper.java
Index: WildcardHelper.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/helpers/WildcardHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WildcardHelper.java 2001/10/19 15:28:45 1.1
+++ WildcardHelper.java 2001/11/26 09:19:51 1.2
@@ -18,7 +18,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/10/19 15:28:45 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/11/26 09:19:51 $
*/
public class WildcardHelper {
@@ -152,6 +152,9 @@
// The matching count
int mcount = 0;
+
+ // We want the complete data be in {0}
+ map.put(Integer.toString(mcount),data);
// First check for MATCH_BEGIN
boolean matchBegin = false;
1.3 +4 -1
xml-cocoon2/src/org/apache/cocoon/matching/helpers/WildcardURIMatcher.java
Index: WildcardURIMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/helpers/WildcardURIMatcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WildcardURIMatcher.java 2001/10/19 15:28:45 1.2
+++ WildcardURIMatcher.java 2001/11/26 09:19:51 1.3
@@ -17,7 +17,7 @@
* (Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/10/19 15:28:45 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/11/26 09:19:51 $
* @deprecated renamed to WildcardHelper
*/
public class WildcardURIMatcher {
@@ -64,6 +64,9 @@
// The matching count
int mcount = 0;
+
+ // We want the complete data be in {0}
+ map.put(Integer.toString(mcount),data);
// First check for MATCH_BEGIN
boolean matchBegin = false;
1.48 +7 -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.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- sitemap.xsl 2001/11/14 22:43:43 1.47
+++ sitemap.xsl 2001/11/26 09:19:51 1.48
@@ -126,7 +126,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.47 2001/11/14 22:43:43 giacomo Exp $
+ * @version CVS $Id: sitemap.xsl,v 1.48 2001/11/26 09:19:51 haul 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"/>";
@@ -1614,6 +1614,12 @@
}
</xsl:for-each>
</xsl:template>
+
+ <!-- nice for debugging: print all kown sitemap parameters to log -->
+ <xsl:template match="map:dump-parameters">
+ this.dumpParameters(listOfMaps);
+ </xsl:template>
+
<!-- this template is used to setup a individual sitemap component before putting
it into a pipeline -->
<xsl:template name="setup-component">
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]