String (TransformerException exception) { final SourceLocator[] locators = new SourceLocator[]{ exception.getLocator() }; final String[] messages = new String[1]; findLocator(exception, locators, messages); final SourceLocator locator = locators[0]; if (locator != null) { final String systemId = locator.getSystemId(); if (systemId != null) { String s = systemId.replaceAll(" ", "%20") + ": "; final int lineNumber = locator.getLineNumber(); if (lineNumber != -1) { s += "line " + lineNumber + ": "; final int columnNumber = locator.getColumnNumber(); if (columnNumber != -1) { s += "column " + columnNumber + ": "; } } return s + (messages[0] != null ? messages[0] : exception.getMessage()); } } return messages[0] != null ? messages[0] : exception.getMessage(); }