Java Code Examples for javax.xml.parsers.ParserConfigurationException#getMessage()
The following examples show how to use
javax.xml.parsers.ParserConfigurationException#getMessage() .
These examples are extracted from open source projects.
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 Project: APICloud-Studio File: XMLMemento.java License: GNU General Public License v3.0 | 6 votes |
/** * Returns a root memento for writing a document. * * @param type * the element node type to create on the document * @return the root memento for writing a document */ public static XMLMemento createWriteRoot(String type) { Document document; try { document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element element = document.createElement(type); document.appendChild(element); return new XMLMemento(document, element); } catch (ParserConfigurationException e) { // throw new Error(e); throw new Error(e.getMessage()); } }
Example 2
Source Project: openjdk-8 File: JAXPParser.java License: GNU General Public License v2.0 | 6 votes |
public void parse( InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { try { SAXParser saxParser = allowFileAccess(factory.newSAXParser(), false); XMLReader reader = new XMLReaderEx(saxParser.getXMLReader()); reader.setContentHandler(handler); if(errorHandler!=null) reader.setErrorHandler(errorHandler); if(entityResolver!=null) reader.setEntityResolver(entityResolver); reader.parse(source); } catch( ParserConfigurationException e ) { // in practice this won't happen SAXParseException spe = new SAXParseException(e.getMessage(),null,e); errorHandler.fatalError(spe); throw spe; } }
Example 3
Source Project: hottub File: JAXPParser.java License: GNU General Public License v2.0 | 6 votes |
public void parse( InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { try { SAXParser saxParser = allowFileAccess(factory.newSAXParser(), false); XMLReader reader = new XMLReaderEx(saxParser.getXMLReader()); reader.setContentHandler(handler); if(errorHandler!=null) reader.setErrorHandler(errorHandler); if(entityResolver!=null) reader.setEntityResolver(entityResolver); reader.parse(source); } catch( ParserConfigurationException e ) { // in practice this won't happen SAXParseException spe = new SAXParseException(e.getMessage(),null,e); errorHandler.fatalError(spe); throw spe; } }
Example 4
Source Project: oopsla15-artifact File: XMLReader.java License: Eclipse Public License 1.0 | 6 votes |
public IValue read(IValueFactory factory, TypeStore store, Type type, Reader stream) throws FactTypeUseException, IOException { this.vf = factory; this.ts = store; try { Document doc = domFactory.newDocumentBuilder().parse(new InputSource(stream)); return parse(doc.getDocumentElement(), type); } catch (SAXException se) { throw new IOException("Parsing of value failed because XML was invalid: " + se.getMessage()); } catch (ParserConfigurationException pce) { throw new IOException("Parsing of value failed because XML configuration is wrong: " + pce.getMessage()); } catch (DOMException de) { throw new IOException("Parsing of value failed because of a XML document failure: " + de.getMessage()); } catch (NumberFormatException nfe) { throw new FactParseError("Expected a number, got something different", nfe); } }
Example 5
Source Project: myexcel File: SaxExcelReader.java License: Apache License 2.0 | 6 votes |
/** * Parses and shows the content of one sheet * using the specified styles and shared-strings tables. * * @param strings The table of strings that may be referenced by cells in the sheet * @param sheetInputStream The stream to read the sheet-data from. * @throws java.io.IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. * @throws SAXException if parsing the XML data fails. */ private void processSheet( SharedStrings strings, XSSFSheetXMLHandler.SheetContentsHandler sheetHandler, InputStream sheetInputStream) throws IOException, SAXException { DataFormatter formatter = new DataFormatter(); InputSource sheetSource = new InputSource(sheetInputStream); try { XMLReader sheetParser = SAXHelper.newXMLReader(); ContentHandler handler = new XSSFSheetXMLHandler( null, null, strings, sheetHandler, formatter, false); sheetParser.setContentHandler(handler); sheetParser.parse(sheetSource); } catch (ParserConfigurationException e) { throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage()); } }
Example 6
Source Project: netbeans File: DDProvider.java License: Apache License 2.0 | 6 votes |
private DDParse parseDD (InputSource is) throws SAXException, IOException { DDProvider.ErrorHandler errorHandler = new DDProvider.ErrorHandler(); DocumentBuilder parser=null; try { DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); parser = fact.newDocumentBuilder(); } catch (ParserConfigurationException ex) { throw new SAXException(ex.getMessage()); } parser.setErrorHandler(errorHandler); parser.setEntityResolver(DDResolver.getInstance()); Document d = parser.parse(is); SAXParseException error = errorHandler.getError(); return new DDParse(d, error); }
Example 7
Source Project: openjdk-8-source File: JAXPParser.java License: GNU General Public License v2.0 | 6 votes |
public void parse( InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { try { SAXParser saxParser = allowFileAccess(factory.newSAXParser(), false); XMLReader reader = new XMLReaderEx(saxParser.getXMLReader()); reader.setContentHandler(handler); if(errorHandler!=null) reader.setErrorHandler(errorHandler); if(entityResolver!=null) reader.setEntityResolver(entityResolver); reader.parse(source); } catch( ParserConfigurationException e ) { // in practice this won't happen SAXParseException spe = new SAXParseException(e.getMessage(),null,e); errorHandler.fatalError(spe); throw spe; } }
Example 8
Source Project: openjdk-jdk9 File: JAXPParser.java License: GNU General Public License v2.0 | 6 votes |
public void parse( InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { try { SAXParser saxParser = allowFileAccess(factory.newSAXParser(), false); XMLReader reader = new XMLReaderEx(saxParser.getXMLReader()); reader.setContentHandler(handler); if(errorHandler!=null) reader.setErrorHandler(errorHandler); if(entityResolver!=null) reader.setEntityResolver(entityResolver); reader.parse(source); } catch( ParserConfigurationException e ) { // in practice this won't happen SAXParseException spe = new SAXParseException(e.getMessage(),null,e); errorHandler.fatalError(spe); throw spe; } }
Example 9
Source Project: simpletask-android File: SardineUtil.java License: GNU General Public License v3.0 | 5 votes |
/** * @return New XML document from the default document builder factory. */ private static Document createDocument() { DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e.getMessage(), e); } return builder.newDocument(); }
Example 10
Source Project: hottub File: DSchemaBuilderImpl.java License: GNU General Public License v2.0 | 5 votes |
public DSchemaBuilderImpl() { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); this.dom = dbf.newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { // impossible throw new InternalError(e.getMessage()); } }
Example 11
Source Project: TencentKona-8 File: DOMForest.java License: GNU General Public License v2.0 | 5 votes |
/** * Parses the given document and add it to the DOM forest. * * @return null if there was a parse error. otherwise non-null. */ private @NotNull Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException, IOException{ Document dom = documentBuilder.newDocument(); systemId = normalizeSystemId(systemId); // put into the map before growing a tree, to // prevent recursive reference from causing infinite loop. core.put(systemId, dom); dom.setDocumentURI(systemId); if (root) rootDocuments.add(systemId); try { XMLReader reader = createReader(dom); InputStream is = null; if(inputSource.getByteStream() == null){ inputSource = entityResolver.resolveEntity(null, systemId); } reader.parse(inputSource); Element doc = dom.getDocumentElement(); if (doc == null) { return null; } NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema"); for (int i = 0; i < schemas.getLength(); i++) { inlinedSchemaElements.add((Element) schemas.item(i)); } } catch (ParserConfigurationException e) { errorReceiver.error(e); throw new SAXException(e.getMessage()); } resolvedCache.put(systemId, dom.getDocumentURI()); return dom; }
Example 12
Source Project: tutorial-soap-spring-boot-cxf File: XmlUtils.java License: MIT License | 5 votes |
private static DocumentBuilder setUpDocumentBuilder() throws XmlUtilsException { DocumentBuilder documentBuilder = null; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException parserConfigurationException) { throw new XmlUtilsException("Problem beim Erstellen des DocumentBuilders: " + parserConfigurationException.getMessage(), parserConfigurationException); } return documentBuilder; }
Example 13
Source Project: zserio File: XmlAstWriter.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Constructor. * * @throws ZserioEmitException Throws in case of XML parser configuration error. */ public XmlAstWriter() throws ZserioEmitException { try { // create XML doc builder final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); xmlDoc = docBuilder.newDocument(); } catch (ParserConfigurationException excpt) { throw new ZserioEmitException(excpt.getMessage()); } }
Example 14
Source Project: openjdk-8-source File: DOMForest.java License: GNU General Public License v2.0 | 5 votes |
/** * Parses the given document and add it to the DOM forest. * * @return null if there was a parse error. otherwise non-null. */ private @NotNull Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException, IOException{ Document dom = documentBuilder.newDocument(); systemId = normalizeSystemId(systemId); // put into the map before growing a tree, to // prevent recursive reference from causing infinite loop. core.put(systemId, dom); dom.setDocumentURI(systemId); if (root) rootDocuments.add(systemId); try { XMLReader reader = createReader(dom); InputStream is = null; if(inputSource.getByteStream() == null){ inputSource = entityResolver.resolveEntity(null, systemId); } reader.parse(inputSource); Element doc = dom.getDocumentElement(); if (doc == null) { return null; } NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema"); for (int i = 0; i < schemas.getLength(); i++) { inlinedSchemaElements.add((Element) schemas.item(i)); } } catch (ParserConfigurationException e) { errorReceiver.error(e); throw new SAXException(e.getMessage()); } resolvedCache.put(systemId, dom.getDocumentURI()); return dom; }
Example 15
Source Project: openjdk-8-source File: DSchemaBuilderImpl.java License: GNU General Public License v2.0 | 5 votes |
public DSchemaBuilderImpl() { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); this.dom = dbf.newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { // impossible throw new InternalError(e.getMessage()); } }
Example 16
Source Project: wES File: DomXmlUtils.java License: MIT License | 5 votes |
/** * 初始化一个空Document对象返回。 * * @return a Document */ public static Document newXMLDocument() { try { return newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException(e.getMessage()); } }
Example 17
Source Project: tutorial-soap-spring-boot-cxf File: XmlUtils.java License: MIT License | 5 votes |
private static DocumentBuilder setUpDocumentBuilder() throws XmlUtilsException { DocumentBuilder documentBuilder = null; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException parserConfigurationException) { throw new XmlUtilsException("Problem beim Erstellen des DocumentBuilders: " + parserConfigurationException.getMessage(), parserConfigurationException); } return documentBuilder; }
Example 18
Source Project: sardine-android File: SardineUtil.java License: Apache License 2.0 | 5 votes |
/** * @return New XML document from the default document builder factory. */ private static Document createDocument() { DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e.getMessage(), e); } return builder.newDocument(); }
Example 19
Source Project: oodt File: XMLQuery.java License: Apache License 2.0 | 5 votes |
/** Create an XML DOM document using the query DTD. * * @return An XML DOM document, with a query root element, using the query DTD. */ public static Document createDocument() { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setCoalescing(true); factory.setNamespaceAware(false); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.newDocument(); } catch (ParserConfigurationException ex) { throw new IllegalStateException("Unexpected ParserConfigurationException: " + ex.getMessage()); } }
Example 20
Source Project: openccg File: GrammarDoc.java License: GNU Lesser General Public License v2.1 | 4 votes |
SourceGrammar loadSourceGrammar() throws GrammarDocException { SourceGrammar sourceGrammar = new SourceGrammar(srcDir); try { SourceGrammarFile grammar = loadGrammarFile( SourceGrammarFileType.GRAMMAR, new File(srcDir, SourceGrammarFileType.GRAMMAR.fileName + ".xml")); sourceGrammar.addSourceGrammarFile(SourceGrammarFileType.GRAMMAR, grammar); //TODO make these StreamSource instead File gd = grammar.sourceFile; for(SourceGrammarFileType fileType : SourceGrammarFileType.values()) { if(!fileType.equals(SourceGrammarFileType.GRAMMAR)) { // already DocumentBuilder db = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); Document doc = db.parse(gd); NodeList fileEls = doc.getElementsByTagName( fileType.name().toLowerCase()); if(fileEls.getLength() == 0) { if(fileType.isRequired()) { throw new GrammarDocException( "file type required but missing: " + fileType); } } else { sourceGrammar.addSourceGrammarFile(fileType, loadGrammarFile(fileType, new File(srcDir, fileType.fileName + ".xml"))); } } } } catch(ParserConfigurationException pce) { throw new GrammarDocException("parser configuration problem: " + pce.getMessage(), pce); } catch(SAXException se) { throw new GrammarDocException("problem parsing source files: " + se.getMessage(), se); } catch(IOException io) { throw new GrammarDocException("io problem with source files: " + io.getMessage(), io); } return sourceGrammar; }