diff options
| author | Alex Schroeder | 2004-04-30 20:00:19 +0000 |
|---|---|---|
| committer | Alex Schroeder | 2004-04-30 20:00:19 +0000 |
| commit | 27240aa42f922ee7470a5cdfefb896b0867e29b7 (patch) | |
| tree | 63cb4198a9ab59cc440ccc144691c4ec3639bebb | |
| parent | d71d20ea2ce24b9a8b230ffe1ed1de1aae09adf8 (diff) | |
| download | emacs-27240aa42f922ee7470a5cdfefb896b0867e29b7.tar.gz emacs-27240aa42f922ee7470a5cdfefb896b0867e29b7.zip | |
(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.
| -rw-r--r-- | lisp/xml.el | 42 |
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. | ||
| 627 | XML can be a tree or a list of nodes. | ||
| 628 | The 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 | ||