Skip to content

Commit

Permalink
library(sgml): Correctly parse XML leaf nodes that are not text nodes.
Browse files Browse the repository at this point in the history
Example:

    ?- load_xml("<schemaRef type=\"simple\"/>", Node, []).
       Node = [element(schemaRef,[type="simple"],[])].

This is necessary for example to parse XBRL files. See #665.
  • Loading branch information
triska committed Aug 11, 2020
1 parent 5fa3b9f commit 099d9aa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/machine/system_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 099d9aa

Please sign in to comment.