use of javax.xml.transform.TransformerException in project robovm by robovm.
the class XPathException method printStackTrace.
/**
* Print the the trace of methods from where the error
* originated. This will trace all nested exception
* objects, as well as this object.
* @param s The writer where the dump will be sent to.
*/
public void printStackTrace(java.io.PrintWriter s) {
if (s == null)
s = new java.io.PrintWriter(System.err);
try {
super.printStackTrace(s);
} catch (Exception e) {
}
boolean isJdk14OrHigher = false;
try {
Throwable.class.getMethod("getCause", (Class<?>) null);
isJdk14OrHigher = true;
} catch (NoSuchMethodException nsme) {
// do nothing
}
// The following code is only required when using jdk 1.3 or lower
if (!isJdk14OrHigher) {
Throwable exception = m_exception;
for (int i = 0; (i < 10) && (null != exception); i++) {
s.println("---------");
try {
exception.printStackTrace(s);
} catch (Exception e) {
s.println("Could not print stack trace...");
}
if (exception instanceof TransformerException) {
TransformerException se = (TransformerException) exception;
Throwable prev = exception;
exception = se.getException();
if (prev == exception) {
exception = null;
break;
}
} else {
exception = null;
}
}
}
}
use of javax.xml.transform.TransformerException in project robovm by robovm.
the class XPathException method printStackTrace.
/**
* Print the the trace of methods from where the error
* originated. This will trace all nested exception
* objects, as well as this object.
* @param s The stream where the dump will be sent to.
*/
public void printStackTrace(java.io.PrintStream s) {
if (s == null)
s = System.err;
try {
super.printStackTrace(s);
} catch (Exception e) {
}
Throwable exception = m_exception;
for (int i = 0; (i < 10) && (null != exception); i++) {
s.println("---------");
exception.printStackTrace(s);
if (exception instanceof TransformerException) {
TransformerException se = (TransformerException) exception;
Throwable prev = exception;
exception = se.getException();
if (prev == exception)
break;
} else {
exception = null;
}
}
}
use of javax.xml.transform.TransformerException in project robovm by robovm.
the class Expression method error.
/**
* Tell the user of an error, and probably throw an
* exception.
*
* @param xctxt The XPath runtime context.
* @param msg An error msgkey that corresponds to one of the constants found
* in {@link org.apache.xpath.res.XPATHErrorResources}, which is
* a key for a format string.
* @param args An array of arguments represented in the format string, which
* may be null.
*
* @throws TransformerException if the current ErrorListoner determines to
* throw an exception.
*
* @throws javax.xml.transform.TransformerException
*/
public void error(XPathContext xctxt, String msg, Object[] args) throws javax.xml.transform.TransformerException {
java.lang.String fmsg = XSLMessages.createXPATHMessage(msg, args);
if (null != xctxt) {
ErrorListener eh = xctxt.getErrorListener();
TransformerException te = new TransformerException(fmsg, this);
eh.fatalError(te);
}
}
use of javax.xml.transform.TransformerException in project robovm by robovm.
the class Expression method warn.
/**
* Warn the user of an problem.
*
* @param xctxt The XPath runtime context.
* @param msg An error msgkey that corresponds to one of the conststants found
* in {@link org.apache.xpath.res.XPATHErrorResources}, which is
* a key for a format string.
* @param args An array of arguments represented in the format string, which
* may be null.
*
* @throws TransformerException if the current ErrorListoner determines to
* throw an exception.
*
* @throws javax.xml.transform.TransformerException
*/
public void warn(XPathContext xctxt, String msg, Object[] args) throws javax.xml.transform.TransformerException {
java.lang.String fmsg = XSLMessages.createXPATHWarning(msg, args);
if (null != xctxt) {
ErrorListener eh = xctxt.getErrorListener();
// TO DO: Need to get stylesheet Locator from here.
eh.warning(new TransformerException(fmsg, xctxt.getSAXLocator()));
}
}
use of javax.xml.transform.TransformerException in project logger by orhanobut.
the class LoggerPrinter method xml.
@Override
public void xml(@Nullable String xml) {
if (Utils.isEmpty(xml)) {
d("Empty/Null xml content");
return;
}
try {
Source xmlInput = new StreamSource(new StringReader(xml));
StreamResult xmlOutput = new StreamResult(new StringWriter());
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(xmlInput, xmlOutput);
d(xmlOutput.getWriter().toString().replaceFirst(">", ">\n"));
} catch (TransformerException e) {
e("Invalid xml");
}
}
Aggregations