Expand description
§OxTTL
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);
§License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or
<http://www.apache.org/licenses/LICENSE-2.0>
) - MIT license (LICENSE-MIT or
<http://opensource.org/licenses/MIT>
)
at your option.
§Contribution
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.
Re-exports§
pub use crate::n3::N3Parser;
pub use crate::nquads::NQuadsParser;
pub use crate::nquads::NQuadsSerializer;
pub use crate::ntriples::NTriplesParser;
pub use crate::ntriples::NTriplesSerializer;
pub use crate::trig::TriGParser;
pub use crate::trig::TriGSerializer;
pub use crate::turtle::TurtleParser;
pub use crate::turtle::TurtleSerializer;
Modules§
- A N-Quads streaming parser implemented by
NQuadsParser
and a serializer implemented byNQuadsSerializer
. - A N-Triples streaming parser implemented by
NTriplesParser
and a serializer implemented byNTriplesSerializer
. - A Turtle streaming parser implemented by
TurtleParser
and a serializer implemented byTurtleSerializer
.
Structs§
- A position in a text i.e. a
line
number starting from 0, acolumn
number starting from 0 (in number of code points) and a global fileoffset
starting from 0 (in number of bytes). - An error in the syntax of the parsed file.
Enums§
- A parsing error.