From: erik Date: Tue, 21 Mar 2006 18:38:40 +0000 (+0000) Subject: (no commit message) X-Git-Tag: BEFORE_MAVEN_MIGRATION~174 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=3ccd0d8b45abdf872dae59a59d87ccf8ea0fc4aa;p=utils --- diff --git a/crawler/kiss/conf/kiss/programs.xml b/crawler/kiss/conf/kiss/programs.xml index b99436fe..fabc9fbc 100644 --- a/crawler/kiss/conf/kiss/programs.xml +++ b/crawler/kiss/conf/kiss/programs.xml @@ -42,6 +42,10 @@ star.*gate + + + six.*feet.*under + battlestar diff --git a/crawler/kiss/conf/kiss/reportToText.xsl b/crawler/kiss/conf/kiss/reportToText.xsl index bb5fba22..e46e4328 100644 --- a/crawler/kiss/conf/kiss/reportToText.xsl +++ b/crawler/kiss/conf/kiss/reportToText.xsl @@ -85,12 +85,17 @@ + + Category: + + + diff --git a/crawler/kiss/conf/xml/report.xml b/crawler/kiss/conf/xml/report.xml index ab01bfc8..391aea94 100644 --- a/crawler/kiss/conf/xml/report.xml +++ b/crawler/kiss/conf/xml/report.xml @@ -16,9 +16,7 @@ Brainiac Humor - - science - + science Discovery Channel 23:30 @@ -29,9 +27,7 @@ Andere tijden Documentaire - - - + docu Nederland 1 23:30 diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/KissCrawler.java b/crawler/kiss/src/org/wamblee/crawler/kiss/KissCrawler.java index d96ef3e5..6e705315 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/KissCrawler.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/KissCrawler.java @@ -179,7 +179,6 @@ public class KissCrawler { } catch (NotificationException e) { throw new RuntimeException(e); } - sendMail(executor); } /** diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/MailNotifier.java b/crawler/kiss/src/org/wamblee/crawler/kiss/MailNotifier.java index f8566d51..c8074ced 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/MailNotifier.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/MailNotifier.java @@ -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); } } diff --git a/support/src/org/wamblee/xml/XSLT.java b/support/src/org/wamblee/xml/XSLT.java index e7c5fc76..ae603976 100644 --- a/support/src/org/wamblee/xml/XSLT.java +++ b/support/src/org/wamblee/xml/XSLT.java @@ -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.