From: Markus Triska Date: Tue, 11 Aug 2020 19:00:56 +0000 (+0200) Subject: library(sgml): Correctly parse XML leaf nodes that are not text nodes. X-Git-Tag: v0.9.0~174^2~12^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=099d9aaca6509496ccb28c522659b990f42037f0;p=scryer-prolog.git library(sgml): Correctly parse XML leaf nodes that are not text nodes. Example: ?- load_xml("", Node, []). Node = [element(schemaRef,[type="simple"],[])]. This is necessary for example to parse XBRL files. See #665. --- diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 2d890877..d2779d1a 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -5877,7 +5877,10 @@ impl MachineState { indices: &mut IndexStore, node: roxmltree::Node, ) -> Addr { - if node.has_children() { + if node.is_text() { + let string = String::from(node.text().unwrap()); + self.heap.put_complete_string(&string) + } else { let mut avec = Vec::new(); for attr in node.attributes() { let chars = clause_name!(String::from(attr.name()), indices.atom_tbl); @@ -5914,9 +5917,6 @@ impl MachineState { self.heap.push(HeapCellValue::Addr(children)); result - } else { - let string = String::from(node.text().unwrap()); - self.heap.put_complete_string(&string) } }