Browse Source

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
master
Steve Loughran 23 years ago
parent
commit
62e7dc5ae2
2 changed files with 22 additions and 3 deletions
  1. +14
    -1
      docs/manual/listeners.html
  2. +8
    -2
      src/main/org/apache/tools/ant/XmlLogger.java

+ 14
- 1
docs/manual/listeners.html View File

@@ -269,7 +269,20 @@ corresponding Log4j level.</p>
<h3><a name="XmlLogger">XmlLogger</a></h3> <h3><a name="XmlLogger">XmlLogger</a></h3>


<p>Writes all build information out to an XML file named log.xml, or the value <p>Writes all build information out to an XML file named log.xml, or the value
of the XmlLogger.file property if present.</p>
of the <code>XmlLogger.file</code> property if present.
<p>
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
<code>ant.XmlLogger.stylesheet.uri</code> 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.



</p>


<blockquote> <blockquote>




+ 8
- 2
src/main/org/apache/tools/ant/XmlLogger.java View File

@@ -185,10 +185,14 @@ public class XmlLogger implements BuildListener {
buildElement.element.appendChild(stacktrace); buildElement.element.appendChild(stacktrace);
} }


String outFilename = event.getProject().getProperty("XmlLogger.file");
String outFilename = event.getProject().getProperty("XmlLogger.file");
if (outFilename == null) { if (outFilename == null) {
outFilename = "log.xml"; outFilename = "log.xml";
} }
String xslUri=event.getProject().getProperty("ant.XmlLogger.stylesheet.uri");
if(xslUri==null) {
xslUri="log.xsl";
}
Writer out = null; Writer out = null;
try { try {
// specify output in UTF8 otherwise accented characters will blow // specify output in UTF8 otherwise accented characters will blow
@@ -196,7 +200,9 @@ public class XmlLogger implements BuildListener {
FileOutputStream fos = new FileOutputStream(outFilename); FileOutputStream fos = new FileOutputStream(outFilename);
out = new OutputStreamWriter(fos, "UTF8"); out = new OutputStreamWriter(fos, "UTF8");
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
out.write("<?xml-stylesheet type=\"text/xsl\" href=\"log.xsl\"?>\n\n");
if(xslUri.length()>0) {
out.write("<?xml-stylesheet type=\"text/xsl\" href=\""+xslUri+"\"?>\n\n");
}
(new DOMElementWriter()).write(buildElement.element, out, 0, "\t"); (new DOMElementWriter()).write(buildElement.element, out, 0, "\t");
out.flush(); out.flush();
} catch(IOException exc) { } catch(IOException exc) {


Loading…
Cancel
Save