Browse Source

Include information about the XSLT processor found (if any) in -diagnostics. PR 46612.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@738872 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
499deaa377
2 changed files with 67 additions and 3 deletions
  1. +4
    -0
      WHATSNEW
  2. +63
    -3
      src/main/org/apache/tools/ant/Diagnostics.java

+ 4
- 0
WHATSNEW View File

@@ -664,6 +664,10 @@ Other changes:
using gcj.
Bugzilla Issue 46617.

* ant -diagnostics now outputs information about the default XSLT
processor.
Bugzilla Issue 46612.

Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================



+ 63
- 3
src/main/org/apache/tools/ant/Diagnostics.java View File

@@ -27,6 +27,8 @@ import org.xml.sax.XMLReader;

import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import java.io.File;
import java.io.FilenameFilter;
import java.io.PrintStream;
@@ -172,7 +174,7 @@ public final class Diagnostics {
* what parser are we using.
* @return the classname of the parser
*/
private static String getXmlParserName() {
private static String getXMLParserName() {
SAXParser saxParser = getSAXParser();
if (saxParser == null) {
return "Could not create an XML Parser";
@@ -182,6 +184,20 @@ public final class Diagnostics {
return saxParserName;
}

/**
* what parser are we using.
* @return the classname of the parser
*/
private static String getXSLTProcessorName() {
Transformer transformer = getXSLTProcessor();
if (transformer == null) {
return "Could not create an XSLT Processor";
}
// check to what is in the classname
String processorName = transformer.getClass().getName();
return processorName;
}

/**
* Create a JAXP SAXParser
* @return parser or null for trouble
@@ -201,11 +217,29 @@ public final class Diagnostics {
return saxParser;
}

/**
* Create a JAXP XSLT Transformer
* @return parser or null for trouble
*/
private static Transformer getXSLTProcessor() {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
if (transformerFactory == null) {
return null;
}
Transformer transformer = null;
try {
transformer = transformerFactory.newTransformer();
} catch (Exception e) {
// ignore
ignoreThrowable(e);
}
return transformer;
}

/**
* get the location of the parser
* @return path or null for trouble in tracking it down
*/

private static String getXMLParserLocation() {
SAXParser saxParser = getSAXParser();
if (saxParser == null) {
@@ -237,6 +271,19 @@ public final class Diagnostics {
}
}

/**
* get the location of the parser
* @return path or null for trouble in tracking it down
*/
private static String getXSLTProcessorLocation() {
Transformer transformer = getXSLTProcessor();
if (transformer == null) {
return null;
}
String location = getClassLocation(transformer.getClass());
return location;
}

/**
* ignore exceptions. This is to allow future
* implementations to log at a verbose level
@@ -305,6 +352,9 @@ public final class Diagnostics {
header(out, "XML Parser information");
doReportParserInfo(out);

header(out, "XSLT Processor information");
doReportXSLTProcessorInfo(out);

header(out, "System properties");
doReportSystemProperties(out);

@@ -494,13 +544,23 @@ public final class Diagnostics {
* @param out
*/
private static void doReportParserInfo(PrintStream out) {
String parserName = getXmlParserName();
String parserName = getXMLParserName();
String parserLocation = getXMLParserLocation();
printParserInfo(out, "XML Parser", parserName, parserLocation);
printParserInfo(out, "Namespace-aware parser", getNamespaceParserName(),
getNamespaceParserLocation());
}

/**
* tell the user about the XSLT processor
* @param out
*/
private static void doReportXSLTProcessorInfo(PrintStream out) {
String processorName = getXSLTProcessorName();
String processorLocation = getXSLTProcessorLocation();
printParserInfo(out, "XSLT Processor", processorName, processorLocation);
}

private static void printParserInfo(PrintStream out, String parserType, String parserName,
String parserLocation) {
if (parserName == null) {


Loading…
Cancel
Save