forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r570993 - in /forrest/trunk/whiteboard/forrest2/core/src: conf/defaultForrestContext.xml examples/helloWorld/src/forrestContext.xml examples/helloWorld/src/locationmap.xml main/org/apache/forrest/core/plugin/XSLTOutputPlugin.java
Date Thu, 30 Aug 2007 00:15:32 GMT
Author: rgardler
Date: Wed Aug 29 17:15:32 2007
New Revision: 570993

URL: http://svn.apache.org/viewvc?rev=570993&view=rev
Log:
Use the locationmap to resolve output XSLTs

Modified:
    forrest/trunk/whiteboard/forrest2/core/src/conf/defaultForrestContext.xml
    forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/forrestContext.xml
    forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/locationmap.xml
    forrest/trunk/whiteboard/forrest2/core/src/main/org/apache/forrest/core/plugin/XSLTOutputPlugin.java

Modified: forrest/trunk/whiteboard/forrest2/core/src/conf/defaultForrestContext.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/conf/defaultForrestContext.xml?rev=570993&r1=570992&r2=570993&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/conf/defaultForrestContext.xml (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/conf/defaultForrestContext.xml Wed Aug 29 17:15:32
2007
@@ -32,6 +32,6 @@
 		class="org.apache.forrest.core.plugin.XSLTOutputPlugin">
     <property name="pattern" value="html" />
     <property name="xsltPath"
-			value="/xdocs/samples/xslt/internal-to-html.xsl" />
+			value="internal-to-html.xsl" />
   </bean>
 </beans>

Modified: forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/forrestContext.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/forrestContext.xml?rev=570993&r1=570992&r2=570993&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/forrestContext.xml
(original)
+++ forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/forrestContext.xml
Wed Aug 29 17:15:32 2007
@@ -32,6 +32,6 @@
 		class="org.apache.forrest.core.plugin.XSLTOutputPlugin">
     <property name="pattern" value="html" />
     <property name="xsltPath"
-			value="/xdocs/samples/xslt/internal-to-html.xsl" />
+			value="internal-to-html.xsl" />
   </bean>
 </beans>

Modified: forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/locationmap.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/locationmap.xml?rev=570993&r1=570992&r2=570993&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/locationmap.xml (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/examples/helloWorld/src/locationmap.xml Wed
Aug 29 17:15:32 2007
@@ -16,13 +16,16 @@
   limitations under the License.
 -->
 <locationmap>
-  <location regexp="(.*).xhtml2">
+  <location regexp="(.*)\.xhtml2">
     <source href="classpath:/xdocs/$(1).xhtml2"/>
   </location>
-  <location regexp="(.*)/(.*).html">
+  <location regexp="(.*)/(.*)\.html">
     <source href="classpath:/xdocs/$(2).xhtml2"/>
   </location>
-  <location regexp="(.*).html">
+  <location regexp="(.*)\.html">
     <source href="classpath:/xdocs/$(1).xhtml2"/>
+  </location>
+  <location regexp="(.*)\.xsl">
+    <source href="classpath:/xdocs/samples/xslt/$(1).xsl"/>
   </location>
 </locationmap>

Modified: forrest/trunk/whiteboard/forrest2/core/src/main/org/apache/forrest/core/plugin/XSLTOutputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/main/org/apache/forrest/core/plugin/XSLTOutputPlugin.java?rev=570993&r1=570992&r2=570993&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/main/org/apache/forrest/core/plugin/XSLTOutputPlugin.java
(original)
+++ forrest/trunk/whiteboard/forrest2/core/src/main/org/apache/forrest/core/plugin/XSLTOutputPlugin.java
Wed Aug 29 17:15:32 2007
@@ -33,6 +33,8 @@
 import org.apache.forrest.core.Controller;
 import org.apache.forrest.core.document.DefaultOutputDocument;
 import org.apache.forrest.core.document.IDocument;
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.exception.ProcessingException;
 import org.apache.log4j.Logger;
 
 /**
@@ -59,17 +61,16 @@
 		final TransformerFactory tFactory = TransformerFactory.newInstance();
 		log.debug("Processing document with output stylesheet from " + this.getXsltPath());
 		try {
-			final String xsltURL = this.getClass().getResource(
-					this.getXsltPath()).toExternalForm();
-			final File xslt = new File(new URI(xsltURL));
+            final AbstractSourceDocument xsltDoc = controller.getSourceDocuments(new URI(this.getXsltPath()));
 			Transformer transformer;
-			transformer = tFactory.newTransformer(new StreamSource(xslt));
-			final StringReader reader = new StringReader(doc
-					.getContentAsString());
+			transformer = tFactory.newTransformer(new StreamSource(new StringReader(xsltDoc.getContentAsString())));
+            log.debug("Got transformer ");
+			final StringReader reader = new StringReader(doc.getContentAsString());
 			final StreamSource in = new StreamSource(reader);
 			final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
 			final StreamResult out = new StreamResult(outStream);
 			transformer.transform(in, out);
+            log.debug("Transformed");
 			return new DefaultOutputDocument(doc.getRequestURI(), outStream.toString());
 		} catch (final TransformerConfigurationException e) {
 			// TODO Auto-generated catch block
@@ -83,7 +84,11 @@
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 			return null;
-		}
+		} catch (final ProcessingException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            return null;
+        }
 	}
 
 	public String getXsltPath() {



Mime
View raw message