Examples of RDFParser


Examples of org.openrdf.rio.RDFParser

      ValueFactory vf = systemRepo.getValueFactory();

      Graph graph = new GraphImpl(vf);

      RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE, vf);
      rdfParser.setRDFHandler(new StatementCollector(graph));
      rdfParser.parse(new StringReader(configString), RepositoryConfigSchema.NAMESPACE);

      Resource repositoryNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE,
          RepositoryConfigSchema.REPOSITORY);
      RepositoryConfig repConfig = RepositoryConfig.create(graph, repositoryNode);
      repConfig.validate();
View Full Code Here

Examples of org.openrdf.rio.RDFParser

      URL dataURL = new URL(dataPath);
      RDFFormat format = Rio.getParserFormatForFileName(dataPath, RDFFormat.RDFXML);

      writeln("RDF Format is " + format.getName());

      RDFParser parser = Rio.createParser(format);
      VerificationListener listener = new VerificationListener();
      parser.setDatatypeHandling(RDFParser.DatatypeHandling.VERIFY);
      parser.setVerifyData(true);
      parser.setParseErrorListener(listener);
      parser.setRDFHandler(listener);

      writeln("Verifying data...");
      InputStream in = dataURL.openStream();
      try {
        parser.parse(in, "urn://openrdf.org/RioVerifier/");
      }
      finally {
        in.close();
      }
View Full Code Here

Examples of org.openrdf.rio.RDFParser

    if (httpCode == HttpURLConnection.HTTP_OK) {
      String mimeType = getResponseMIMEType(method);
      try {
        RDFFormat format = RDFFormat.matchMIMEType(mimeType, rdfFormats);
        RDFParser parser = Rio.createParser(format, getValueFactory());
        parser.setPreserveBNodeIDs(true);
        parser.setRDFHandler(handler);
        parser.parse(method.getResponseBodyAsStream(), method.getURI().getURI());
      }
      catch (UnsupportedRDFormatException e) {
        throw new RepositoryException("Server responded with an unsupported file format: " + mimeType);
      }
      catch (RDFParseException e) {
View Full Code Here

Examples of org.openrdf.rio.RDFParser

  /* Adapted from Sesame's RepositoryConnectionBase.addInputStreamOrReader() */
  private void addData(Graph graph, InputStream is, RDFFormat dataFormat, String baseURI, Resource... contexts) throws RDFParseException, RDFHandlerException, IOException
   {
    OpenRDFUtil.verifyContextNotNull(contexts);

    RDFParser rdfParser = Rio.createParser(dataFormat, graph.getValueFactory());

    rdfParser.setVerifyData(true);
    rdfParser.setStopAtFirstError(true);
    rdfParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

    RDFGraphInserter rdfInserter = new RDFGraphInserter(graph, contexts);
    rdfParser.setRDFHandler(rdfInserter);
    rdfParser.parse(is, baseURI);
  }   
View Full Code Here

Examples of org.openrdf.rio.RDFParser

  {
    RepositoryConnection con = dataRep.getConnection();
    con.setAutoCommit(false);
    try {
      RDFFormat rdfFormat = Rio.getParserFormatForFileName(graphURI.toString(), RDFFormat.TURTLE);
      RDFParser rdfParser = Rio.createParser(rdfFormat, dataRep.getValueFactory());
      rdfParser.setVerifyData(false);
      rdfParser.setDatatypeHandling(DatatypeHandling.IGNORE);
      // rdfParser.setPreserveBNodeIDs(true);

      RDFInserter rdfInserter = new RDFInserter(con);
      rdfInserter.enforceContext(context);
      rdfParser.setRDFHandler(rdfInserter);

      URL graphURL = new URL(graphURI.toString());
      InputStream in = graphURL.openStream();
      try {
        rdfParser.parse(in, graphURI.toString());
      }
      finally {
        in.close();
      }
View Full Code Here

Examples of org.openrdf.rio.RDFParser

    throws Exception
  {
    RDFFormat rdfFormat = Rio.getParserFormatForFileName(resultFileURL);

    if (rdfFormat != null) {
      RDFParser parser = Rio.createParser(rdfFormat);
      parser.setDatatypeHandling(DatatypeHandling.IGNORE);
      parser.setPreserveBNodeIDs(true);

      Set<Statement> result = new LinkedHashSet<Statement>();
      parser.setRDFHandler(new StatementCollector(result));

      InputStream in = new URL(resultFileURL).openStream();
      try {
        parser.parse(in, resultFileURL);
      }
      finally {
        in.close();
      }
View Full Code Here

Examples of org.openrdf.rio.RDFParser

            final boolean verifyDataType,
            final boolean stopAtFirstError,
            final ExtractionContext extractionContext,
            final ExtractionResult extractionResult
    ) {
        final RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
        configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
        return parser;
    }
View Full Code Here

Examples of org.openrdf.rio.RDFParser

            final boolean verifyDataType,
            final boolean stopAtFirstError,
            final ExtractionContext extractionContext,
            final ExtractionResult extractionResult
    ) {
        final RDFParser parser = Rio.createParser(RDFFormat.NTRIPLES);
        configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
        return parser;
    }
View Full Code Here

Examples of org.openrdf.rio.RDFParser

            final boolean verifyDataType,
            final boolean stopAtFirstError,
            final ExtractionContext extractionContext,
            final ExtractionResult extractionResult
    ) {
        final RDFParser parser = Rio.createParser(RDFFormat.NQUADS);
        configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
        return parser;
    }
View Full Code Here

Examples of org.semanticweb.owlapi.rdf.syntax.RDFParser

        try {
            final RDFXMLOntologyFormat format = new RDFXMLOntologyFormat();
            if (owlOntologyManager == null) {
                throw new OWLRuntimeException("Cannot parse because OWLOntologyManager is null!");
            }
            final RDFParser parser = new RDFParser() {
                public void startPrefixMapping(String prefix, String IRI) throws SAXException {
                    super.startPrefixMapping(prefix, IRI);
                    format.setPrefix(prefix, IRI);
                }


                public void startElement(String namespaceIRI, String localName, String qName, Attributes atts) throws
                                                                                                               SAXException {
                    super.startElement(namespaceIRI, localName, qName, atts);
                    String value = atts.getValue(XMLNS, "base");
                    if (value != null) {
                        consumer.setXMLBase(value);
                    }
                }
            };
            IRIProvider prov = new IRIProvider() {
                public IRI getIRI(String s) {
                    return parser.getIRI(s);
                }
            };
            consumer = new OWLRDFConsumer(owlOntologyManager, ontology, new AnonymousNodeChecker() {
                public boolean isAnonymousNode(IRI IRI) {
                    return parser.isAnonymousNodeIRI(IRI.toString());
                }


                public boolean isAnonymousNode(String IRI) {
                    return parser.isAnonymousNodeIRI(IRI);
                }
            });
            consumer.setIRIProvider(prov);
            consumer.setOntologyFormat(format);
            InputSource is = getInputSource(documentSource);
            parser.parse(is, consumer);
            return format;
        }
        catch (TranslatedOntologyChangeException e) {
            throw e.getCause();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.