Java Code Examples for org.eclipse.rdf4j.rio.RDFFormat#RDFXML

The following examples show how to use org.eclipse.rdf4j.rio.RDFFormat#RDFXML . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TripleStoreRDF4J.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
private static RDFFormat guessFormatFromName(String name) {
    if (name.endsWith(".ttl")) {
        return RDFFormat.TURTLE;
    } else if (name.endsWith(".xml")) {
        return RDFFormat.RDFXML;
    }
    return RDFFormat.RDFXML;
}
 
Example 2
Source File: RestUtils.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns the specified RDFFormat. Currently supports Turtle, TRiG, RDF/XML, and JSON-LD.
 *
 * @param format The abbreviated name of a RDFFormat.
 * @return A RDFFormat object with the requested format.
 */
public static RDFFormat getRDFFormat(String format) {
    switch (format.toLowerCase()) {
        case "turtle":
            return RDFFormat.TURTLE;
        case "trig":
            return RDFFormat.TRIG;
        case "rdf/xml":
            return RDFFormat.RDFXML;
        case "jsonld":
        default:
            return RDFFormat.JSONLD;
    }
}
 
Example 3
Source File: RdfController.java    From rya with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/loadrdf", method = RequestMethod.POST)
public void loadRdf(@RequestParam(required = false) final String format,
        @RequestParam(value = RdfCloudTripleStoreConfiguration.CONF_CV, required = false) final String cv,
        @RequestParam(required = false) final String graph,
                    @RequestBody final String body,
                    final HttpServletResponse response)
        throws RepositoryException, IOException, RDFParseException {
    RDFFormat format_r = RDFFormat.RDFXML;
    if (format != null) {
        format_r = RdfFormatUtils.getRdfFormatFromName(format);
        if (format_r == null) {
            throw new RuntimeException("RDFFormat[" + format + "] not found");
        }
    }

    // add named graph as context (if specified).
    final List<Resource> contextList = new ArrayList<Resource>();
    if (graph != null) {
        contextList.add(VALUE_FACTORY.createIRI(graph));
    }
    SailRepositoryConnection conn = null;
    try {
        conn = repository.getConnection();

        if (conn.getSailConnection() instanceof RdfCloudTripleStoreConnection && cv != null) {
            final RdfCloudTripleStoreConnection<?> sailConnection = (RdfCloudTripleStoreConnection<?>) conn.getSailConnection();
            sailConnection.getConf().set(RdfCloudTripleStoreConfiguration.CONF_CV, cv);
        }

        conn.add(new StringReader(body), "", format_r, contextList.toArray(new Resource[contextList.size()]));
        conn.commit();
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
}
 
Example 4
Source File: RDFXMLWriter.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public RDFFormat getRDFFormat() {
	return RDFFormat.RDFXML;
}
 
Example 5
Source File: RDFXMLParserFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Returns the RDF format for this factory.
 */
@Override
public RDFFormat getRDFFormat() {
	return RDFFormat.RDFXML;
}
 
Example 6
Source File: RDFXMLParser.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public final RDFFormat getRDFFormat() {
	return RDFFormat.RDFXML;
}
 
Example 7
Source File: RDFXMLWriterFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Returns {@link RDFFormat#RDFXML}.
 */
@Override
public RDFFormat getRDFFormat() {
	return RDFFormat.RDFXML;
}
 
Example 8
Source File: RDFXMLPrettyWriterFactory.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Returns {@link RDFFormat#RDFXML}.
 */
@Override
public RDFFormat getRDFFormat() {
	return RDFFormat.RDFXML;
}