You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/07/21 18:24:37 UTC
svn commit: r678458 - in /cocoon/whiteboard/corona/trunk:
corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/
corona-sample/src/main/resources/COB-INF/
corona-sample/src/main/resources/COB-INF/sax-pipeline/
corona-servlet/src/main/java/org/...
Author: reinhard
Date: Mon Jul 21 09:24:36 2008
New Revision: 678458
URL: http://svn.apache.org/viewvc?rev=678458&view=rev
Log:
. differentiate between match and select + update schema
. fix bug with nested match/select structures (match -> if; select -> switch)
. Invocation: rename removeActions() to reset because there is more cleanup work that needs to be done in the case of an error invocation
. add additional test cases for match/select
Added:
cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt (with props)
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java (with props)
Modified:
cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java
cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html
cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/simple.xslt
cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/RedirectNode.java
cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/Invocation.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/AbstractSitemapNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ActNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ErrorNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/GenerateNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/InvocationResult.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/MatchNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/OtherwiseNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelineNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelinesNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ReadNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SerializeNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/TransformNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/WhenNode.java
cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/resources/corona-sitemap-1.0.xsd
Modified: cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample-webapp/src/test/java/org/apache/cocoon/corona/it/MatcherTest.java Mon Jul 21 09:24:36 2008
@@ -66,4 +66,40 @@
this.assertXPath("/html/body/p", "otherwise");
}
+ public void testDeeplyNestedMatcherSelector1() throws Exception {
+ this.loadXmlPage("advanced-matching-4?param_a=1¶m_b=1¶m_c=1¶m_d=1¶m_e=1");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/xml", this.response.getContentType());
+ this.assertXPath("/html/body/p[text() = '1']", "1");
+ this.assertXPath("/html/body/p[text() = '2']", "2");
+ this.assertXPath("/html/body/p[text() = '3']", "3");
+ this.assertXPath("/html/body/p[text() = '4']", "4");
+ this.assertXPath("/html/body/p[text() = '5']", "");
+ this.assertXPath("/html/body/p[text() = '6']", "6");
+ }
+
+ public void testDeeplyNestedMatcherSelector2() throws Exception {
+ this.loadXmlPage("advanced-matching-4?param_a=1¶m_b=1¶m_c=1¶m_d=2¶m_e=1");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/xml", this.response.getContentType());
+ this.assertXPath("/html/body/p[text() = '1']", "1");
+ this.assertXPath("/html/body/p[text() = '2']", "2");
+ this.assertXPath("/html/body/p[text() = '3']", "3");
+ this.assertXPath("/html/body/p[text() = '4']", "");
+ this.assertXPath("/html/body/p[text() = '5']", "");
+ this.assertXPath("/html/body/p[text() = '6']", "6");
+ }
+
+ public void testDeeplyNestedMatcherSelector3() throws Exception {
+ this.loadXmlPage("advanced-matching-4?param_a=1¶m_b=2¶m_e=1");
+ assertTrue(this.response.getStatusCode() == 200);
+ assertEquals("text/xml", this.response.getContentType());
+ this.assertXPath("/html/body/p[text() = '1']", "1");
+ this.assertXPath("/html/body/p[text() = '2']", "");
+ this.assertXPath("/html/body/p[text() = '3']", "");
+ this.assertXPath("/html/body/p[text() = '4']", "");
+ this.assertXPath("/html/body/p[text() = '5']", "5");
+ this.assertXPath("/html/body/p[text() = '6']", "6");
+ }
+
}
Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/overview.html Mon Jul 21 09:24:36 2008
@@ -72,6 +72,7 @@
<li><a href="advanced-matching">Otherwise</a> Reach the otherwise section</li>
<li><a href="advanced-matching-2?myparam=1">Uncomplete pipeline: when</a> Adding a transformer</li>
<li><a href="advanced-matching-2?myparam=2">Uncomplete pipeline: otherwise</a> Adding a transformer</li>
+ <li><a href="advanced-matching-3?myparam=1&yourparam=2">Two matchers: Two matchers that add components to a pipeline.</li>
</ul>
<h2>Aggregation</h2>
<ul>
Added: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt?rev=678458&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt (added)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt Mon Jul 21 09:24:36 2008
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:param name="text" />
+
+ <xsl:template match="body">
+ <body>
+ <xsl:apply-templates select="@*|node()|text()|comment()|processing-instruction()" />
+ <p>
+ <xsl:value-of select="$text" />
+ </p>
+ </body>
+ </xsl:template>
+
+ <xsl:template match="@*|node()|text()|comment()|processing-instruction()" priority="-1">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()|text()|comment()|processing-instruction()" />
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/add-paragraph.xslt
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/simple.xslt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/simple.xslt?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/simple.xslt (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sax-pipeline/simple.xslt Mon Jul 21 09:24:36 2008
@@ -6,9 +6,9 @@
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,7 @@
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:param name="myParam"/>
+ <xsl:param name="myParam" />
<xsl:template match="/">
<html>
@@ -27,7 +27,9 @@
<body>
<h1>Simple Pipeline</h1>
- <p><xsl:value-of select="$myParam"/></p>
+ <p>
+ <xsl:value-of select="$myParam" />
+ </p>
</body>
</html>
</xsl:template>
Modified: cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/whiteboard/corona/trunk/corona-sample/src/main/resources/COB-INF/sitemap.xmap Mon Jul 21 09:24:36 2008
@@ -178,7 +178,7 @@
<!-- ~~~~~~~~~~~~~~~~ advanced matching (when/otherwise) ~~~~~~~~~~~~~~~ -->
<map:pipeline>
<map:match pattern="advanced-matching">
- <map:match value="{jexl:corona.request.myparam}">
+ <map:select value="{jexl:corona.request.myparam}">
<map:when equals="11">
<map:generate src="sax-pipeline/simple.xml" />
<map:transform src="sax-pipeline/simple.xslt">
@@ -207,11 +207,11 @@
</map:transform>
<map:serialize />
</map:otherwise>
- </map:match>
+ </map:select>
</map:match>
<map:match wildcard="advanced-matching-2">
<map:generate src="sax-pipeline/simple.xml" />
- <map:match value="{jexl:corona.request.myparam}">
+ <map:select value="{jexl:corona.request.myparam}">
<map:when equals="1">
<map:transform src="sax-pipeline/simple.xslt">
<map:parameter name="myParam" value="1" />
@@ -222,6 +222,58 @@
<map:parameter name="myParam" value="otherwise" />
</map:transform>
</map:otherwise>
+ </map:select>
+ <map:serialize />
+ </map:match>
+ <map:match wildcard="advanced-matching-3">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:match value="{jexl:corona.request.myparam}" equals="1">
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="1" />
+ </map:transform>
+ </map:match>
+ <map:match value="{jexl:corona.request.yourparam}" equals="2">
+ <map:transform src="sax-pipeline/add-paragraph.xslt">
+ <map:parameter name="text" value="2"/>
+ </map:transform>
+ </map:match>
+ <map:serialize />
+ </map:match>
+ <map:match wildcard="advanced-matching-4">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="1" />
+ </map:transform>
+ <map:match value="{jexl:corona.request.param_a}" equals="1">
+ <map:select value="{jexl:corona.request.param_b}">
+ <map:when equals="1">
+ <map:transform src="sax-pipeline/add-paragraph.xslt">
+ <map:parameter name="text" value="2"/>
+ </map:transform>
+ <map:match value="{jexl:corona.request.param_c}" equals="1">
+ <map:transform src="sax-pipeline/add-paragraph.xslt">
+ <map:parameter name="text" value="3"/>
+ </map:transform>
+ <map:select value="{jexl:corona.request.param_d}">
+ <map:when equals="1">
+ <map:transform src="sax-pipeline/add-paragraph.xslt">
+ <map:parameter name="text" value="4"/>
+ </map:transform>
+ </map:when>
+ </map:select>
+ </map:match>
+ </map:when>
+ <map:otherwise>
+ <map:transform src="sax-pipeline/add-paragraph.xslt">
+ <map:parameter name="text" value="5"/>
+ </map:transform>
+ </map:otherwise>
+ </map:select>
+ </map:match>
+ <map:match value="{jexl:corona.request.param_e}" equals="1">
+ <map:transform src="sax-pipeline/add-paragraph.xslt">
+ <map:parameter name="text" value="6"/>
+ </map:transform>
</map:match>
<map:serialize />
</map:match>
@@ -319,7 +371,7 @@
</map:pipeline>
<map:handle-errors>
- <map:match value="{jexl:corona.exception.class.name}">
+ <map:select value="{jexl:corona.exception.class.name}">
<map:when contains="NoMatchingPipelineException">
<map:generate src="error-handling/404.xml" />
<map:serialize type="xhtml" status-code="404" />
@@ -332,7 +384,7 @@
<map:generate type="exception" />
<map:serialize type="xml" status-code="500" />
</map:otherwise>
- </map:match>
+ </map:select>
<!--
<map:select type="custom-exception">
<map:when test="not-found">
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/RedirectNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/RedirectNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/RedirectNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/RedirectNode.java Mon Jul 21 09:24:36 2008
@@ -37,7 +37,7 @@
invocation.installComponent("redirector", this.getParameters());
// signal that we did some processing
- return InvocationResult.PROCESSED;
+ return InvocationResult.CONTINUE;
}
/**
Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/node/StatusCodeCollector.java Mon Jul 21 09:24:36 2008
@@ -56,7 +56,7 @@
InvocationResult invocationResult = (InvocationResult) proceedingJoinPoint.proceed();
- if (invocationResult.isProcessed() && statusCode != null) {
+ if (invocationResult.isContinued() && statusCode != null) {
THREAD_LOCAL.set(Integer.valueOf(statusCode));
}
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/Invocation.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/Invocation.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/Invocation.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/Invocation.java Mon Jul 21 09:24:36 2008
@@ -24,8 +24,6 @@
public interface Invocation {
- void clearActions();
-
void execute() throws Exception;
OutputStream getOutputStream();
@@ -48,6 +46,8 @@
boolean isErrorInvocation();
+ void reset();
+
URL resolve(String resource);
void setOutputStream(OutputStream outputStream);
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java Mon Jul 21 09:24:36 2008
@@ -96,10 +96,11 @@
/**
* {@inheritDoc}
*
- * @see org.apache.cocoon.corona.sitemap.Invocation#clearActions()
+ * @see org.apache.cocoon.corona.sitemap.Invocation#reset()
*/
- public void clearActions() {
+ public void reset() {
this.actions.clear();
+ this.hasFinisher = false;
}
/**
@@ -305,6 +306,11 @@
return this.componentProvider.getLanguageInterpreter(language);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.corona.sitemap.Invocation#resolveParameter(java.lang.String)
+ */
public String resolveParameter(final String parameter) {
if (parameter == null) {
return null;
@@ -357,4 +363,4 @@
public void setObjectModel(ObjectModel objectModel) {
this.objectModel = objectModel;
}
-}
+}
\ No newline at end of file
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/AbstractSitemapNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/AbstractSitemapNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/AbstractSitemapNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/AbstractSitemapNode.java Mon Jul 21 09:24:36 2008
@@ -99,7 +99,7 @@
result = currentResult;
}
- if (result.isCompleted()) {
+ if (result.isCompleted() || result == InvocationResult.BREAK) {
break;
}
}
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ActNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ActNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ActNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ActNode.java Mon Jul 21 09:24:36 2008
@@ -34,7 +34,7 @@
invocation.installAction(ACTION_CATEGORY + this.type);
// signal that we did some processing
- return InvocationResult.PROCESSED;
+ return InvocationResult.CONTINUE;
}
@Override
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ErrorNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ErrorNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ErrorNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ErrorNode.java Mon Jul 21 09:24:36 2008
@@ -30,7 +30,7 @@
return InvocationResult.NONE;
}
- if (super.invoke(invocation).isProcessed()) {
+ if (super.invoke(invocation).isContinued()) {
return InvocationResult.COMPLETED;
}
return InvocationResult.NONE;
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/GenerateNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/GenerateNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/GenerateNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/GenerateNode.java Mon Jul 21 09:24:36 2008
@@ -55,7 +55,7 @@
invocation.installComponent(GENERATOR_CATEGORY + this.type, parameters);
// signal that we did some processing
- return InvocationResult.PROCESSED;
+ return InvocationResult.CONTINUE;
}
/**
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/InvocationResult.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/InvocationResult.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/InvocationResult.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/InvocationResult.java Mon Jul 21 09:24:36 2008
@@ -20,22 +20,22 @@
public enum InvocationResult {
- NONE(false, false), PROCESSED(true, false), COMPLETED(true, true);
+ NONE(false, false), CONTINUE(true, false), BREAK(true, false), COMPLETED(true, true);
private boolean isCompleted;
- private boolean isProcessed;
+ private boolean isContinued;
- InvocationResult(boolean isProcessed, boolean isCompleted) {
+ InvocationResult(boolean isContinued, boolean isCompleted) {
this.isCompleted = isCompleted;
- this.isProcessed = isProcessed;
+ this.isContinued = isContinued;
}
public boolean isCompleted() {
return this.isCompleted;
}
- public boolean isProcessed() {
- return this.isProcessed;
+ public boolean isContinued() {
+ return this.isContinued;
}
}
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/MatchNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/MatchNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/MatchNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/MatchNode.java Mon Jul 21 09:24:36 2008
@@ -91,20 +91,10 @@
this.matcherContext = this.lookupMatcherContext();
// if there are NO matching attributes (regexp, equals, ...) set, execute the children
if (this.matcherContext == null) {
- InvocationResult invocationResult = super.invoke(invocation);
-
- if (invocationResult.isProcessed()) {
- if (invocation.hasCompletePipeline()) {
- return InvocationResult.COMPLETED;
- } else {
- return InvocationResult.PROCESSED;
- }
- }
-
- return InvocationResult.NONE;
+ throw new RuntimeException("Error!");
}
- // if there are matching attributes, invoke the matcher and execute the children afterwards
+ // invoke the matcher and execute the children afterwards
Map<String, String> matches = this.matcherContext.match(testValue);
if (matches == null) {
// do not ask our children, there was no match
@@ -115,8 +105,12 @@
InvocationResult invocationResult = super.invoke(invocation);
invocation.popSitemapParameters();
- if (invocationResult.isProcessed()) {
- return InvocationResult.COMPLETED;
+ if (invocationResult.isContinued()) {
+ if (invocation.hasCompletePipeline()) {
+ return InvocationResult.COMPLETED;
+ } else {
+ return InvocationResult.CONTINUE;
+ }
}
return InvocationResult.NONE;
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/OtherwiseNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/OtherwiseNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/OtherwiseNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/OtherwiseNode.java Mon Jul 21 09:24:36 2008
@@ -19,37 +19,33 @@
package org.apache.cocoon.corona.sitemap.node;
import org.apache.cocoon.corona.sitemap.Invocation;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
@Node(name = "otherwise")
-public class OtherwiseNode extends WhenNode {
-
- private final Log logger = LogFactory.getLog(this.getClass());
+public class OtherwiseNode extends AbstractSitemapNode {
/**
* {@inheritDoc}
*
- * @see org.apache.cocoon.corona.sitemap.node.WhenNode#invoke(org.apache.cocoon.corona.sitemap.Invocation)
+ * @see org.apache.cocoon.corona.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.corona.sitemap.Invocation)
*/
@Override
public InvocationResult invoke(Invocation invocation) {
- if (invocation.isErrorInvocation() && !this.hasHandleErrorsParent(this.getParent())) {
- if (this.logger.isDebugEnabled()) {
- this.logger
- .debug("Stop here because it's an error invocation and this node is defined outside of <handle-errors>.");
- }
- return InvocationResult.NONE;
- }
-
this.checkParent();
- InvocationResult invocationResult = super.invoke(invocation);
-
- if (invocationResult.isProcessed()) {
+ InvocationResult result = super.invoke(invocation);
+ if (invocation.hasCompletePipeline()) {
return InvocationResult.COMPLETED;
}
+ if (result.isContinued()) {
+ return InvocationResult.BREAK;
+ }
return InvocationResult.NONE;
}
+
+ protected void checkParent() {
+ if (!(this.getParent() instanceof SelectNode)) {
+ throw new RuntimeException("The parent node has to be a select node.");
+ }
+ }
}
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelineNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelineNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelineNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelineNode.java Mon Jul 21 09:24:36 2008
@@ -50,7 +50,7 @@
try {
// now proceed as usual (invoking our children)
- if (!super.invoke(invocation).isProcessed()) {
+ if (!super.invoke(invocation).isContinued()) {
// indicate that we couldn't handle this
return InvocationResult.NONE;
}
@@ -67,7 +67,7 @@
}
private void clearActions(Invocation invocation) {
- invocation.clearActions();
+ invocation.reset();
}
/**
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelinesNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelinesNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelinesNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/PipelinesNode.java Mon Jul 21 09:24:36 2008
@@ -38,7 +38,7 @@
@Override
public InvocationResult invoke(Invocation invocation) {
try {
- if (super.invoke(invocation).isProcessed()) {
+ if (super.invoke(invocation).isContinued()) {
// signal that we handled this successfully
return InvocationResult.COMPLETED;
}
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ReadNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ReadNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ReadNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/ReadNode.java Mon Jul 21 09:24:36 2008
@@ -49,7 +49,7 @@
invocation.installComponent(READER_CATEGORY + this.type, parameters);
// signal that we did some processing
- return InvocationResult.PROCESSED;
+ return InvocationResult.CONTINUE;
}
/**
Added: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java?rev=678458&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java (added)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java Mon Jul 21 09:24:36 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.corona.sitemap.node;
+
+import org.apache.cocoon.corona.sitemap.Invocation;
+import org.apache.cocoon.corona.sitemap.node.annotations.Parameter;
+
+@Node(name = "select")
+public class SelectNode extends AbstractSitemapNode {
+
+ @Parameter
+ private String value;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.corona.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.corona.sitemap.Invocation)
+ */
+ @Override
+ public InvocationResult invoke(Invocation invocation) {
+ InvocationResult invocationResult = super.invoke(invocation);
+
+ if (invocationResult == InvocationResult.BREAK) {
+ if (invocation.hasCompletePipeline()) {
+ return InvocationResult.COMPLETED;
+ }
+
+ return InvocationResult.CONTINUE;
+ }
+
+ if (invocationResult.isContinued()) {
+ if (invocation.hasCompletePipeline()) {
+ return InvocationResult.COMPLETED;
+ }
+
+ return InvocationResult.CONTINUE;
+ }
+
+ return InvocationResult.NONE;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+}
\ No newline at end of file
Propchange: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SelectNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SerializeNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SerializeNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SerializeNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/SerializeNode.java Mon Jul 21 09:24:36 2008
@@ -44,7 +44,7 @@
invocation.installComponent(SERIALIZER_CATEGORY + this.type, this.getParameters());
// signal that we did some processing
- return InvocationResult.PROCESSED;
+ return InvocationResult.CONTINUE;
}
/**
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/TransformNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/TransformNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/TransformNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/TransformNode.java Mon Jul 21 09:24:36 2008
@@ -54,7 +54,7 @@
invocation.installComponent(TRANSFORMER_CATEGORY + this.type, parameters);
// signal that we did some processing
- return InvocationResult.PROCESSED;
+ return InvocationResult.CONTINUE;
}
/**
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/WhenNode.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/WhenNode.java?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/WhenNode.java (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/node/WhenNode.java Mon Jul 21 09:24:36 2008
@@ -19,37 +19,31 @@
package org.apache.cocoon.corona.sitemap.node;
import org.apache.cocoon.corona.sitemap.Invocation;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
@Node(name = "when")
public class WhenNode extends MatchNode {
- private final Log logger = LogFactory.getLog(this.getClass());
-
@Override
public InvocationResult invoke(Invocation invocation) {
this.checkParent();
- return super.invoke(invocation);
+ InvocationResult result = super.invoke(invocation);
+ if (invocation.hasCompletePipeline()) {
+ return InvocationResult.COMPLETED;
+ }
+
+ if (result.isContinued()) {
+ return InvocationResult.BREAK;
+ }
+ return result;
}
protected void checkParent() {
- if (this.getParent() instanceof MatchNode) {
- MatchNode parentMatchNode = (MatchNode) this.getParent();
+ if (this.getParent() instanceof SelectNode) {
+ SelectNode parentMatchNode = (SelectNode) this.getParent();
this.setValue(parentMatchNode.getValue());
-
- if (parentMatchNode.isInMatchingMode()) {
- String message = "The parent node used one of the matching attributes (pattern, regexp, ends-with, etc.). "
- + "Hence it's not allowed to set when/otherwise nodes as children.";
- this.logger.error(message);
- throw new RuntimeException(message);
- }
} else {
- String message = "The parent node has to be a match node.";
- this.logger.error(message);
- throw new RuntimeException(message);
+ throw new RuntimeException("The parent node has to be a select node.");
}
}
-
-}
+}
\ No newline at end of file
Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/resources/corona-sitemap-1.0.xsd
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/resources/corona-sitemap-1.0.xsd?rev=678458&r1=678457&r2=678458&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/resources/corona-sitemap-1.0.xsd (original)
+++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/resources/corona-sitemap-1.0.xsd Mon Jul 21 09:24:36 2008
@@ -91,6 +91,7 @@
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="match" />
+ <xsd:element ref="select" />
<xsd:element ref="generate" />
<xsd:element ref="transform" />
<xsd:element ref="serialize" />
@@ -114,19 +115,61 @@
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
+ <xsd:group ref="pipeline-content" />
+ </xsd:sequence>
+ <xsd:attribute name="value" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The test value. The default is the request URI.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attributeGroup ref="expression-attrs" />
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="select">
+ <xsd:annotation>
+ <xsd:documentation>
+ The select element is used in conjunction with when and otherwise. This allows for
+ testing against multipe values.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="parameter" minOccurs="0" maxOccurs="unbounded" />
<xsd:element ref="when" minOccurs="0" maxOccurs="unbounded" />
<xsd:element ref="otherwise" minOccurs="0" maxOccurs="1" />
- <xsd:group ref="pipeline-content" />
</xsd:sequence>
<xsd:attribute name="value" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>The test value. The default is the request URI.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="when">
+ <xsd:annotation>
+ <xsd:documentation>
+ Each of the when elements is tested. When the first one matches, the sitemap execution continues within the
+ element.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="pipeline-content" />
+ </xsd:sequence>
<xsd:attributeGroup ref="expression-attrs" />
</xsd:complexType>
</xsd:element>
+ <xsd:element name="otherwise">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="pipeline-content" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
<xsd:attributeGroup name="expression-attrs">
<xsd:attribute name="pattern" type="xsd:string" use="optional">
<xsd:annotation>
@@ -145,7 +188,7 @@
<xsd:annotation>
<xsd:documentation>
A test string that can contain wildcards: * matches any character but not slashes ** matches any character
- including slahses
+ including slashes
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
@@ -278,29 +321,6 @@
</xsd:complexType>
</xsd:element>
- <xsd:element name="when">
- <xsd:annotation>
- <xsd:documentation>
- Each of the when elements is tested. When the first one matches, the sitemap execution continues within the
- element.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:group ref="pipeline-content" />
- </xsd:sequence>
- <xsd:attributeGroup ref="expression-attrs" />
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="otherwise">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:group ref="pipeline-content" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
<xsd:element name="act">
<xsd:annotation>
<xsd:documentation>