Implementation of an RDF XML streaming parser.
How to read a file foo.rdf and count the number of rdf:type triples:
use rio_xml::{RdfXmlParser, RdfXmlError};
use rio_api::parser::TriplesParser;
use rio_api::model::NamedNode;
use std::io::BufReader;
use std::fs::File;
let rdf_type = NamedNode { iri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" };
let mut count = 0;
RdfXmlParser::new(BufReader::new(File::open("foo.rdf").unwrap()), "file:foo.rdf").unwrap().parse_all(&mut |t| {
if t.predicate == rdf_type {
count += 1;
}
Ok(()) as Result<(), RdfXmlError>
}).unwrap();
Write some triples in RDF XML into a Vec buffer:
use RdfXmlFormatter;
use TriplesFormatter;
use ;
let mut formatter = new.unwrap;
formatter.format.unwrap;
let xml = formatter.finish.unwrap;