# HG changeset patch # User Alex Schroeder # Date 1083355219 0 # Node ID d33879ad154a2c946ba154e3fb45e073265712e3 # Parent fd5403ebeab16935d1282cbf613e3782181e4d84 (xml-debug-print-internal): Don't add newline and indentation to text nodes and write empty elements as empty tags instead of opening and closing tags. (xml-debug-print): Take optional indent-string argument. (xml-print): Alias for xml-debug-print. diff -r fd5403ebeab1 -r d33879ad154a lisp/xml.el --- a/lisp/xml.el Fri Apr 30 18:55:13 2004 +0000 +++ b/lisp/xml.el Fri Apr 30 20:00:19 2004 +0000 @@ -622,9 +622,15 @@ ;;** ;;******************************************************************* -(defun xml-debug-print (xml) +(defun xml-debug-print (xml &optional indent-string) + "Outputs the XML in the current buffer. +XML can be a tree or a list of nodes. +The first line is indented with the optional INDENT-STRING." + (setq indent-string (or indent-string "")) (dolist (node xml) - (xml-debug-print-internal node ""))) + (xml-debug-print-internal node indent-string))) + +(defalias 'xml-print 'xml-debug-print) (defun xml-debug-print-internal (xml indent-string) "Outputs the XML tree in the current buffer. @@ -639,22 +645,26 @@ (insert ?\ (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\") (setq attlist (cdr attlist))) - (insert ?>) - (setq tree (xml-node-children tree)) - ;; output the children - (dolist (node tree) - (cond - ((listp node) - (insert ?\n) - (xml-debug-print-internal node (concat indent-string " "))) - ((stringp node) (insert node)) - (t - (error "Invalid XML tree")))) + (if (null tree) + (insert ?/ ?>) + (insert ?>) - (insert ?\n indent-string - ?< ?/ (symbol-name (xml-node-name xml)) ?>))) + ;; output the children + (dolist (node tree) + (cond + ((listp node) + (insert ?\n) + (xml-debug-print-internal node (concat indent-string " "))) + ((stringp node) (insert node)) + (t + (error "Invalid XML tree")))) + + (when (not (and (null (cdr tree)) + (stringp (car tree)))) + (insert ?\n indent-string)) + (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>)))) (provide 'xml)