From 62e7dc5ae23d71d2d924dd8393e2ceb8a40bc9a7 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sat, 23 Mar 2002 19:52:30 +0000 Subject: [PATCH] style sheet control; you can point to anyhting or turn it off completely. nb, can we make this a logger and not a listener? git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271988 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/listeners.html | 15 ++++++++++++++- src/main/org/apache/tools/ant/XmlLogger.java | 10 ++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/manual/listeners.html b/docs/manual/listeners.html index aba880df1..e65398efb 100644 --- a/docs/manual/listeners.html +++ b/docs/manual/listeners.html @@ -269,7 +269,20 @@ corresponding Log4j level.

XmlLogger

Writes all build information out to an XML file named log.xml, or the value -of the XmlLogger.file property if present.

+of the XmlLogger.file property if present. +

+By default the xml file creates +a reference to an xslt file "log.xsl" in the current directory; look in +ANT_HOME/etc for one of these. You can set the property +ant.XmlLogger.stylesheet.uri to provide a uri to a style sheet. +this can be a relative or absolute file path, or an http URL. +If you set the property to the empty string, "", no XSLT transform +is declared at all. + + + + +

diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java index 62d4f2071..8a46a90fe 100644 --- a/src/main/org/apache/tools/ant/XmlLogger.java +++ b/src/main/org/apache/tools/ant/XmlLogger.java @@ -185,10 +185,14 @@ public class XmlLogger implements BuildListener { buildElement.element.appendChild(stacktrace); } - String outFilename = event.getProject().getProperty("XmlLogger.file"); + String outFilename = event.getProject().getProperty("XmlLogger.file"); if (outFilename == null) { outFilename = "log.xml"; } + String xslUri=event.getProject().getProperty("ant.XmlLogger.stylesheet.uri"); + if(xslUri==null) { + xslUri="log.xsl"; + } Writer out = null; try { // specify output in UTF8 otherwise accented characters will blow @@ -196,7 +200,9 @@ public class XmlLogger implements BuildListener { FileOutputStream fos = new FileOutputStream(outFilename); out = new OutputStreamWriter(fos, "UTF8"); out.write("\n"); - out.write("\n\n"); + if(xslUri.length()>0) { + out.write("\n\n"); + } (new DOMElementWriter()).write(buildElement.element, out, 0, "\t"); out.flush(); } catch(IOException exc) {