Java Code Examples for org.xml.sax.SAXParseException#getMessage()
The following examples show how to use
org.xml.sax.SAXParseException#getMessage() .
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: ModuleReader.java From ontopia with Apache License 2.0 | 6 votes |
@Override public Map read(InputStream source) throws IOException, SAXException { logger.debug("Start to read in module."); parser = getXMLParser(); ModuleContentHandler handler = new ModuleContentHandler(); handler.register(parser); InputSource inpsrc = new InputSource(); if (encrypted) inpsrc.setByteStream(new EncryptedInputStream(source)); else inpsrc.setByteStream(source); try { parser.parse(inpsrc); } catch (SAXParseException e) { throw new SAXException(e.getLineNumber() + ":" + e.getColumnNumber() + ": " + e.getMessage()); } return handler.getFunctions(); }
Example 2
Source File: ErrorHandlerWrapper.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** Creates an XMLParseException from a SAXParseException. */ protected static XMLParseException createXMLParseException(SAXParseException exception) { final String fPublicId = exception.getPublicId(); final String fExpandedSystemId = exception.getSystemId(); final int fLineNumber = exception.getLineNumber(); final int fColumnNumber = exception.getColumnNumber(); XMLLocator location = new XMLLocator() { public String getPublicId() { return fPublicId; } public String getExpandedSystemId() { return fExpandedSystemId; } public String getBaseSystemId() { return null; } public String getLiteralSystemId() { return null; } public int getColumnNumber() { return fColumnNumber; } public int getLineNumber() { return fLineNumber; } public int getCharacterOffset() { return -1; } public String getEncoding() { return null; } public String getXMLVersion() { return null; } }; return new XMLParseException(location, exception.getMessage(),exception); }
Example 3
Source File: ErrorHandlerWrapper.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** Creates an XMLParseException from a SAXParseException. */ protected static XMLParseException createXMLParseException(SAXParseException exception) { final String fPublicId = exception.getPublicId(); final String fExpandedSystemId = exception.getSystemId(); final int fLineNumber = exception.getLineNumber(); final int fColumnNumber = exception.getColumnNumber(); XMLLocator location = new XMLLocator() { public String getPublicId() { return fPublicId; } public String getExpandedSystemId() { return fExpandedSystemId; } public String getBaseSystemId() { return null; } public String getLiteralSystemId() { return null; } public int getColumnNumber() { return fColumnNumber; } public int getLineNumber() { return fLineNumber; } public int getCharacterOffset() { return -1; } public String getEncoding() { return null; } public String getXMLVersion() { return null; } }; return new XMLParseException(location, exception.getMessage(),exception); }
Example 4
Source File: DefaultValidationErrorHandler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void error(SAXParseException e) throws SAXException { if (errorCount >= ERROR_COUNT_LIMIT) { // Ignore all errors after reaching the limit return; } else if (errorCount == 0) { // Print a warning before the first error System.err.println(SAXMessageFormatter.formatMessage(locale, "errorHandlerNotSet", new Object [] {errorCount})); } String systemId = e.getSystemId(); if (systemId == null) { systemId = "null"; } String message = "Error: URI=" + systemId + " Line=" + e.getLineNumber() + ": " + e.getMessage(); System.err.println(message); errorCount++; }
Example 5
Source File: ErrorHandlerWrapper.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** Creates an XMLParseException from a SAXParseException. */ protected static XMLParseException createXMLParseException(SAXParseException exception) { final String fPublicId = exception.getPublicId(); final String fExpandedSystemId = exception.getSystemId(); final int fLineNumber = exception.getLineNumber(); final int fColumnNumber = exception.getColumnNumber(); XMLLocator location = new XMLLocator() { public String getPublicId() { return fPublicId; } public String getExpandedSystemId() { return fExpandedSystemId; } public String getBaseSystemId() { return null; } public String getLiteralSystemId() { return null; } public int getColumnNumber() { return fColumnNumber; } public int getLineNumber() { return fLineNumber; } public int getCharacterOffset() { return -1; } public String getEncoding() { return null; } public String getXMLVersion() { return null; } }; return new XMLParseException(location, exception.getMessage(),exception); }
Example 6
Source File: DefaultValidationErrorHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void error(SAXParseException e) throws SAXException { if (errorCount >= ERROR_COUNT_LIMIT) { // Ignore all errors after reaching the limit return; } else if (errorCount == 0) { // Print a warning before the first error System.err.println(SAXMessageFormatter.formatMessage(locale, "errorHandlerNotSet", new Object [] {errorCount})); } String systemId = e.getSystemId(); if (systemId == null) { systemId = "null"; } String message = "Error: URI=" + systemId + " Line=" + e.getLineNumber() + ": " + e.getMessage(); System.err.println(message); errorCount++; }
Example 7
Source File: ErrorDetail.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Translates <code>SAXParseException</code>. * * @param e * exception to translate */ private void translate( SAXParseException e ) { type = DesignFileException.DESIGN_EXCEPTION_INVALID_XML; exceptionName = e.getClass( ).getName( ); message = e.getMessage( ); description.append( " ( line = " ); //$NON-NLS-1$ description.append( e.getLineNumber( ) ); description.append( ") " ); //$NON-NLS-1$ description.append( e.getClass( ).getName( ) ); description.append( " (" ); //$NON-NLS-1$ description.append( "message : " ); //$NON-NLS-1$ description.append( e.getMessage( ) ); description.append( ")" ); //$NON-NLS-1$ lineNo = e.getLineNumber( ); if ( e.getCause( ) != null && e.getCause( ) instanceof RuntimeException ) { translateCausedException( e.getCause( ) ); } }
Example 8
Source File: Coordinator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void propagateEvent( int severity, SAXParseException saxException ) throws SAXException { ValidationEventImpl ve = new ValidationEventImpl( severity, saxException.getMessage(), getLocation() ); Exception e = saxException.getException(); if( e != null ) { ve.setLinkedException( e ); } else { ve.setLinkedException( saxException ); } // call the client's event handler. If it returns false, then bail-out // and terminate the unmarshal operation. boolean result = handleEvent( ve ); if( ! result ) { // bail-out of the parse with a SAX exception, but convert it into // an UnmarshalException back in in the AbstractUnmarshaller throw saxException; } }
Example 9
Source File: XmlErrorHandler.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Throws back the exception with the name of the XML file and the position * where the exception occurred. */ public void fatalError(SAXParseException exception) throws SAXException { throw new SAXParseException("Fatal error while parsing XML at line " + exception.getLineNumber() + " column " + exception.getColumnNumber() + ": " + exception.getMessage(), null); }
Example 10
Source File: TestUtil.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Throws back the exception with the name of the XML file and the position * where the exception occurred. */ @Override public void fatalError(SAXParseException exception) throws SAXException { throw new SAXParseException("Fatal error while parsing XML at line " + exception.getLineNumber() + " column " + exception.getColumnNumber() + ": " + exception.getMessage(), null); }
Example 11
Source File: PAPPolicyReader.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void warning(SAXParseException exception) throws SAXException { if (log.isWarnEnabled()) { String message = null; message = "Warning on line " + exception.getLineNumber() + ": " + exception.getMessage(); log.warn(message); } }
Example 12
Source File: SerializationTest.java From freecol with GNU General Public License v2.0 | 5 votes |
private void logParseFailure(SAXParseException e, String serialized) { int col = e.getColumnNumber(); String errMsg = e.getMessage() + "\nAt line=" + e.getLineNumber() + ", column=" + col + ":\n" + serialized.substring(Math.max(0, col - 100), Math.min(col + 100, serialized.length())); fail(errMsg); }
Example 13
Source File: SerializationTest.java From freecol with GNU General Public License v2.0 | 5 votes |
public void testValidation() throws Exception { Game game = ServerTestHelper.startServerGame(getTestMap(true)); Colony colony = getStandardColony(6); Player player = game.getPlayerByNationId("model.nation.dutch"); ServerTestHelper.newTurn(); ServerTestHelper.newTurn(); String serialized = null; try { Validator validator = buildValidator("schema/data/data-game.xsd"); serialized = game.serialize(); validator.validate(new StreamSource(new StringReader(serialized))); } catch (SAXParseException e) { int col = e.getColumnNumber(); String errMsg = e.getMessage() + "\nAt line=" + e.getLineNumber() + ", column=" + col + ":\n"; if (serialized != null) { errMsg += serialized.substring(Math.max(0, col - 100), Math.min(col + 100, serialized.length())); } fail(errMsg); } ServerTestHelper.stopServerGame(); }
Example 14
Source File: GetSemFromCat.java From EventCoreference with Apache License 2.0 | 5 votes |
public void parseFile(String filePath) { initPart(); fileName = new File(filePath).getName(); initSingletonId(filePath); String myerror = ""; try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(false); SAXParser parser = factory.newSAXParser(); InputSource inp = new InputSource(new FileReader(filePath)); parser.parse(inp, this); /* System.out.println("eventTermArrayList.size(); = " + eventTermArrayList.size()); System.out.println("timeLinks = " + timeLinks.size()); System.out.println("locationLinks = " + locationLinks.size()); System.out.println("plotLinks = " + plotLinks.size()); */ } catch (SAXParseException err) { myerror = "\n** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId(); myerror += "\n" + err.getMessage(); System.out.println("myerror = " + myerror); } catch (SAXException e) { Exception x = e; if (e.getException() != null) x = e.getException(); myerror += "\nSAXException --" + x.getMessage(); System.out.println("myerror = " + myerror); } catch (Exception eee) { eee.printStackTrace(); myerror += "\nException --" + eee.getMessage(); System.out.println("myerror = " + myerror); } //System.out.println("myerror = " + myerror); }
Example 15
Source File: PAPPolicyReader.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void warning(SAXParseException exception) throws SAXException { if (log.isWarnEnabled()) { String message = null; message = "Warning on line " + exception.getLineNumber() + ": " + exception.getMessage(); log.warn(message); } }
Example 16
Source File: ValidateXmlFilesRuleProvider.java From windup with Eclipse Public License 1.0 | 5 votes |
private void createSAXParseHint(GraphRewrite event, EvaluationContext context, XmlFileModel sourceFile, SAXParseException e) { int lineNumber = e.getLineNumber(); int column = e.getColumnNumber(); InlineHintService service = new InlineHintService(event.getGraphContext()); InlineHintModel hintModel = service.create(); hintModel.setRuleID(((Rule) context.get(Rule.class)).getId()); hintModel.setLineNumber(lineNumber); hintModel.setColumnNumber(column); // FIXME - Fake value as we don't get an actual length of the error from the parser hintModel.setLength(1); hintModel.setFile(sourceFile); hintModel.setEffort(1); IssueCategoryRegistry issueCategoryRegistry = IssueCategoryRegistry.instance(event.getRewriteContext()); hintModel.setIssueCategory(issueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.POTENTIAL)); if (e.getCause() instanceof InvalidXSDURLException) { String xsdUrl = ((InvalidXSDURLException) e.getCause()).getUrl(); hintModel.setTitle(XmlFileModel.XSD_URL_NOT_VALID); hintModel.setHint(xsdUrl + " is not a valid url."); } else { hintModel.setTitle(XmlFileModel.NOT_VALID_XML); String message = "XSD Validation failed due to:\n\n"; message += "\t" + e.getMessage(); message += System.lineSeparator()+System.lineSeparator(); hintModel.setHint(message); } sourceFile.setGenerateSourceReport(true); }
Example 17
Source File: ValidationMessageErrorHandler.java From jackrabbit-filevault with Apache License 2.0 | 4 votes |
private void print(@NotNull SAXParseException x, @NotNull ValidationMessageSeverity severity) { ValidationMessage message = new ValidationMessage(severity, x.getMessage(), Integer.valueOf(x.getLineNumber()), Integer.valueOf(x.getColumnNumber()), null); messages.add(message); }
Example 18
Source File: ErrorCollectorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
private String toString(SAXParseException exception) { return exception.getMessage(); }
Example 19
Source File: SourceGenerator.java From cxf with Apache License 2.0 | 4 votes |
public void error(SAXParseException ex) { throw new RuntimeException("Error compiling schema from WADL : " + ex.getMessage(), ex); }
Example 20
Source File: StructuredSyntaxHandler.java From groovy with Apache License 2.0 | 4 votes |
public void error(SAXParseException e) throws SAXException { throw new SAXException("Line: " + e.getLineNumber() + " message: " + e.getMessage()); }