Java Code Examples for javax.xml.transform.TransformerException#getLocator()

The following examples show how to use javax.xml.transform.TransformerException#getLocator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MCRErrorListener.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
public static String getMyMessageAndLocation(TransformerException exception) {
    SourceLocator locator = exception.getLocator();
    StringBuilder msg = new StringBuilder();
    if (locator != null) {
        String systemID = locator.getSystemId();
        int line = locator.getLineNumber();
        int col = locator.getColumnNumber();
        if (systemID != null) {
            msg.append("SystemID: ");
            msg.append(systemID);
        }
        if (line != 0) {
            msg.append(" [");
            msg.append(line);
            if (col != 0) {
                msg.append(',');
                msg.append(col);
            }
            msg.append("]");
        }
    }
    msg.append(": ");
    msg.append(exception.getMessage());
    return msg.toString();
}
 
Example 2
Source File: MCRTemplatesCompiler.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
private static String buildErrorMessage(String resource, Exception cause) {
    StringBuilder msg = new StringBuilder("Error compiling XSL stylesheet ");
    msg.append(resource);

    if (cause instanceof TransformerException) {
        TransformerException tex = (TransformerException) cause;
        msg.append("\n").append(tex.getMessage());
        SourceLocator sl = tex.getLocator();
        if (sl != null) {
            msg.append(" (").append(sl.getSystemId()).append(") ");
            msg.append(" at line ").append(sl.getLineNumber());
            msg.append(" column ").append(sl.getColumnNumber());
        }
    }

    return msg.toString();
}
 
Example 3
Source File: CollectingErrorEventHandler.java    From validator with Apache License 2.0 5 votes vote down vote up
private static XMLSyntaxError createError(final XMLSyntaxErrorSeverity severity, final TransformerException exception) {
    final XMLSyntaxError e = createError(severity, exception.getMessage());
    if (exception.getLocator() != null) {
        e.setRowNumber(exception.getLocator().getLineNumber());
        e.setColumnNumber(exception.getLocator().getColumnNumber());
    }
    return e;
}
 
Example 4
Source File: FopTask.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void error(TransformerException exception) throws TransformerException
{
	SourceLocator locator = exception.getLocator();
	Logging.errorPrint("FOP Error " + exception.getMessage() + " at " + getLocation(locator));
	throw exception;
}
 
Example 5
Source File: FopTask.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void fatalError(TransformerException exception) throws TransformerException
{
	SourceLocator locator = exception.getLocator();
	Logging.errorPrint("FOP Fatal Error " + exception.getMessage() + " at " + getLocation(locator));
	throw exception;
}
 
Example 6
Source File: FopTask.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void error(TransformerException exception) throws TransformerException
{
	SourceLocator locator = exception.getLocator();
	Logging.errorPrint("FOP Error " + exception.getMessage() + " at " + getLocation(locator));
	throw exception;
}
 
Example 7
Source File: FopTask.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void fatalError(TransformerException exception) throws TransformerException
{
	SourceLocator locator = exception.getLocator();
	Logging.errorPrint("FOP Fatal Error " + exception.getMessage() + " at " + getLocation(locator));
	throw exception;
}
 
Example 8
Source File: FopTask.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void warning(TransformerException exception) throws TransformerException
{
	SourceLocator locator = exception.getLocator();
	Logging.log(Logging.WARNING, getLocation(locator) + exception.getMessage());
}
 
Example 9
Source File: FopTask.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void warning(TransformerException exception) throws TransformerException
{
	SourceLocator locator = exception.getLocator();
	Logging.log(Logging.WARNING, getLocation(locator) + exception.getMessage());
}