[Yanel-commits] rev 21237 - in public/yanel/trunk/src/contributions/resources/calendar: . src/java/org/wyona/yanel/impl/resources xslt

michi at wyona.com michi at wyona.com
Fri Dec 29 01:13:40 CET 2006


Author: michi
Date: 2006-12-29 01:13:39 +0100 (Fri, 29 Dec 2006)
New Revision: 21237

Added:
   public/yanel/trunk/src/contributions/resources/calendar/xslt/
   public/yanel/trunk/src/contributions/resources/calendar/xslt/xml2ics.xsl
Modified:
   public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
Log:
XSLT fixed

Modified: public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java	2006-12-28 23:41:02 UTC (rev 21236)
+++ public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java	2006-12-29 00:13:39 UTC (rev 21237)
@@ -11,6 +11,13 @@
 
 import org.apache.log4j.Category;
 
+import java.io.File;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+
 /**
  *
  */
@@ -88,14 +95,22 @@
 	    view.setInputStream(new java.io.StringBufferInputStream(calendar.toString()));
             return view;
         } else {
-            String xslt = getRTD().getConfigFile().getParent();
+            String xslt = getRTD().getConfigFile().getParent() + File.separator + "xslt" + File.separator + "xml2ics.xsl";
             log.error("DEBUG: XSLT: " + xslt);
+            java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
+            try {
+                Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new File(xslt)));
+		transformer.transform(new StreamSource(new java.io.StringBufferInputStream(calendar.toString())), new StreamResult(out));
+            } catch(Exception e) {
+                log.error(e.getMessage(), e);
+            }
+
             //response.getOutputStream();
 
             View view = new View();
             //view.setResponse(false);
-	    view.setMimeType("application/xml");
-	    view.setInputStream(new java.io.StringBufferInputStream(calendar.toString()));
+	    view.setMimeType("text/plain");
+	    view.setInputStream(new java.io.ByteArrayInputStream(out.toByteArray()));
             return view;
         }
     }

Added: public/yanel/trunk/src/contributions/resources/calendar/xslt/xml2ics.xsl
===================================================================
--- public/yanel/trunk/src/contributions/resources/calendar/xslt/xml2ics.xsl	2006-12-28 23:41:02 UTC (rev 21236)
+++ public/yanel/trunk/src/contributions/resources/calendar/xslt/xml2ics.xsl	2006-12-29 00:13:39 UTC (rev 21237)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:cal="http://..."
+>
+
+<xsl:output method="text"/>
+
+<xsl:template match="/">
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN<xsl:apply-templates select="/calendar/cal:event"/>
+</xsl:template>
+
+<xsl:template match="cal:event">BEGIN:VEVENT
+CREATED:<xsl:value-of select="@created"/>
+UID:<xsl:value-of select="@uid"/>
+SUMMARY:<xsl:value-of select="cal:summary"/>
+LOCATION:<xsl:value-of select="cal:location"/>
+END:VEVENT
+</xsl:template>
+
+</xsl:stylesheet>




More information about the Yanel-commits mailing list