Crates.io | oxrdfio |
lib.rs | oxrdfio |
version | 0.1.3 |
source | src |
created_at | 2024-01-03 12:58:24.282687 |
updated_at | 2024-11-07 18:15:08.865206 |
description | Parser and serializer for various RDF formats |
homepage | |
repository | https://github.com/oxigraph/oxigraph/tree/master/lib/oxrdfxml |
max_upload_size | |
id | 1087374 |
size | 80,955 |
OxRDF I/O is a set of parsers and serializers for RDF.
It supports:
oxttl
oxttl
oxttl
oxrdfxml
oxttl
oxttl
Support for SPARQL-star is also available behind the rdf-star
feature for Turtle-star, TriG-star, N-Triples-star and N-Quads-star.
It is designed as a low level parser compatible with both synchronous and asynchronous I/O (behind the async-tokio
feature).
The entry points of this library are the two [RdfParser
] and [RdfSerializer
] structs.
Usage example converting a Turtle file to a N-Triples file:
use oxrdfio::{RdfFormat, RdfParser, RdfSerializer};
let turtle_file = b"@base <http://example.com/> .
@prefix schema: <http://schema.org/> .
<foo> a schema:Person ;
schema:name \"Foo\" .
<bar> a schema:Person ;
schema:name \"Bar\" .";
let ntriples_file = b"<http://example.com/foo> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
<http://example.com/foo> <http://schema.org/name> \"Foo\" .
<http://example.com/bar> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
<http://example.com/bar> <http://schema.org/name> \"Bar\" .
";
let mut serializer = RdfSerializer::from_format(RdfFormat::NTriples).for_writer(Vec::new());
for quad in RdfParser::from_format(RdfFormat::Turtle).for_reader(turtle_file.as_ref()) {
serializer.serialize_quad(&quad.unwrap()).unwrap();
}
assert_eq!(serializer.finish().unwrap(), ntriples_file);
Parsers for other RDF formats exists in Rust like graph-rdfa-processor for RDFa and json-ld for JSON-LD.
This project is licensed under either of
<http://www.apache.org/licenses/LICENSE-2.0>
)<http://opensource.org/licenses/MIT>
)at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Oxigraph by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.