]> code.delx.au - gnu-emacs/blobdiff - lisp/nxml/rng-loc.el
Merge from emacs-23
[gnu-emacs] / lisp / nxml / rng-loc.el
index b81bfe009f868a2d4ab924b166e12b4f576c99a3..5ba52c3e1236b6d753202eb3f0f1fd449e51f2a5 100644 (file)
@@ -1,24 +1,24 @@
 ;;; rng-loc.el --- locate the schema to use for validation
 
-;; Copyright (C) 2003 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: XML, RelaxNG
 
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2 of
-;; the License, or (at your option) any later version.
+;; This file is part of GNU Emacs.
 
-;; This program is distributed in the hope that it will be
-;; useful, but WITHOUT ANY WARRANTY; without even the implied
-;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-;; PURPOSE.  See the GNU General Public License for more details.
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
-;; You should have received a copy of the GNU General Public
-;; License along with this program; if not, write to the Free
-;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-;; MA 02111-1307 USA
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 (defvar rng-current-schema-file-name nil
   "Filename of schema being used for current buffer.
-Nil if using a vacuous schema.")
+It is nil if using a vacuous schema.")
 (make-variable-buffer-local 'rng-current-schema-file-name)
 
-(defvar rng-schema-locating-files-default nil
+(defvar rng-schema-locating-files-default
+  (list "schemas.xml" (expand-file-name "schema/schemas.xml" data-directory))
   "Default value for variable `rng-schema-locating-files'.")
 
-(defvar rng-schema-locating-file-schema-file nil
+(defvar rng-schema-locating-file-schema-file
+  (expand-file-name "schema/locate.rnc" data-directory)
   "File containing schema for schema locating files.")
 
 (defvar rng-schema-locating-file-schema nil
@@ -50,7 +52,7 @@ Nil if using a vacuous schema.")
   :type '(repeat file)
   :group 'relax-ng)
 
-(defvar rng-schema-loader-alist nil
+(defvar rng-schema-loader-alist '(("rnc" . rng-c-load-schema))
   "Alist of schema extensions vs schema loader functions.")
 
 (defvar rng-cached-document-element nil)
@@ -89,7 +91,7 @@ Nil if using a vacuous schema.")
 FILENAME must be the name of a file containing a schema.
 The extension of FILENAME is used to determine what kind of schema it
 is.  The variable `rng-schema-loader-alist' maps from schema
-extensions to schema loader functions. The function
+extensions to schema loader functions.  The function
 `rng-c-load-schema' is the loader for RELAX NG compact syntax.  The
 association is between the buffer and the schema: the association is
 lost when the buffer is killed."
@@ -115,7 +117,7 @@ lost when the buffer is killed."
          rng-any-element))
   (setq rng-current-schema-file-name filename)
   (run-hooks 'rng-schema-change-hook))
-  
+
 (defun rng-load-schema (filename)
   (let* ((extension (file-name-extension filename))
         (loader (cdr (assoc extension rng-schema-loader-alist))))
@@ -130,7 +132,7 @@ lost when the buffer is killed."
   "Display a message saying what schema `rng-validate-mode' is using."
   (interactive)
   (if rng-current-schema-file-name
-      (message "Using schema %s" 
+      (message "Using schema %s"
               (abbreviate-file-name rng-current-schema-file-name))
     (message "Using vacuous schema")))
 
@@ -186,7 +188,7 @@ If TYPE-ID is non-nil, then locate the schema for this TYPE-ID."
 (defun rng-locate-schema-file-using (files)
   "Locate a schema using the schema locating files FILES.
 FILES is a list of file-names.
-Return either a URI, a list (TYPE-ID) where TYPE-ID is a string
+Return either a URI, a list (TYPE-ID) where TYPE-ID is a string,
 or nil."
   (let (rules
        ;; List of types that override normal order-based
@@ -379,7 +381,7 @@ NS is t if the document has a non-nil, but not otherwise known namespace."
 
 (defun rng-locate-schema-file-from-type-id (type-id file)
   "Locate the schema for type id TYPE-ID using schema locating file FILE.
-Return either a URI, a list (TYPE-ID) where TYPE-ID is a string
+Return either a URI, a list (TYPE-ID) where TYPE-ID is a string,
 or nil."
   (let ((rules (rng-get-parsed-schema-locating-file file))
        schema rule)
@@ -423,7 +425,7 @@ or nil."
                   (cons (list file mtime parsed)
                         rng-schema-locating-file-alist)))
           parsed))))
-  
+
 (defconst rng-locate-namespace-uri
   (nxml-make-namespace "http://thaiopensource.com/ns/locating-rules/1.0"))
 
@@ -506,8 +508,7 @@ saved to the first writable file in `rng-schema-locating-files'."
                                         "schema location")
                                       file)))))
          (t
-          (save-excursion
-            (set-buffer (find-file-noselect file))
+          (with-current-buffer (find-file-noselect file)
             (let ((modified (buffer-modified-p)))
               (if (> (buffer-size) 0)
                   (let (xmltok-dtd)
@@ -545,4 +546,5 @@ saved to the first writable file in `rng-schema-locating-files'."
 
 (provide 'rng-loc)
 
+;; arch-tag: 725cf968-37a2-418b-b47b-d5209871a9ab
 ;;; rng-loc.el ends here