/** * Choose the parser based on the {@link RDFFormat} specified to the * constructor. * * @return The parser. */ final protected RDFParser getParser(final RDFFormat rdfFormat) { final RDFParser parser = Rio.createParser(rdfFormat, valueFactory); parser.setValueFactory(valueFactory); return parser; }
/** Parse from input stream, no base uri specified. */ public Document parseRDF(InputStream inputStream, RDFFormat format, String baseuri) throws RDFParseException, RDFHandlerException, IOException { RDFParser rdfParser = Rio.createParser(format); return parseRDF(inputStream, rdfParser, baseuri); }
public VerbatimRdfizer(final RDFFormat format, final RDFParser.DatatypeHandling datatypeHandling) { this.format = format; parser = Rio.createParser(format); parser.setDatatypeHandling(datatypeHandling); }
public VerbatimRdfizer(final RDFFormat format, final RDFParser.DatatypeHandling datatypeHandling) { this.format = format; parser = Rio.createParser(format); parser.setDatatypeHandling(datatypeHandling); }
/** Parse from input stream, no base uri specified. */ public Document parseRDF(InputStream inputStream, RDFFormat format, String baseuri) throws RDFParseException, RDFHandlerException, IOException { RDFParser rdfParser = Rio.createParser(format); return parseRDF(inputStream, rdfParser, baseuri); }
/** * Choose the parser based on the {@link RDFFormat} specified to the * constructor. * * @return The parser. */ final protected RDFParser getParser(final RDFFormat rdfFormat) { final RDFParser parser = Rio.createParser(rdfFormat, valueFactory); parser.setValueFactory(valueFactory); return parser; }
public Document parseRDF(String filename) throws RDFParseException, RDFHandlerException, IOException, JAXBException { // System.out.println("**** Parse "+filename); File file = new File(filename); URL documentURL = file.toURI().toURL(); InputStream inputStream = documentURL.openStream(); RDFParser rdfParser = Rio.createParser(Rio.getParserFormatForFileName(file.getName())); String streamName = documentURL.toString(); return parseRDF(inputStream, rdfParser, streamName); }
public Document parseRDF(String filename) throws RDFParseException, RDFHandlerException, IOException, JAXBException { // System.out.println("**** Parse "+filename); File file = new File(filename); URL documentURL = file.toURI().toURL(); InputStream inputStream = documentURL.openStream(); RDFParser rdfParser = Rio.createParser(Rio.getParserFormatForFileName(file.getName())); String streamName = documentURL.toString(); return parseRDF(inputStream, rdfParser, streamName); }
public RepositoryConnection(SesameAbstractRepo rep, QuestDBConnection connection) throws OBDAException { this.repository = rep; this.questConn = connection; this.isOpen = true; this.isActive = false; this.autoCommit = connection.getAutoCommit(); this.rdfParser = Rio.createParser(RDFFormat.RDFXML, this.repository.getValueFactory()); }
/** * Constructor to start parsing R2RML mappings from file. * @param file - the File object */ public R2RMLManager(File file) throws Exception { myModel = new LinkedHashModel(); RDFParser parser = Rio.createParser(RDFFormat.TURTLE); InputStream in = new FileInputStream(file); URL documentUrl = new URL("file://" + file); StatementCollector collector = new StatementCollector(myModel); parser.setRDFHandler(collector); parser.parse(in, documentUrl.toString()); r2rmlParser = new R2RMLParser(); }
/** * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to * create RDF model objects. */ public GeonamesParser() { super(); lineParser = Rio.createParser(RDFFormat.RDFXML); lineParser.setParseErrorListener(this); lineParser.setParserConfig(getParserConfig()); }
/** * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to * create RDF model objects. */ public GeonamesParser() { super(); lineParser = Rio.createParser(RDFFormat.RDFXML); lineParser.setParseErrorListener(this); lineParser.setParserConfig(getParserConfig()); }
public static void loadDataset(IDataset dataset, InputStream rdf, RDFFormat format,String baseURI,int batchSize) throws Exception { DatasetStatementCollection sc = new DatasetStatementCollection(batchSize,dataset); RDFParser parser = Rio.createParser(format); parser.setRDFHandler(sc); parser.setValueFactory(Constants.valueFactory); parser.parse(rdf,baseURI); }
/** * Creates a new RDFParserBase that will use the supplied ValueFactory to * create RDF model objects. * * @param valueFactory A ValueFactory. */ public GeonamesParser(ValueFactory valueFactory) { super(valueFactory); lineParser = Rio.createParser(RDFFormat.RDFXML); lineParser.setParseErrorListener(this); lineParser.setValueFactory(valueFactory); lineParser.setParserConfig(getParserConfig()); }
public static void parse(final InputStream is, final RDFSink sink, final String baseUri, final RDFFormat format) throws RippleException { RDFParser parser = Rio.createParser(format); parser.setRDFHandler(new SesameInputAdapter(sink)); try { parser.parse(is, baseUri); } catch (IOException | RDFParseException | RDFHandlerException e) { throw new RippleException(e); } } }
@Override protected void addAxiomStatements() throws SailException { RDFParser parser = Rio.createParser(RDFFormat.TURTLE); if (axiomClosureNeeded) { loadAxiomStatements(parser, "/schema/spin-full.ttl"); } else { loadAxiomStatements(parser, "/schema/sp.ttl"); loadAxiomStatements(parser, "/schema/spin.ttl"); loadAxiomStatements(parser, "/schema/spl.spin.ttl"); } }
/** * Create a parser for the given format, turning off some of the stricter configuration settings so we * can handle more messy data without errors. * @param format * @return */ private RDFParser createParser(RDFFormat format) { RDFParser parser = Rio.createParser(format); parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES); parser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES); parser.getParserConfig().addNonFatalError(BasicParserSettings.NORMALIZE_DATATYPE_VALUES); return parser; }
private long parseRdfContent(final InputStream content, final RDFFormat format) throws RDFParseException, IOException, RDFHandlerException { RDFParser parser = Rio.createParser(format); parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false); ParsedRDFHandler parsedRDFHandler = new ParsedRDFHandler(); parsedRDFHandler.clear(); parser.setRDFHandler(parsedRDFHandler); parser.parse(content, BASE_IRI); return parsedRDFHandler.getCount(); }
@Test public void testParserFactoryRegisteredAlternate() { final RDFFormat fmt = Rio.getParserFormatForMIMEType("application/json"); Assert.assertNotNull("Could not find the RDF/JSON RDFFormat instance", fmt); final RDFParser parser = Rio.createParser(fmt); Assert.assertTrue(parser instanceof RDFJSONParser); }
@Test public void testParserFactoryRegistered() { final RDFFormat fmt = Rio.getParserFormatForMIMEType("application/rdf+json"); Assert.assertNotNull("Could not find the RDF/JSON RDFFormat instance", fmt); final RDFParser parser = Rio.createParser(fmt); Assert.assertTrue(parser instanceof RDFJSONParser); }