From af0560896755707baf7cf8751dbb8605ca6ba75f Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Tue, 29 Sep 2020 14:45:51 +0200 Subject: [PATCH] fixed submetadata warnings --- Cargo.toml | 2 +- src/parser.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 332599e..b18767c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "folia" -version = "0.0.4" +version = "0.0.5" description = "High-performance library for handling the FoLiA XML format (Format for Linguistic Annotation)" authors = ["Maarten van Gompel "] homepage = "https://proycon.github.io/folia" diff --git a/src/parser.rs b/src/parser.rs index 4c3393c..ee16ac6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -86,6 +86,7 @@ impl Document { let mut parsedeclarations = false; let mut parseprovenance = false; let mut submetadata: Option = None; + let mut submetadata_type: Option = None; let mut text: Option = None; let mut meta_id: Option = None; let mut declaration_key: Option = None; @@ -161,9 +162,8 @@ impl Document { parseprovenance = true; }, (Some(ns), b"submetadata") if ns == NSFOLIA => { - let mut submetadata_type: Option = None; for attrib in e.attributes() { - let attrib = attrib.expect("unwrapping annotator attribute"); + let attrib = attrib.expect("unwrapping submetadata attribute"); if let Ok(value) = attrib.unescape_and_decode_value(&reader) { match attrib.key { b"xml:id" => { @@ -264,6 +264,9 @@ impl Document { if let Some(submetadata_id) = &submetadata { let submetadata_opt: Option<&mut Metadata> = doc.submetadata.get_mut(submetadata_id); if let Some(submetadata) = submetadata_opt { + if submetadata.metadatatype.is_none() && submetadata_type.is_some() { + submetadata.metadatatype = submetadata_type.clone(); + } submetadata.data.insert(meta_id.clone(), text.clone()); } } else {