stylesheets are now searched in the classpath.
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / notification / MailNotifier.java
index 1c970a7151f11f1260583a873636299b3397ab5b..536135b28508288f65f42bf82f3ea3089584d66c 100644 (file)
@@ -4,8 +4,6 @@
  */
 package org.wamblee.crawler.kiss.notification;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Date;
@@ -16,12 +14,8 @@ import javax.xml.transform.TransformerException;
 
 import org.apache.commons.mail.EmailException;
 import org.apache.commons.mail.HtmlEmail;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
 import org.dom4j.Element;
-import org.w3c.dom.Document;
-import org.wamblee.io.FileResource;
-import org.wamblee.io.InputResource;
+import org.wamblee.xml.ClasspathUriResolver;
 import org.wamblee.xml.XSLT;
 
 /**
@@ -84,10 +78,8 @@ public class MailNotifier implements Notifier {
             mail.setSentDate(new Date());
             mail.setSubject(_subject);
 
-            String htmlText = transformReport(aReport, new FileResource(
-                    new File(_htmlXslt)));
-            String plainText = transformReport(aReport, new FileResource(
-                    new File(_textXslt)));
+            String htmlText = transformReport(aReport, _htmlXslt);
+            String plainText = transformReport(aReport, _textXslt);
 
             mail.setHtmlMsg(htmlText);
             mail.setTextMsg(plainText);
@@ -117,9 +109,10 @@ public class MailNotifier implements Notifier {
      * @throws TransformerException
      *             In case of problems transforming.
      */
-    private String transformReport(Element aReport, InputResource aXslt)
+    private String transformReport(Element aReport, String aXslt)
             throws IOException, TransformerException {
         String reportXmlText = aReport.asXML();
-        return new XSLT().textTransform(reportXmlText.getBytes(), aXslt);
+        XSLT xsltProcessor = new XSLT(new ClasspathUriResolver());
+        return xsltProcessor.textTransform(reportXmlText.getBytes(), xsltProcessor.resolve(aXslt));
     }
 }