/** * This is protected rather than private to allow subclassing, * however, reimplementors should be aware that the default configuration * via {@link #create()} includes functionality that is not simply * included. The most important is to do with character encoding checking. * A common user error is to not have correct XML encoding, or to open * files with the wrong encodings on their reader. The {@link #setEncoding(String)} * method does what it can to try and detect these user errors, and is worth the effort. * Consider using {@link SAXParserWithEncodingCheck} * @param rdr */ protected RDFXMLParser(XMLReader rdr) { super(); saxParser = rdr; try { SAX2RDF.installHandlers(rdr, this); } catch (SAXException e) { throw new RuntimeException("Supposedly impossible:", e); } }
/** * This is protected rather than private to allow subclassing, * however, reimplementors should be aware that the default configuration * via {@link #create()} includes functionality that is not simply * included. The most important is to do with character encoding checking. * A common user error is to not have correct XML encoding, or to open * files with the wrong encodings on their reader. The {@link #setEncoding(String)} * method does what it can to try and detect these user errors, and is worth the effort. * Consider using {@link SAXParserWithEncodingCheck} * @param rdr */ protected RDFXMLParser(XMLReader rdr) { super(); saxParser = rdr; try { SAX2RDF.installHandlers(rdr, this); } catch (SAXException e) { throw new RuntimeException("Supposedly impossible:", e); } }
void loadXMLModel(Model m2, InputStream in, RDFEHArray eh2) throws SAXException, IOException { XMLReader saxParser = XMLReaderFactory.createXMLReader(); SAX2Model handler = SAX2Model.create(base, m2); SAX2RDF.installHandlers(saxParser, handler); handler.setErrorHandler(eh2); InputSource ins = new InputSource(in); ins.setSystemId(base); try { try { saxParser.parse(ins); } finally { handler.close(); } } catch (SAXParseException e) { // already reported, leave it be. } }
void loadXMLModel(Model m2, InputStream in, RDFEHArray eh2) throws SAXException, IOException { XMLReader saxParser = XMLReaderFactory.createXMLReader(); SAX2Model handler = SAX2Model.create(base, m2); SAX2RDF.installHandlers(saxParser, handler); handler.setErrorHandler(eh2); InputSource ins = new InputSource(in); ins.setSystemId(base); try { try { saxParser.parse(ins); } finally { handler.close(); } } catch (SAXParseException e) { // already reported, leave it be. } }
synchronized public void parse(InputSource input, String base) throws IOException, SAXException { // Make sure we have a sane state for // Namespace processing. initParse(base,""); SAX2RDF.installHandlers(saxParser, this); initEncodingChecks(input); try { saxParser.parse(input); } catch (UTFDataFormatException e) { generalError(ERR_UTF_ENCODING, e); } catch (IOException e) { generalError(ERR_GENERIC_IO, e); } catch (WrappedException wrapped) { wrapped.throwMe(); } catch (FatalParsingErrorException e) { // ignore this. } finally { afterParse(); } }
synchronized public void parse(InputSource input, String base) throws IOException, SAXException { // Make sure we have a sane state for // Namespace processing. initParse(base,""); SAX2RDF.installHandlers(saxParser, this); initEncodingChecks(input); try { saxParser.parse(input); } catch (UTFDataFormatException e) { generalError(ERR_UTF_ENCODING, e); } catch (IOException e) { generalError(ERR_GENERIC_IO, e); } catch (WrappedException wrapped) { wrapped.throwMe(); } catch (FatalParsingErrorException e) { // ignore this. } finally { afterParse(); } }
XMLReader saxParser = XMLReaderFactory.createXMLReader(); SAX2Model handler = SAX2Model.create("http://example.org/", m2, "fr"); SAX2RDF.installHandlers(saxParser, handler); handler.setErrorHandler(eh2);
XMLReader saxParser = XMLReaderFactory.createXMLReader(); SAX2Model handler = SAX2Model.create("http://example.org/", m2, "fr"); SAX2RDF.installHandlers(saxParser, handler); handler.setErrorHandler(eh2);