Add 2012 to FSF copyright years for Emacs files (do not merge to trunk)
[bpt/emacs.git] / lisp / nxml / rng-dt.el
CommitLineData
8cd39fb3
MH
1;;; rng-dt.el --- datatype library interface for RELAX NG
2
49f70d46 3;; Copyright (C) 2003, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
8cd39fb3
MH
4
5;; Author: James Clark
6;; Keywords: XML, RelaxNG
7
09aa73e6 8;; This file is part of GNU Emacs.
8cd39fb3 9
4936186e 10;; GNU Emacs is free software: you can redistribute it and/or modify
09aa73e6 11;; it under the terms of the GNU General Public License as published by
4936186e
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
8cd39fb3 14
09aa73e6
GM
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
4936186e 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
8cd39fb3
MH
22
23;;; Commentary:
24
25;;; Code:
26
27(require 'rng-util)
28
29(defvar rng-dt-error-reporter nil)
30
31(defun rng-dt-error (string &rest objs)
32 (if rng-dt-error-reporter
33 (apply rng-dt-error-reporter (cons string objs))
34 nil))
35
36(defvar rng-dt-namespace-context-getter nil
10545bd8
JB
37 "A list used by datatype libraries to expand names.
38The car of the list is a symbol which is the name of a function.
39This function is applied to the cdr of the list. The function must
40return a list whose car is the default namespace and whose cdr is an
41alist of (PREFIX . NAMESPACE) pairs, where PREFIX is a string and
42NAMESPACE is a symbol. This must be dynamically bound before calling
43a datatype library.")
8cd39fb3
MH
44
45(defsubst rng-dt-make-value (dt str)
46 (apply (car dt) (cons str (cdr dt))))
47
48(defun rng-dt-builtin-compile (name params)
49 (cond ((eq name 'string)
50 (if (null params)
51 '(t identity)
52 (rng-dt-error "The string datatype does not take any parameters")))
53 ((eq name 'token)
54 (if (null params)
55 '(t rng-collapse-space)
56 (rng-dt-error "The token datatype does not take any parameters")))
57 (t
58 (rng-dt-error "There is no built-in datatype %s" name))))
59
60(put (rng-make-datatypes-uri "") 'rng-dt-compile 'rng-dt-builtin-compile)
61
62(provide 'rng-dt)
63
ab4c34c6 64;; arch-tag: 1dca90f1-8dae-4dd4-b61f-fade4452c014
8cd39fb3 65;;; rng-dt.el ends here