5 releases

0.1.0-alpha.5 Mar 25, 2024
0.1.0-alpha.4 Mar 23, 2024
0.1.0-alpha.3 Mar 7, 2024
0.1.0-alpha.2 Jan 25, 2024
0.1.0-alpha.1 Jan 3, 2024

#2762 in Parser implementations

Download history 18/week @ 2024-01-01 23/week @ 2024-01-08 79/week @ 2024-01-15 26/week @ 2024-01-22 80/week @ 2024-01-29 51/week @ 2024-02-05 7/week @ 2024-02-12 112/week @ 2024-02-19 74/week @ 2024-02-26 185/week @ 2024-03-04 50/week @ 2024-03-11 155/week @ 2024-03-18 170/week @ 2024-03-25 167/week @ 2024-04-01

550 downloads per month
Used in 10 crates (via oxrdfio)

MIT/Apache

280KB
6K SLoC

OxRDF/XML

Latest Version Released API docs Crates.io downloads actions status Gitter

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;

fn main() {
    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().parse_read(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.

Dependencies

~1.9–3.5MB
~66K SLoC