diff --git a/Cargo.toml b/Cargo.toml index 6a23456..f51eaa0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "testsuite", "xml" ] +resolver = "2" [patch.crates-io] rio_api = { path = "api" } diff --git a/testsuite/Cargo.toml b/testsuite/Cargo.toml index b942192..c22ab0f 100644 --- a/testsuite/Cargo.toml +++ b/testsuite/Cargo.toml @@ -19,7 +19,7 @@ oxiri = "0.2" permutohedron = "0.2" [dev-dependencies] -criterion = "0.4" +criterion = "0.5" [features] default = [] diff --git a/testsuite/rdf-tests b/testsuite/rdf-tests index 4cc89f4..83e2e77 160000 --- a/testsuite/rdf-tests +++ b/testsuite/rdf-tests @@ -1 +1 @@ -Subproject commit 4cc89f493823bef49e2f0fa6b70af88d4ba02d52 +Subproject commit 83e2e779289f75d6b6d8e98f7ab6cc181137933c diff --git a/testsuite/src/manifest.rs b/testsuite/src/manifest.rs index 749f0fb..12a5e61 100644 --- a/testsuite/src/manifest.rs +++ b/testsuite/src/manifest.rs @@ -16,10 +16,10 @@ pub struct Test { impl fmt::Display for Test { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.kind)?; - for name in &self.name { + if let Some(name) = &self.name { write!(f, " named \"{}\"", name)?; } - for comment in &self.comment { + if let Some(comment) = &self.comment { write!(f, " with comment \"{}\"", comment)?; } write!(f, " on file \"{}\"", self.action)?; diff --git a/turtle/src/shared.rs b/turtle/src/shared.rs index 5dec6f3..b608be0 100644 --- a/turtle/src/shared.rs +++ b/turtle/src/shared.rs @@ -5,7 +5,6 @@ use oxiri::Iri; use rio_api::model::*; use std::char; use std::io::BufRead; -use std::u8; pub const MAX_ASCII: u8 = 0x7F; diff --git a/turtle/src/utils.rs b/turtle/src/utils.rs index f24d01a..8fd0f1f 100644 --- a/turtle/src/utils.rs +++ b/turtle/src/utils.rs @@ -4,7 +4,6 @@ use rio_api::parser::LineBytePosition; use std::collections::VecDeque; use std::io::{BufRead, ErrorKind, Read}; use std::str; -use std::u8; /// Reads the file in streaming pub struct LookAheadByteReader { diff --git a/xml/Cargo.toml b/xml/Cargo.toml index dcdca52..6982ec2 100644 --- a/xml/Cargo.toml +++ b/xml/Cargo.toml @@ -22,4 +22,4 @@ default = [] oxilangtag = "0.1" oxiri = "0.2" rio_api = { version = "0.8", path="../api" } -quick-xml = "0.28" +quick-xml = "0.36" diff --git a/xml/src/error.rs b/xml/src/error.rs index 39b8b3b..b9f49ef 100644 --- a/xml/src/error.rs +++ b/xml/src/error.rs @@ -99,9 +99,6 @@ impl From for io::Error { match error.kind { RdfXmlErrorKind::Xml(error) => match error { quick_xml::Error::Io(error) => io::Error::new(error.kind(), error), - quick_xml::Error::UnexpectedEof(error) => { - io::Error::new(io::ErrorKind::UnexpectedEof, error) - } error => io::Error::new(io::ErrorKind::InvalidData, error), }, RdfXmlErrorKind::Other(error) => io::Error::new(io::ErrorKind::InvalidData, error), diff --git a/xml/src/parser.rs b/xml/src/parser.rs index 3e54c1d..90e4e9a 100644 --- a/xml/src/parser.rs +++ b/xml/src/parser.rs @@ -1,20 +1,20 @@ -use quick_xml::events::*; -use quick_xml::{NsReader, Writer}; -use rio_api::model::*; -use rio_api::parser::TriplesParser; -use std::convert::TryInto; -use std::io::BufRead; -use std::str; - use crate::error::{RdfXmlError, RdfXmlErrorKind}; use crate::model::*; use crate::utils::*; use oxilangtag::LanguageTag; use oxiri::Iri; +use quick_xml::escape::resolve_xml_entity; use quick_xml::escape::unescape_with; use quick_xml::events::attributes::Attribute; +use quick_xml::events::*; use quick_xml::name::{LocalName, QName, ResolveResult}; +use quick_xml::{NsReader, Writer}; +use rio_api::model::*; +use rio_api::parser::TriplesParser; use std::collections::{HashMap, HashSet}; +use std::convert::TryInto; +use std::io::BufRead; +use std::str; /// A [RDF/XML](https://www.w3.org/TR/rdf-syntax-grammar/) streaming parser. /// @@ -63,7 +63,7 @@ impl RdfXmlParser { /// Builds the parser from a `BufRead` implementation, and a base IRI for relative IRI resolution. pub fn new(reader: R, base_iri: Option>) -> Self { let mut reader = NsReader::from_reader(reader); - reader.expand_empty_elements(true); + reader.config_mut().expand_empty_elements = true; Self { reader: RdfXmlReader { reader, @@ -80,7 +80,7 @@ impl RdfXmlParser { /// The current byte position in the input data. pub fn buffer_position(&self) -> usize { - self.reader.reader.buffer_position() + self.reader.reader.buffer_position().try_into().unwrap() } } @@ -1021,7 +1021,7 @@ impl RdfXmlReader { fn convert_attribute(&self, attribute: Attribute) -> Result { Ok(attribute - .decode_and_unescape_value_with(&self.reader, |e| self.resolve_entity(e))? + .decode_and_unescape_value_with(self.reader.decoder(), |e| self.resolve_entity(e))? .to_string()) } @@ -1036,7 +1036,7 @@ impl RdfXmlReader { } fn resolve_entity(&self, e: &str) -> Option<&str> { - self.custom_entities.get(e).map(|e| e.as_str()) + resolve_xml_entity(e).or_else(|| self.custom_entities.get(e).map(String::as_str)) } }