aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/xml.el42
1 files changed, 26 insertions, 16 deletions
diff --git a/lisp/xml.el b/lisp/xml.el
index ab87125356d..db3292a4cfb 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -622,9 +622,15 @@ This follows the rule [28] in the XML specifications."
622;;** 622;;**
623;;******************************************************************* 623;;*******************************************************************
624 624
625(defun xml-debug-print (xml) 625(defun xml-debug-print (xml &optional indent-string)
626 "Outputs the XML in the current buffer.
627XML can be a tree or a list of nodes.
628The first line is indented with the optional INDENT-STRING."
629 (setq indent-string (or indent-string ""))
626 (dolist (node xml) 630 (dolist (node xml)
627 (xml-debug-print-internal node ""))) 631 (xml-debug-print-internal node indent-string)))
632
633(defalias 'xml-print 'xml-debug-print)
628 634
629(defun xml-debug-print-internal (xml indent-string) 635(defun xml-debug-print-internal (xml indent-string)
630 "Outputs the XML tree in the current buffer. 636 "Outputs the XML tree in the current buffer.
@@ -639,22 +645,26 @@ The first line is indented with INDENT-STRING."
639 (insert ?\ (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\") 645 (insert ?\ (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\")
640 (setq attlist (cdr attlist))) 646 (setq attlist (cdr attlist)))
641 647
642 (insert ?>)
643
644 (setq tree (xml-node-children tree)) 648 (setq tree (xml-node-children tree))
645 649
646 ;; output the children 650 (if (null tree)
647 (dolist (node tree) 651 (insert ?/ ?>)
648 (cond 652 (insert ?>)
649 ((listp node) 653
650 (insert ?\n) 654 ;; output the children
651 (xml-debug-print-internal node (concat indent-string " "))) 655 (dolist (node tree)
652 ((stringp node) (insert node)) 656 (cond
653 (t 657 ((listp node)
654 (error "Invalid XML tree")))) 658 (insert ?\n)
655 659 (xml-debug-print-internal node (concat indent-string " ")))
656 (insert ?\n indent-string 660 ((stringp node) (insert node))
657 ?< ?/ (symbol-name (xml-node-name xml)) ?>))) 661 (t
662 (error "Invalid XML tree"))))
663
664 (when (not (and (null (cdr tree))
665 (stringp (car tree))))
666 (insert ?\n indent-string))
667 (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>))))
658 668
659(provide 'xml) 669(provide 'xml)
660 670