Skip to content

Commit

Permalink
Do not create metadata labels with empty name in XLSX importer
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskrause committed Aug 15, 2024
1 parent 3f301f0 commit ff2d72a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/exporter/saltxml/corpus_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl SaltCorpusStructureMapper {
project_elem.write_inner_content::<_, Error>(|writer| {
writer
.create_element("sCorpusGraphs")
.write_inner_content::<_, Error>(|mut writer| {
.write_inner_content::<_, Error>(|writer| {
writer
.create_element("labels")
.with_attribute(("xsi:type", "saltCore:SFeature"))
Expand Down
2 changes: 1 addition & 1 deletion src/exporter/saltxml/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl SaltDocumentGraphMapper {
.get_value_for_item(&document_node_id, &NODE_NAME_KEY)?
.context("Missing node name for document graph")?;
let salt_id = format!("T::salt:/{node_name}");
graph_tag.write_inner_content::<_, Error>(|mut writer| {
graph_tag.write_inner_content::<_, Error>(|writer| {
writer
.create_element("labels")
.with_attribute(("xsi:type", "saltCore:SElementId"))
Expand Down
20 changes: 11 additions & 9 deletions src/importer/xlsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,17 @@ impl ImportSpreadsheet {
if let Some(value_cell) = entry_map.get(&2) {
let kv = key_cell.get_value();
let key = kv.trim();
let (ns, name) = split_qname(key);
let vv = value_cell.get_value();
let value = vv.trim();
update.add_event(UpdateEvent::AddNodeLabel {
node_name: doc_path.to_string(),
anno_ns: ns.map_or("".to_string(), str::to_string),
anno_name: name.to_string(),
anno_value: value.to_string(),
})?;
if !key.is_empty() {
let (ns, name) = split_qname(key);
let vv = value_cell.get_value();
let value = vv.trim();
update.add_event(UpdateEvent::AddNodeLabel {
node_name: doc_path.to_string(),
anno_ns: ns.map_or("".to_string(), str::to_string),
anno_name: name.to_string(),
anno_value: value.to_string(),
})?;
}
}
}
}
Expand Down

0 comments on commit ff2d72a

Please sign in to comment.