Author: jvazquez
Date: Fri Jan 30 18:44:47 2009
New Revision: 739374
URL: http://svn.apache.org/viewvc?rev=739374&view=rev
Log: (empty)
Added:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-content.xslt
- copied, changed from r739346,
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test.xslt
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-html.xslt
Removed:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test.xslt
Modified:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/java/org/apache/sling/pipeline/prototype/PipelineServlet.java
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/pipelines.json
Modified:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/java/org/apache/sling/pipeline/prototype/PipelineServlet.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/pipeline/src/main/java/org/apache/sling/pipeline/prototype/PipelineServlet.java?rev=739374&r1=739373&r2=739374&view=diff
==============================================================================
---
incubator/sling/whiteboard/jvazquez/pipeline/src/main/java/org/apache/sling/pipeline/prototype/PipelineServlet.java
(original)
+++
incubator/sling/whiteboard/jvazquez/pipeline/src/main/java/org/apache/sling/pipeline/prototype/PipelineServlet.java
Fri Jan 30 18:44:47 2009
@@ -19,10 +19,15 @@
package org.apache.sling.pipeline.prototype;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
import org.apache.cocoon.pipeline.NonCachingPipeline;
import org.apache.cocoon.pipeline.Pipeline;
@@ -43,25 +48,61 @@
private static final long serialVersionUID = -5203204085782263204L;
+ private static final String PIPELINE_GENERATOR_PROP = "sling:generator";
+ private static final String PIPELINE_TRANSFORM_PROP = "sling:transform";
+
@Override
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException, IOException {
try {
+ // Supports only JCR resources
Node currentNode =
request.getResource().adaptTo(Node.class);
- String generatoUrl =
currentNode.getProperty("sling:generator").getValue().getString();
- String transformUrl =
currentNode.getProperty("sling:transform").getValue().getString();
- final String baseUrl = request.getScheme() + "://" +
request.getServerName() + ":" + request.getServerPort();
- URL srcUrl = new URL(baseUrl + generatoUrl);
- URL xslUrl = new URL(baseUrl + transformUrl);
+
+ // Generator and Transform properties
+ String generatorUrl = getGenUrl(currentNode);
+ String[] transformUrls = getTranUrls(currentNode);
+
+ // Builds the resources´ URLs
+ URL srcUrl = buildAbsUrl(request, generatorUrl);
+ URL[] xslUrls = new URL[transformUrls.length];
+ for (int i = 0; i < transformUrls.length; i++) {
+ xslUrls[i] = buildAbsUrl(request,
transformUrls[i]);
+ }
+
+ /** A simple non-caching Cocoon 3 pipeline */
Pipeline pipeline = new NonCachingPipeline();
+
+ // Generator
pipeline.addComponent(new FileGenerator(srcUrl));
- pipeline.addComponent(new XSLTTransformer(xslUrl));
+
+ // Transformers
+ for (int i = 0; i < xslUrls.length; i++) {
+ pipeline.addComponent(new
XSLTTransformer(xslUrls[i]));
+ }
+
+ // Serializer
pipeline.addComponent(new XMLSerializer());
+
+ // Pipeline set-up
pipeline.setup(response.getOutputStream());
+
+ // Pipeline execution
pipeline.execute();
+
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
+
+ private URL buildAbsUrl(ServletRequest request, String relUrl) throws
MalformedURLException {
+ return new URL(request.getScheme(), request.getServerName(),
request.getServerPort(), relUrl);
+ }
+
+ private String getGenUrl(Node node) throws ValueFormatException,
IllegalStateException, PathNotFoundException, RepositoryException {
+ return
node.getProperty(PIPELINE_GENERATOR_PROP).getValue().getString();
+ }
+
+ private String[] getTranUrls(Node node) throws ValueFormatException,
IllegalStateException, PathNotFoundException, RepositoryException {
+ return
node.getProperty(PIPELINE_TRANSFORM_PROP).getValue().getString().split(";");
+ }
}
Modified:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/pipelines.json
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/pipelines.json?rev=739374&r1=739373&r2=739374&view=diff
==============================================================================
---
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/pipelines.json
(original)
+++
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/pipelines.json
Fri Jan 30 18:44:47 2009
@@ -5,6 +5,6 @@
"title": "test_pipeline",
"sling:resourceType": "sling/pipeline",
"sling:generator": "/pipeline-sample/generator/test.xml",
- "sling:transform": "/pipeline-sample/transform/test.xslt"
+ "sling:transform":
"/pipeline-sample/transform/test-content.xslt;/pipeline-sample/transform/test-html.xslt"
}
}
\ No newline at end of file
Copied:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-content.xslt
(from r739346,
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test.xslt)
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-content.xslt?p2=incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-content.xslt&p1=incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test.xslt&r1=739346&r2=739374&rev=739374&view=diff
==============================================================================
---
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test.xslt
(original)
+++
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-content.xslt
Fri Jan 30 18:44:47 2009
@@ -16,13 +16,7 @@
limitations under the License.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
- <xsl:param name="myParam" />
-
- <xsl:template match="/">
- <p>
- <xsl:value-of select="$myParam" />
- </p>
+ <xsl:template match="/test">
+ <content>A little bit of content.</content>
</xsl:template>
-
</xsl:stylesheet>
Added:
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-html.xslt
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-html.xslt?rev=739374&view=auto
==============================================================================
---
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-html.xslt
(added)
+++
incubator/sling/whiteboard/jvazquez/pipeline/src/main/resources/SLING-INF/content/pipeline-sample/transform/test-html.xslt
Fri Jan 30 18:44:47 2009
@@ -0,0 +1,30 @@
+<?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 version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title>Just a pretty simple pipeline.</title>
+ </head>
+ <body>
+ The pipeline contents:
+ <xsl:value-of select="/content"/>
+ </body>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file