xemacs-packages/net-utils/xml.el is quite a bit out of sync compared with the
version distributed with GNU Emacs. In particular it has a nasty bug
illustrated by the code below: an empty element written as <foo/> incorrectly
has a list of children. Compare with <foo></foo> where the test below
returns
nil. A minimal patch is in the attached diff but it might be better to sync
with the FSF version.
- David.
(defun pg-xml-parse-string (arg)
"Parse string in ARG, same as pg-xml-parse-buffer."
(let
((tempbuffer (get-buffer-create " *xml-parse*")))
(save-excursion
(set-buffer tempbuffer)
(delete-region (point-min) (point-max))
(insert-string arg)
(pg-xml-parse-buffer (current-buffer) 'nomessage))))
(defun pg-xml-parse-buffer (&optional buffer nomsg)
"Parse an XML documment in BUFFER (defaulting to current buffer).
Parsing according to `xml-parse-file' of xml.el."
(unless nomsg
(message "Parsing %s..." (buffer-name buffer)))
(let ((xml (xml-parse-region (point-min)
(point-max)
(current-buffer)
nil)))
(unless nomsg
(message "Parsing %s...done" (buffer-name buffer)))
xml))
;; Check that the empty parsing bug isn't present
(if (xml-node-children (car (pg-xml-parse-string "<foo/>")))
(pg-internal-warning "An old version of xml.el was loaded! It is buggy.
See Proof General FAQ."))
*** /home/da/emacs-src/xemacs/packages/xemacs-packages/net-utils/xml.el 2004-08-25
12:04:32.000000000 +0100
--- PG/lib/xml.el 2005-09-29 18:22:43.000000000 +0100
***************
*** 1,5 ****
--- 1,8 ----
;;; xml.el --- XML parser
+ ;;; !!! This version has been modified from the version distributed with
+ ;;; XEmacs to fix a bug parsing empty elements, for Proof General. !!!
+
;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
;; Author: Emmanuel Briot <briot(a)gnat.com>
***************
*** 169,176 ****
(error "XML files can have only one toplevel tag")))
(goto-char end)))
(if parse-dtd
! (cons dtd (reverse xml))
! (reverse xml)))))
(defun xml-parse-tag (end &optional parse-dtd)
--- 172,179 ----
(error "XML files can have only one toplevel tag")))
(goto-char end)))
(if parse-dtd
! (cons dtd (nreverse xml))
! (nreverse xml)))))
(defun xml-parse-tag (end &optional parse-dtd)
***************
*** 225,231 ****
(if (looking-at "/>")
(progn
(forward-char 2)
! (nreverse (cons '("") children)))
;; is this a valid start tag ?
(if (eq (char-after) ?>)
--- 228,234 ----
(if (looking-at "/>")
(progn
(forward-char 2)
! (nreverse children))
;; is this a valid start tag ?
(if (eq (char-after) ?>)