Author: bodewig Date: Thu Jan 29 14:55:31 2009 New Revision: 738872 URL: http://svn.apache.org/viewvc?rev=738872&view=rev Log: Include information about the XSLT processor found (if any) in -diagnostics. PR 46612.
Modified: ant/core/trunk/WHATSNEW ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=738872&r1=738871&r2=738872&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Thu Jan 29 14:55:31 2009 @@ -664,6 +664,10 @@ 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 ============================================= Modified: ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java?rev=738872&r1=738871&r2=738872&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java Thu Jan 29 14:55:31 2009 @@ -27,6 +27,8 @@ 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 @@ * 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"; @@ -183,6 +185,20 @@ } /** + * 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 */ @@ -202,10 +218,28 @@ } /** + * 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) { @@ -238,6 +272,19 @@ } /** + * 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 * @param thrown @@ -305,6 +352,9 @@ header(out, "XML Parser information"); doReportParserInfo(out); + header(out, "XSLT Processor information"); + doReportXSLTProcessorInfo(out); + header(out, "System properties"); doReportSystemProperties(out); @@ -494,13 +544,23 @@ * @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) {