List of usage examples for org.xml.sax SAXParseException getMessage
public String getMessage()
From source file:TryDOM.java
public void warning(SAXParseException spe) { System.out.println("Warning at line " + spe.getLineNumber()); System.out.println(spe.getMessage()); }//w w w . j av a 2 s. c om
From source file:DOMCopy.java
private void show(String type, SAXParseException e) { System.out.println(type + ": " + e.getMessage()); System.out.println("Line " + e.getLineNumber() + " Column " + e.getColumnNumber()); System.out.println("System ID: " + e.getSystemId()); }//w w w .j a v a 2 s.co m
From source file:MainClass.java
public void fatalError(SAXParseException spe) throws SAXException { System.out.println("Fatal error at line " + spe.getLineNumber()); System.out.println(spe.getMessage()); throw spe;//from w ww .j a v a 2 s. c o m }
From source file:SAXDemo.java
/** This method is called when errors occur */ public void error(SAXParseException exception) { System.err.println("ERROR: line " + exception.getLineNumber() + ": " + exception.getMessage()); }
From source file:SAXDemo.java
/** This method is called when warnings occur */ public void warning(SAXParseException exception) { System.err.println("WARNING: line " + exception.getLineNumber() + ": " + exception.getMessage()); }
From source file:TryDOM.java
public void fatalError(SAXParseException spe) throws SAXException { System.out.println("Fatal error at line " + spe.getLineNumber()); System.out.println(spe.getMessage()); throw spe; }//from w ww. j a v a 2 s . c om
From source file:WebAppConfig.java
/** * This constructor method is passed an XML file. It uses the JAXP API to * obtain a DOM parser, and to parse the file into a DOM Document object, * which is used by the remaining methods of the class. *///w ww. j a v a 2 s . c o m public WebAppConfig(File configfile) throws IOException, SAXException, ParserConfigurationException { // Get a JAXP parser factory object javax.xml.parsers.DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); // Tell the factory what kind of parser we want dbf.setValidating(false); // Use the factory to get a JAXP parser object javax.xml.parsers.DocumentBuilder parser = dbf.newDocumentBuilder(); // Tell the parser how to handle errors. Note that in the JAXP API, // DOM parsers rely on the SAX API for error handling parser.setErrorHandler(new org.xml.sax.ErrorHandler() { public void warning(SAXParseException e) { System.err.println("WARNING: " + e.getMessage()); } public void error(SAXParseException e) { System.err.println("ERROR: " + e.getMessage()); } public void fatalError(SAXParseException e) throws SAXException { System.err.println("FATAL: " + e.getMessage()); throw e; // re-throw the error } }); // Finally, use the JAXP parser to parse the file. This call returns // A Document object. Now that we have this object, the rest of this // class uses the DOM API to work with it; JAXP is no longer required. document = parser.parse(configfile); }
From source file:com.consol.citrus.samples.bookstore.validation.XmlSchemaValidatingChannelInterceptor.java
/** * Validates the payload of the message/*from ww w . j ava2 s . c om*/ * * @param message * @param channel */ public void validateSchema(Message<?> message, MessageChannel channel) { try { SAXParseException[] exceptions = xmlValidator.validate(converter.convertToSource(message.getPayload())); if (exceptions.length > 0) { StringBuilder msg = new StringBuilder("Invalid XML message on channel "); if (channel != null) { msg.append(channel.toString()); } else { msg.append("<unknown>"); } msg.append(":\n"); for (SAXParseException e : exceptions) { msg.append("\t").append(e.getMessage()); msg.append(" (line=").append(e.getLineNumber()); msg.append(", col=").append(e.getColumnNumber()).append(")\n"); } log.warn("XSD schema validation failed: ", msg.toString()); throw new XmlSchemaValidationException(message, exceptions[0]); } } catch (IOException ioE) { throw new MessagingException("Exception applying schema validation", ioE); } }
From source file:SAXDemo.java
/** This method is called when non-recoverable errors occur. */ public void fatalError(SAXParseException exception) throws SAXException { System.err.println("FATAL: line " + exception.getLineNumber() + ": " + exception.getMessage()); throw (exception); }
From source file:com.moviejukebox.reader.MovieNFOReader.java
/** * Take either a file or a String and process the NFO * * @param nfoFile// w w w . j a v a2s .c om * @param nfoString * @param movie * @param nfoFilename * @return */ private static boolean convertNfoToDoc(File nfoFile, final String nfoString, Movie movie, final String nfoFilename) { Document xmlDoc; String filename; if (StringUtils.isBlank(nfoFilename) && nfoFile != null) { filename = nfoFile.getName(); } else { filename = nfoFilename; } try { if (nfoFile == null) { // Assume we're using the string xmlDoc = DOMHelper.getDocFromString(nfoString); } else { xmlDoc = DOMHelper.getDocFromFile(nfoFile); } } catch (SAXParseException ex) { LOG.debug(ERROR_FIXIT, filename, ex.getMessage()); return Boolean.FALSE; } catch (MalformedURLException ex) { LOG.debug(ERROR_FIXIT, filename, ex.getMessage()); return Boolean.FALSE; } catch (IOException ex) { LOG.debug(ERROR_FIXIT, filename, ex.getMessage()); return Boolean.FALSE; } catch (ParserConfigurationException | SAXException ex) { LOG.debug(ERROR_FIXIT, filename, ex.getMessage()); return Boolean.FALSE; } return parseXmlNfo(xmlDoc, movie, filename); }