stylesheets are now searched in the classpath.
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / notification / MailNotifier.java
index 47c3edd59c19d3be265f25403a8062b667986be6..536135b28508288f65f42bf82f3ea3089584d66c 100644 (file)
@@ -4,7 +4,6 @@
  */
 package org.wamblee.crawler.kiss.notification;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Date;
@@ -16,8 +15,7 @@ import javax.xml.transform.TransformerException;
 import org.apache.commons.mail.EmailException;
 import org.apache.commons.mail.HtmlEmail;
 import org.dom4j.Element;
-import org.wamblee.io.FileResource;
-import org.wamblee.io.InputResource;
+import org.wamblee.xml.ClasspathUriResolver;
 import org.wamblee.xml.XSLT;
 
 /**
@@ -80,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);
@@ -113,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));
     }
 }