private OWLRDFConsumer consumeTriples(RepositoryConnection connection, org.openrdf.model.URI axiomId) throws OWLOntologyCreationException, RepositoryException, IOException, RDFHandlerException, SAXException { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = manager.createOntology(); OWLRDFConsumer consumer = new OWLRDFConsumer(ontology, anonymousNodeChecker, new OWLOntologyLoaderConfiguration()); consumer.setOntologyFormat(new TrackingOntologyFormat()); RepositoryResult<Statement> triples = connection.getStatements(null, null, null, false, axiomId);
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { final RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); RDFParser parser = new RDFParser() { @Override public void startPrefixMapping(@Nullable String prefix, @Nullable String uri) throws SAXException { super.startPrefixMapping(prefix, uri); if (prefix != null && uri != null) { format.setPrefix(prefix, uri); } } }; OWLRDFConsumer consumer = new OWLRDFConsumer(ontology, configuration); consumer.setIRIProvider(parser); consumer.setOntologyFormat(format); InputSource is = getInputSource(documentSource, configuration); parser.parse(is, consumer); return format; } catch (RDFParserException | SAXException | OWLOntologyInputSourceException | IOException e) { throw new OWLRDFXMLParserException(e); } } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { final RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); RDFParser parser = new RDFParser() { @Override public void startPrefixMapping(@Nullable String prefix, @Nullable String uri) throws SAXException { super.startPrefixMapping(prefix, uri); if (prefix != null && uri != null) { format.setPrefix(prefix, uri); } } }; OWLRDFConsumer consumer = new OWLRDFConsumer(ontology, configuration); consumer.setIRIProvider(parser); consumer.setOntologyFormat(format); InputSource is = getInputSource(documentSource, configuration); parser.parse(is, consumer); return format; } catch (RDFParserException | SAXException | OWLOntologyInputSourceException | IOException e) { throw new OWLRDFXMLParserException(e); } } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { final RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); RDFParser parser = new RDFParser() { @Override public void startPrefixMapping(@Nullable String prefix, @Nullable String uri) throws SAXException { super.startPrefixMapping(prefix, uri); if (prefix != null && uri != null) { format.setPrefix(prefix, uri); } } }; OWLRDFConsumer consumer = new OWLRDFConsumer(ontology, configuration); consumer.setIRIProvider(parser); consumer.setOntologyFormat(format); InputSource is = getInputSource(documentSource, configuration); parser.parse(is, consumer); return format; } catch (RDFParserException | SAXException | OWLOntologyInputSourceException | IOException e) { throw new OWLRDFXMLParserException(e); } } }
@Override public OWLDocumentFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology, OWLOntologyLoaderConfiguration configuration) { try { final RDFXMLDocumentFormat format = new RDFXMLDocumentFormat(); RDFParser parser = new RDFParser() { @Override public void startPrefixMapping(@Nullable String prefix, @Nullable String uri) throws SAXException { super.startPrefixMapping(prefix, uri); if (prefix != null && uri != null) { format.setPrefix(prefix, uri); } } }; OWLRDFConsumer consumer = new OWLRDFConsumer(ontology, configuration); consumer.setIRIProvider(parser); consumer.setOntologyFormat(format); InputSource is = getInputSource(documentSource, configuration); parser.parse(is, consumer); return format; } catch (RDFParserException | SAXException | OWLOntologyInputSourceException | IOException e) { throw new OWLRDFXMLParserException(e); } } }