cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r705655 - in /cocoon/cocoon3/trunk: cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/ cocoon-sample/src/main/resources/COB-INF/ cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/
Date Fri, 17 Oct 2008 16:08:00 GMT
Author: reinhard
Date: Fri Oct 17 09:07:59 2008
New Revision: 705655

URL: http://svn.apache.org/viewvc?rev=705655&view=rev
Log:
COCOON3-2 Make the SchemaProcessorTransformer useable with sitemaps.

Modified:
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/SchemaProcessorTransformer.java
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/SchemaProcessorTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/SchemaProcessorTransformer.java?rev=705655&r1=705654&r2=705655&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/SchemaProcessorTransformer.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/SchemaProcessorTransformer.java
Fri Oct 17 09:07:59 2008
@@ -19,42 +19,48 @@
 package org.apache.cocoon.pipeline.component.sax;
 
 import java.net.URL;
+import java.util.Map;
 
 import javax.xml.XMLConstants;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.ValidatorHandler;
 
+import org.apache.cocoon.pipeline.SetupException;
 import org.apache.cocoon.pipeline.util.StringRepresentation;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.xml.sax.SAXException;
 
-/*
- * FIXME Doesn't work in sitemaps because of missing setConfiguration() and default constructor.
- */
 public final class SchemaProcessorTransformer extends AbstractTransformer {
 
     private final static SchemaFactory SCHEMA_FACTORY = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 
+    private final static String SOURCE = "source";
+
     private final Log logger = LogFactory.getLog(this.getClass());
 
     private Schema schema;
 
     private URL source;
 
+    public SchemaProcessorTransformer() {
+        super();
+    }
+
     public SchemaProcessorTransformer(URL source) {
-        if (source == null) {
-            throw new IllegalArgumentException("The parameter 'source' mustn't be null.");
-        }
+        super();
+        this.init(source);
+    }
 
-        try {
-            this.schema = SCHEMA_FACTORY.newSchema(source);
-        } catch (SAXException e) {
-            throw new RuntimeException("Could not initialize xschema source", e);
-        }
+    @Override
+    public void setConfiguration(Map<String, ? extends Object> configuration) {
+        this.init((URL) configuration.get(SOURCE));
+    }
 
-        this.source = source;
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "src=" + this.source);
     }
 
     @Override
@@ -66,8 +72,17 @@
         super.setXMLConsumer(new XMLConsumerAdapter(validatorHandler, xmlConsumer));
     }
 
-    @Override
-    public String toString() {
-        return StringRepresentation.buildString(this, "src=" + this.source);
+    private void init(URL source) {
+        if (source == null) {
+            throw new IllegalArgumentException("The parameter 'source' mustn't be null.");
+        }
+
+        try {
+            this.schema = SCHEMA_FACTORY.newSchema(source);
+        } catch (SAXException e) {
+            throw new SetupException("Could not initialize xschema source", e);
+        }
+
+        this.source = source;
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=705655&r1=705654&r2=705655&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Fri Oct 17
09:07:59 2008
@@ -32,6 +32,7 @@
     <li><a href="sax-pipeline/simple">SAX Pipeline</a>: Simplest possible
pipeline that has a generator, transformer and serializer.</li>
     <li><a href="sax-pipeline/simple-xhtml">SAX Pipeline</a>: Same as before
but creates XHTML as output format.</li>
     <li><a href="sax-pipeline/simple-xml">SAX Pipeline</a>: Same as before
but creates XML as output format.</li>
+    <li><a href="sax-pipeline/simple-xsd">SAX Pipeline</a>: Same as before
but creates XML as output format after validating the input.</li>
     <li><a href="sax-pipeline/unauthorized">Status code</a>: Set status
code '401' at pipeline.</li>
   </ul>
   <h2>Error handling</h2>

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=705655&r1=705654&r2=705655&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Fri Oct 17
09:07:59 2008
@@ -82,6 +82,11 @@
         </map:transform>
         <map:serialize type="xml" />
       </map:match>
+      <map:match equals="sax-pipeline/simple-xsd">
+        <map:generate src="sax-pipeline/simple.xml" />
+        <map:transform type="schema" src="sax-pipeline/simple.xsd" />
+        <map:serialize type="xml" />
+      </map:match>
       <map:match pattern="sax-pipeline/unauthorized">
         <map:generate src="sax-pipeline/unauthorized.xml" />
         <map:serialize type="xhtml" status-code="401" />

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml?rev=705655&r1=705654&r2=705655&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml
Fri Oct 17 09:07:59 2008
@@ -54,9 +54,11 @@
   <bean name="reader:file" class="org.apache.cocoon.pipeline.component.sax.FileReaderComponent"
scope="prototype" />
 
   <bean name="transformer:xslt" class="org.apache.cocoon.pipeline.component.sax.XSLTTransformer"
scope="prototype" />
-  
+
+  <bean name="transformer:schema" class="org.apache.cocoon.pipeline.component.sax.SchemaProcessorTransformer"
scope="prototype" />
+
   <bean name="transformer:include" class="org.apache.cocoon.pipeline.component.sax.IncludeTransformer"
scope="prototype" />
-  
+
   <bean name="transformer:cleaning" class="org.apache.cocoon.pipeline.component.sax.CleaningTransformer"
scope="prototype" />
 
 </beans>



Mime
View raw message