[s-xml-devel] support for the xml: namespace

Rudi Schlatte rudi at constantly.at
Thu Nov 17 13:14:00 UTC 2005


Hi,

This patch adds support for the xml: namespace, as per the xml  
namespace spec.  I /think/ I have commit rights, but would appreciate  
comments, especially of the "no, it's supposed to be done *that* way"  
variety.

Index: src/xml.lisp
===================================================================
RCS file: /project/s-xml/cvsroot/s-xml/src/xml.lisp,v
retrieving revision 1.13
diff -u -r1.13 xml.lisp
--- src/xml.lisp	6 Nov 2005 12:44:48 -0000	1.13
+++ src/xml.lisp	11 Nov 2005 13:39:38 -0000
@@ -154,15 +154,16 @@
              :initform nil))
    (:documentation "Describes an XML namespace and how it is handled"))
+(defmethod print-object ((object xml-namespace) stream)
+  (print-unreadable-object (object stream :type t :identity t)
+    (format stream "~A - ~A" (get-prefix object) (get-uri object))))
+
(defvar *local-namespace* (make-instance 'xml-namespace
                                           :uri "local"
                                           :prefix ""
                                           :package (find- 
package :keyword))
    "The local (global default) XML namespace")
-(defvar *known-namespaces* (list *local-namespace*)
-  "The list of known/defined namespaces")
-
(defun find-namespace (uri)
    "Find a registered XML namespace identified by uri"
    (find uri *known-namespaces* :key #'get-uri :test #'string-equal))
@@ -180,9 +181,6 @@
              *known-namespaces*))
      namespace))
-(defvar *namespaces* `(("" . ,*local-namespace*))
-  "Ordered list of (prefix . XML-namespace) bindings currently in  
effect - special variable")
-
(defun find-namespace-binding (prefix namespaces)
    "Find the XML namespace currently bound to prefix in the  
namespaces bindings"
    (cdr (assoc prefix namespaces :test #'string-equal)))
@@ -250,6 +248,18 @@
                            (if *auto-create-namespace-packages*
                                (make-package (string-upcase unique- 
name) :nicknames `(,unique-name))
                              (error "Cannot create package ~s"  
unique-name))))))
+
+;;; REC-xml-names-19990114 says: "The prefix xml is by definition
+;;; bound to the namespace name http://www.w3.org/XML/1998/namespace."
+(defvar *xml-namespace*
+  (new-namespace "http://www.w3.org/XML/1998/namespace" "xml"))
+
+(defvar *known-namespaces*
+  (list *local-namespace* *xml-namespace*)
+  "The list of known/defined namespaces")
+
+(defvar *namespaces* `(("xml" . ,*xml-namespace*) ("" . ,*local- 
namespace*))
+  "Ordered list of (prefix . XML-namespace) bindings currently in  
effect - special variable")
(defun extend-namespaces (attributes namespaces)
    "Given possible 'xmlns[:prefix]' attributes, extend the  
namespaces bindings"



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/s-xml-devel/attachments/20051117/c2b7003d/attachment.sig>


More information about the s-xml-devel mailing list