/** * Parses RDF from given input source. * * @param source specifies where RDF comes from * @param inputConsumer receives notifications about RDF parsing events * @throws SAXException SAXException * @throws IOException IOException */ public void parse(@Nonnull InputSource source, @Nonnull RDFConsumer inputConsumer) throws SAXException, IOException { InputSource s = checkNotNull(source, "source cannot be null"); checkNotNull(inputConsumer, "consumer cannot be null"); String systemID = s.getSystemId(); try { if (systemID != null) { baseIRI = IRI.create(new URI(source.getSystemId())); } else { throw new SAXException( "Supplied InputSource object myst have systemId property set, which is needed for IRI resolution."); } consumer = inputConsumer; inputConsumer.startModel(getBaseIRI()); DeclHandler handler = new DeclHandler() { public void internalEntityDecl(String name, String value) { consumer.addPrefix(name, value); } public void externalEntityDecl(String name, String publicId, String systemId) {} public void elementDecl(String name, String model) {} public void attributeDecl( String eName, String aName, String type, String mode, String value) {} }; SAXParsers.initParserWithOWLAPIStandards(handler).parse(source, this); inputConsumer.endModel(); } catch (URISyntaxException e) { throw new SAXException("Invalid SystemID '" + systemID + "'of the supplied input source.", e); } finally { state = null; states.clear(); baseIRIs.clear(); } }