You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2007/07/26 23:16:27 UTC
svn commit: r559981 -
/webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
Author: dims
Date: Thu Jul 26 14:16:26 2007
New Revision: 559981
URL: http://svn.apache.org/viewvc?view=rev&rev=559981
Log:
Better diagnostics when prettifying fails
Modified:
webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
Modified: webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java?view=diff&rev=559981&r1=559980&r2=559981
==============================================================================
--- webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java (original)
+++ webservices/axis2/branches/java/1_3/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java Thu Jul 26 14:16:26 2007
@@ -27,6 +27,8 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
@@ -49,7 +51,7 @@
*
* @param file
*/
- public static void prettify(File file) {
+ public static void prettify(final File file) {
try {
InputStream inputStream = new ByteArrayInputStream(IOUtils.getStreamAsByteArray(new FileInputStream(file)));
@@ -61,6 +63,19 @@
TransformerFactory tf = TransformerFactory.newInstance();
Templates templates = tf.newTemplates(stylesheetSource);
Transformer transformer = templates.newTransformer();
+ transformer.setErrorListener(new ErrorListener(){
+ public void warning(TransformerException exception) throws TransformerException {
+ log.warn("Exception occurred while trying to pretty print file " + file, exception);
+ }
+
+ public void error(TransformerException exception) throws TransformerException {
+ log.error("Exception occurred while trying to pretty print file " + file, exception);
+ }
+
+ public void fatalError(TransformerException exception) throws TransformerException {
+ log.error("Exception occurred while trying to pretty print file " + file, exception);
+ }
+ });
transformer.transform(xmlSource, new StreamResult(outputStream));
inputStream.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org