srdf::srdf_parser

Function rdf_list

Source
pub fn rdf_list<RDF>() -> RDFList<RDF>
where RDF: SRDF,
Expand description

Parses the current focus node as an RDF List

use iri_s::{IriS, iri};
use srdf::SRDFGraph;
use srdf::{property_value, then, RDFFormat, ReaderMode, RDFNodeParse, rdf_list, set_focus};
use oxrdf::{Literal, Term};
let s = r#"prefix : <http://example.org/>
 :x :p (1 2).
"#;
let graph = SRDFGraph::from_str(s, &RDFFormat::Turtle, None, &ReaderMode::default()).unwrap();
let x = iri!("http://example.org/x");
let p = iri!("http://example.org/p");
let mut parser = property_value(&p).then(move |obj| {
  set_focus(&obj).with(rdf_list())
});
assert_eq!(parser.parse(&x, graph).unwrap(),
  vec![Term::from(Literal::from(1)), Term::from(Literal::from(2))])