From 0a783c201ad605afff85e27ba50c66a109355d4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Mon, 4 Mar 2013 22:03:25 +0100 Subject: [PATCH] Fix the printing of attributes. --- src/tree/naive.ml | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/tree/naive.ml b/src/tree/naive.ml index 8654c45..cff6ee2 100644 --- a/src/tree/naive.ml +++ b/src/tree/naive.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) open Utils @@ -228,7 +228,9 @@ let output_escape_string out s = let rec print_attributes out tree_ node = if node != nil then begin - output_string out (QName.to_string node.tag); + let ntag = QName.to_string node.tag in + output_char out ' '; + output out ntag 1 (String.length ntag - 1); output_string out "=\""; output_escape_string out node.first_child.data; output_char out '"'; @@ -237,32 +239,30 @@ let rec print_attributes out tree_ node = let rec print_xml out tree_ node = if node != nil then - let () = - if node.tag == QName.text then - output_escape_string out node.data + let () = + if node.tag == QName.text then + output_escape_string out node.data + else + let tag = QName.to_string node.tag in + output_char out '<'; + output_string out tag; + let fchild = + if node.first_child.tag == QName.attribute_map then + let () = print_attributes out tree_ node.first_child.first_child in + node.first_child.next_sibling else - let tag = QName.to_string node.tag in - output_char out '<'; - output_string out tag; - let fchild = - if node.first_child.tag == QName.attribute_map then - let () = - print_attributes out tree_ node.first_child.first_child - in - node.first_child.next_sibling - else - node.first_child - in - if fchild == nil then output_string out "/>" - else begin - output_char out '>'; - print_xml out tree_ fchild; - output_string out "' - end + node.first_child in - print_xml out tree_ node.next_sibling + if fchild == nil then output_string out "/>" + else begin + output_char out '>'; + print_xml out tree_ fchild; + output_string out "' + end + in + print_xml out tree_ node.next_sibling let root t = t.root -- 2.17.1