(defgroup reftex): Update home page url-link.
[bpt/emacs.git] / lisp / xml.el
index 444b8c6..ca8f5bd 100644 (file)
@@ -1,7 +1,7 @@
 ;;; xml.el --- XML parser
 
 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Emmanuel Briot  <briot@gnat.com>
 ;; Maintainer: Mark A. Hershberger <mah@everybody.org>
@@ -165,22 +165,19 @@ If FILE is already visited, use its buffer and don't kill it.
 Returns the top node with all its children.
 If PARSE-DTD is non-nil, the DTD is parsed rather than skipped.
 If PARSE-NS is non-nil, then QNAMES are expanded."
-  (let ((keep))
-    (if (get-file-buffer file)
-       (progn
-         (set-buffer (get-file-buffer file))
-         (setq keep (point)))
-      (let (auto-mode-alist)           ; no need for xml-mode
-       (find-file file)))
-
-    (let ((xml (xml-parse-region (point-min)
-                                (point-max)
-                                (current-buffer)
-                                parse-dtd parse-ns)))
-      (if keep
-         (goto-char keep)
-       (kill-buffer (current-buffer)))
-      xml)))
+  (if (get-file-buffer file)
+      (with-current-buffer (get-file-buffer file)
+       (save-excursion
+         (xml-parse-region (point-min)
+                           (point-max)
+                           (current-buffer)
+                           parse-dtd parse-ns)))
+    (with-temp-buffer
+      (insert-file-contents file)
+      (xml-parse-region (point-min)
+                       (point-max)
+                       (current-buffer)
+                       parse-dtd parse-ns))))
 
 
 (defvar xml-name-re)
@@ -306,16 +303,16 @@ is not well-formed XML.
 If PARSE-DTD is non-nil, the DTD is parsed rather than skipped,
 and returned as the first element of the list.
 If PARSE-NS is non-nil, then QNAMES are expanded."
-  (save-excursion
-    (if buffer
-       (set-buffer buffer))
-    (save-restriction
-      (narrow-to-region beg end)
-      ;; Use fixed syntax table to ensure regexp char classes and syntax
-      ;; specs DTRT.
-      (with-syntax-table (standard-syntax-table)
-       (let ((case-fold-search nil)    ; XML is case-sensitive.
-             xml result dtd)
+  ;; Use fixed syntax table to ensure regexp char classes and syntax
+  ;; specs DTRT.
+  (with-syntax-table (standard-syntax-table)
+    (let ((case-fold-search nil)       ; XML is case-sensitive.
+         xml result dtd)
+      (save-excursion
+       (if buffer
+           (set-buffer buffer))
+       (save-restriction
+         (narrow-to-region beg end)
          (goto-char (point-min))
          (while (not (eobp))
            (if (search-forward "<" nil t)