indexing description: "Objects that ..." author: "" date: "$Date$" revision: "$Revision$" class XML_ELEMENT inherit XML_NODE redefine set_inner_text, to_xml_internal, debug_out_impl end create {XML_NODE} make_node feature -- Access from {XML_NODE} node_type : STRING is -- gets the node type do Result := "XML_ELEMENT" end set_inner_text (text: STRING) is -- sets the inner text of this xml node do Precursor (text) child_nodes.wipe_out child_nodes.append (owner_document.create_text (text)) end feature -- Cloning clone_node (deep: BOOLEAN) : like Current is -- creates a clone of the current node local c: LINKED_LIST_CURSOR[XML_NODE] do create Result.make_node (Void, parent, namespace, name.xml_prefix, name.xml_local_part) c := attributes.cursor from attributes.start until attributes.after loop Result.attributes.append (attributes.item.clone_node (deep)) attributes.forth end attributes.go_to (c) if deep then c := child_nodes.cursor from child_nodes.start until child_nodes.after loop Result.child_nodes.append (child_nodes.item.clone_node (deep)) child_nodes.forth end child_nodes.go_to (c) end end feature {XML_NODE} -- Implementation to_xml_internal (pretty_print: BOOLEAN; indent_depth: INTEGER) : STRING is -- generates the string for the xml content local cnode: XML_CHARACTER_DATA contains_text: BOOLEAN inner: STRING child_indent: INTEGER do contains_text := False create inner.make_empty if pretty_print then child_indent := indent_depth + 1 else child_indent := 0 end if child_nodes.count > 0 then from child_nodes.start until child_nodes.after loop cnode ?= child_nodes.item if cnode /= Void then if not cnode.is_whitespace then contains_text := True inner.append (cnode.to_xml_internal (pretty_print, child_indent)) end else if pretty_print and not contains_text then inner.append ("%N") end inner.append (child_nodes.item.to_xml_internal (pretty_print, child_indent)) end child_nodes.forth end end create Result.make_empty Result.append (get_indent_string (indent_depth) + "<" + name.name) from attributes.start until attributes.after loop Result.append (" " + attributes.item.to_xml_internal (pretty_print, child_indent)) attributes.forth end if child_nodes.count > 0 then Result.append (">") Result.append (inner) if not contains_text then Result.append ("%N" + get_indent_string (indent_depth)) end Result.append ("") else Result.append (" />") end end feature {XML_NODE} -- Debug debug_out_impl (pre: STRING) : STRING is -- do create Result.make_empty --Result.append (pre + node_type + ": " + name + "%Ninner text: %"" + inner_text + "%"%N") Result.append (pre + node_type + ": " + name.name + "%N") from attributes.start until attributes.off loop Result.append (attributes.item.debug_out_impl (pre + " ")) attributes.forth end from child_nodes.start until child_nodes.off loop Result.append (child_nodes.item.debug_out_impl (pre + " ")) child_nodes.forth end end end