(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 18:38:40 +0000 (18:38 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 18:38:40 +0000 (18:38 +0000)
crawler/kiss/conf/kiss/programs.xml
crawler/kiss/conf/kiss/reportToText.xsl
crawler/kiss/conf/xml/report.xml
crawler/kiss/src/org/wamblee/crawler/kiss/KissCrawler.java
crawler/kiss/src/org/wamblee/crawler/kiss/MailNotifier.java
support/src/org/wamblee/xml/XSLT.java

index b99436fe92daca5f9166cb844c5697abe8527f66..fabc9fbcbec0c5cc095cce74f9a73e5c7a89eeb4 100644 (file)
   <program>
     <match>star.*gate</match>
   </program>
+
+  <program>
+    <match>six.*feet.*under</match>
+  </program>
   
   <program>
     <match>battlestar</match>
index bb5fba223aa1c68005136e20188c184dfe9a64a5..e46e4328bbe3e10b7575d51ee06373e9d7b4ce32 100644 (file)
   <xsl:template match="program">
     <xsl:call-template name="addProgramInfo"/>
   </xsl:template>
+  
   <xsl:template match="interesting">
     <xsl:call-template name="programTable"/>
     <xsl:apply-templates select="category"/>
   </xsl:template>
+  
   <xsl:template match="category">
     <xsl:text>Category: </xsl:text><xsl:value-of select="@name"/>
+    <xsl:value-of select="$newline"/>
+    <xsl:value-of select="$newline"/>
     <xsl:call-template name="programTable"/>
   </xsl:template>
+  
 </xsl:stylesheet>
index ab01bfc81f3eeb8f5ce886d76190dd931c4a77e6..391aea9464346081f3a6922641115d1fa152da49 100644 (file)
@@ -16,9 +16,7 @@
         <program>
             <name>Brainiac</name>
             <description>Humor</description>
-            <keywords>
-                science
-            </keywords>
+            <keywords>science</keywords>
             <channel>Discovery Channel</channel>
             <interval>
                 <begin>23:30</begin>
@@ -29,9 +27,7 @@
             <program>
                 <name>Andere tijden</name>
                 <description>Documentaire</description>
-                <keywords>
-                    
-                </keywords>
+                <keywords>docu</keywords>
                 <channel>Nederland 1</channel>
                 <interval>
                     <begin>23:30</begin>
index d96ef3e581605eec5d99e6656a9e96d2c10ad5ff..6e705315ef77e459bd7c74bb600d7871658ae1d8 100644 (file)
@@ -179,7 +179,6 @@ public class KissCrawler {
         } catch (NotificationException e) { 
             throw new RuntimeException(e);
         }
-        sendMail(executor);
     }
 
     /**
index f8566d51f9031f6f563b95a56f594e869ba6f7a0..c8074ced0ed6e8cfab88aceb217014f27ae542c7 100644 (file)
@@ -72,6 +72,8 @@ public class MailNotifier implements Notifier {
             String htmlText = transformReport( aReport, new FileResource(new File(_htmlXslt)) );
             String plainText = transformReport( aReport, new FileResource(new File(_textXslt)) );
             
+            
+            
             mail.setHtmlMsg(htmlText);
             mail.setTextMsg(plainText);
             
@@ -98,10 +100,6 @@ public class MailNotifier implements Notifier {
      */
     private String transformReport( Element aReport, InputResource aXslt ) throws IOException, TransformerException {
         String reportXmlText = aReport.asXML();
-        Document document = new XSLT().transform(reportXmlText.getBytes(), aXslt);
-        ByteArrayOutputStream transformed = new ByteArrayOutputStream();
-        XMLSerializer serializer = new XMLSerializer(transformed, new OutputFormat());
-        serializer.serialize(document);
-        return transformed.toString();
+        return new XSLT().textTransform(reportXmlText.getBytes(), aXslt);
     }
 }
index e7c5fc7643c76c046e06c69c401f67a435df5618..ae603976b6de126e8a1ac22a3880fb76d1599f7c 100644 (file)
@@ -17,6 +17,7 @@
 package org.wamblee.xml;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -28,6 +29,7 @@ import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Document;
@@ -88,6 +90,21 @@ public class XSLT {
         transform(source, result, aXslt);
         return (Document) result.getNode();
     }
+    
+    /**
+     * Transforms a document to a text output. This supports XSLT transformations
+     * that result in text documents. 
+     * @param aDocument Document to transform.
+     * @param aXslt XSL transformation. 
+     * @return Transformed document.  
+     */
+    public String textTransform(byte[] aDocument, InputResource aXslt) throws IOException, TransformerException { 
+        Source source = new StreamSource(new ByteArrayInputStream(aDocument));
+        ByteArrayOutputStream os = new ByteArrayOutputStream(); 
+        StreamResult result = new StreamResult(os);
+        transform(source, result, aXslt);
+        return new String(os.toByteArray());
+    }
 
     /**
      * Transforms a document using XSLT.