use of javax.xml.transform.SourceLocator in project robovm by robovm.
the class StylesheetHandler method getBaseIdentifier.
/**
* Return the base identifier.
*
* @return The base identifier of the current stylesheet.
*/
public String getBaseIdentifier() {
// Try to get the baseIdentifier from the baseIdentifier's stack,
// which may not be the same thing as the value found in the
// SourceLocators stack.
String base = (String) (m_baseIdentifiers.isEmpty() ? null : m_baseIdentifiers.peek());
// Otherwise try the stylesheet.
if (null == base) {
SourceLocator locator = getLocator();
base = (null == locator) ? "" : locator.getSystemId();
}
return base;
}
use of javax.xml.transform.SourceLocator in project robovm by robovm.
the class DefaultErrorHandler method ensureLocationSet.
public static void ensureLocationSet(TransformerException exception) {
// SourceLocator locator = exception.getLocator();
SourceLocator locator = null;
Throwable cause = exception;
// Try to find the locator closest to the cause.
do {
if (cause instanceof SAXParseException) {
locator = new SAXSourceLocator((SAXParseException) cause);
} else if (cause instanceof TransformerException) {
SourceLocator causeLocator = ((TransformerException) cause).getLocator();
if (null != causeLocator)
locator = causeLocator;
}
if (cause instanceof TransformerException)
cause = ((TransformerException) cause).getCause();
else if (cause instanceof SAXException)
cause = ((SAXException) cause).getException();
else
cause = null;
} while (null != cause);
exception.setLocator(locator);
}
use of javax.xml.transform.SourceLocator in project robovm by robovm.
the class DefaultErrorHandler method printLocation.
public static void printLocation(PrintWriter pw, Throwable exception) {
SourceLocator locator = null;
Throwable cause = exception;
// Try to find the locator closest to the cause.
do {
if (cause instanceof SAXParseException) {
locator = new SAXSourceLocator((SAXParseException) cause);
} else if (cause instanceof TransformerException) {
SourceLocator causeLocator = ((TransformerException) cause).getLocator();
if (null != causeLocator)
locator = causeLocator;
}
if (cause instanceof TransformerException)
cause = ((TransformerException) cause).getCause();
else if (cause instanceof WrappedRuntimeException)
cause = ((WrappedRuntimeException) cause).getException();
else if (cause instanceof SAXException)
cause = ((SAXException) cause).getException();
else
cause = null;
} while (null != cause);
if (null != locator) {
// getErrorWriter().println("Parser fatal error: "+exception.getMessage());
String id = (null != locator.getPublicId()) ? locator.getPublicId() : (null != locator.getSystemId()) ? locator.getSystemId() : //"SystemId Unknown";
XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null);
pw.print(id + "; " + XMLMessages.createXMLMessage("line", null) + locator.getLineNumber() + "; " + XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber() + "; ");
} else
pw.print("(" + XMLMessages.createXMLMessage(XMLErrorResources.ER_LOCATION_UNKNOWN, null) + ")");
}
use of javax.xml.transform.SourceLocator in project robovm by robovm.
the class XPath method error.
/**
* Tell the user of an error, and probably throw an
* exception.
*
* @param xctxt The XPath runtime context.
* @param sourceNode Not used.
* @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.
*/
public void error(XPathContext xctxt, int sourceNode, String msg, Object[] args) throws javax.xml.transform.TransformerException {
String fmsg = XSLMessages.createXPATHMessage(msg, args);
ErrorListener ehandler = xctxt.getErrorListener();
if (null != ehandler) {
ehandler.fatalError(new TransformerException(fmsg, (SAXSourceLocator) xctxt.getSAXLocator()));
} else {
SourceLocator slocator = xctxt.getSAXLocator();
System.out.println(fmsg + "; file " + slocator.getSystemId() + "; line " + slocator.getLineNumber() + "; column " + slocator.getColumnNumber());
}
}
Aggregations