aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark A. Hershberger2007-12-18 03:22:05 +0000
committerMark A. Hershberger2007-12-18 03:22:05 +0000
commit7731c9f4012b43ee393417ae8cd541c5d89b172b (patch)
tree5de40a7fb1eaad3ccc7f4f0ff3fc241ca4cec37d
parent4f9d920a2d764ffe93e7ec1a75c70cb1d46810f0 (diff)
downloademacs-7731c9f4012b43ee393417ae8cd541c5d89b172b.tar.gz
emacs-7731c9f4012b43ee393417ae8cd541c5d89b172b.zip
fix up xml-debug-print
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/xml.el17
2 files changed, 22 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 30b7a23d712..3c348071fda 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12007-12-18 Mark A. Hershberger <mah@everybody.org>
2
3 * xml.el (xml-escape-string): New function. Escape string using
4 xml-entity-alist.
5 (xml-debug-print-internal): Use xml-escape-string to escape
6 characters in attributes and in text children of elements.
7
12007-12-18 Glenn Morris <rgm@gnu.org> 82007-12-18 Glenn Morris <rgm@gnu.org>
2 9
3 * progmodes/cc-subword.el (c-subword-mode): Drop support for 10 * progmodes/cc-subword.el (c-subword-mode): Drop support for
diff --git a/lisp/xml.el b/lisp/xml.el
index 6ea6dd4f56c..20c582f06e8 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -844,6 +844,17 @@ The first line is indented with the optional INDENT-STRING."
844 844
845(defalias 'xml-print 'xml-debug-print) 845(defalias 'xml-print 'xml-debug-print)
846 846
847(defun xml-escape-string (string)
848 (mapconcat (lambda (byte)
849 (let ((char (char-to-string byte)))
850 (if (rassoc char xml-entity-alist)
851 (concat "&" (car (rassoc char xml-entity-alist)) ";")
852 char)))
853 (if (multibyte-string-p string)
854 (encode-coding-string string 'utf-8)
855 string)
856 ""))
857
847(defun xml-debug-print-internal (xml indent-string) 858(defun xml-debug-print-internal (xml indent-string)
848 "Outputs the XML tree in the current buffer. 859 "Outputs the XML tree in the current buffer.
849The first line is indented with INDENT-STRING." 860The first line is indented with INDENT-STRING."
@@ -854,7 +865,8 @@ The first line is indented with INDENT-STRING."
854 ;; output the attribute list 865 ;; output the attribute list
855 (setq attlist (xml-node-attributes tree)) 866 (setq attlist (xml-node-attributes tree))
856 (while attlist 867 (while attlist
857 (insert ?\ (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\") 868 (insert ?\ (symbol-name (caar attlist)) "=\""
869 (xml-escape-string (cdar attlist)) ?\")
858 (setq attlist (cdr attlist))) 870 (setq attlist (cdr attlist)))
859 871
860 (setq tree (xml-node-children tree)) 872 (setq tree (xml-node-children tree))
@@ -869,7 +881,8 @@ The first line is indented with INDENT-STRING."
869 ((listp node) 881 ((listp node)
870 (insert ?\n) 882 (insert ?\n)
871 (xml-debug-print-internal node (concat indent-string " "))) 883 (xml-debug-print-internal node (concat indent-string " ")))
872 ((stringp node) (insert node)) 884 ((stringp node)
885 (insert (xml-escape-string node)))
873 (t 886 (t
874 (error "Invalid XML tree")))) 887 (error "Invalid XML tree"))))
875 888