Crates.io | oxrdfxml |
lib.rs | oxrdfxml |
version | 0.1.3 |
source | src |
created_at | 2024-01-03 12:58:15.340612 |
updated_at | 2024-11-07 18:14:49.813452 |
description | Parser and serializer for the RDF/XML format |
homepage | |
repository | https://github.com/oxigraph/oxigraph/tree/master/lib/oxrdfxml |
max_upload_size | |
id | 1087372 |
size | 97,683 |
OxRdfXml is a parser and serializer for RDF/XML.
The entry points of this library are the two [RdfXmlParser
] and [RdfXmlSerializer
] structs.
Usage example counting the number of people in a RDF/XML file:
use oxrdf::{NamedNodeRef, vocab::rdf};
use oxrdfxml::RdfXmlParser;
let file = br#"<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:schema="http://schema.org/">
<rdf:Description rdf:about="http://example.com/foo">
<rdf:type rdf:resource="http://schema.org/Person" />
<schema:name>Foo</schema:name>
</rdf:Description>
<schema:Person rdf:about="http://example.com/bar" schema:name="Bar" />
</rdf:RDF>"#;
let schema_person = NamedNodeRef::new("http://schema.org/Person").unwrap();
let mut count = 0;
for triple in RdfXmlParser::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.