Crates.io | oxttl |
lib.rs | oxttl |
version | 0.1.3 |
source | src |
created_at | 2024-01-03 12:58:19.391142 |
updated_at | 2024-11-07 18:14:59.551815 |
description | Parser and serializer for languages related to RDF Turtle (N-Triples, N-Quads, Turtle, TriG and N3) |
homepage | |
repository | https://github.com/oxigraph/oxigraph/tree/master/lib/oxttl |
max_upload_size | |
id | 1087373 |
size | 345,638 |
Oxttl is a set of parsers and serializers for Turtle, TriG, N-Triples, N-Quads and N3.
Support for SPARQL-star is also available behind the rdf-star
feature for all languages but N3 (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.
Usage example counting the number of people in a Turtle file:
use oxrdf::{NamedNodeRef, vocab::rdf};
use oxttl::TurtleParser;
let 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 schema_person = NamedNodeRef::new("http://schema.org/Person").unwrap();
let mut count = 0;
for triple in TurtleParser::new().for_reader(file.as_ref()) {
let triple = triple.unwrap();
if triple.predicate == rdf::TYPE && triple.object == schema_person.into() {
count += 1;
}
}
assert_eq!(2, count);
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.