From scaekenberghe at common-lisp.net Fri Sep 2 14:38:41 2005 From: scaekenberghe at common-lisp.net (Sven Van Caekenberghe) Date: Fri, 2 Sep 2005 16:38:41 +0200 (CEST) Subject: [s-xml-cvs] CVS update: s-xml/src/xml.lisp Message-ID: <20050902143841.61103880DA@common-lisp.net> Update of /project/s-xml/cvsroot/s-xml/src In directory common-lisp.net:/tmp/cvs-serv32108/src Modified Files: xml.lisp Log Message: default namespaces without a prefix are now handled by creating a new, uniquely named package and the same prefix Date: Fri Sep 2 16:38:40 2005 Author: scaekenberghe Index: s-xml/src/xml.lisp diff -u s-xml/src/xml.lisp:1.10 s-xml/src/xml.lisp:1.11 --- s-xml/src/xml.lisp:1.10 Mon Aug 29 17:01:47 2005 +++ s-xml/src/xml.lisp Fri Sep 2 16:38:39 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: xml.lisp,v 1.10 2005/08/29 15:01:47 scaekenberghe Exp $ +;;;; $Id: xml.lisp,v 1.11 2005/09/02 14:38:39 scaekenberghe Exp $ ;;;; ;;;; This is a Common Lisp implementation of a basic but usable XML parser. ;;;; The parser is non-validating and not complete (no CDATA). @@ -232,6 +232,25 @@ (defvar *auto-create-namespace-packages* t "If t, new packages will be created for namespaces, if needed, named by the prefix") +(defun new-namespace (uri &optional prefix) + "Register a new namespace for uri and prefix, creating a package if necessary" + (if prefix + (register-namespace uri + prefix + (or (find-package prefix) + (if *auto-create-namespace-packages* + (make-package prefix :nicknames `(,(string-upcase prefix))) + (error "Cannot find or create package ~s" prefix)))) + (let ((unique-name (loop :for i :upfrom 0 + :do (let ((name (format nil "ns-~d" i))) + (when (not (find-package name)) + (return name)))))) + (register-namespace uri + unique-name + (if *auto-create-namespace-packages* + (make-package (string-upcase unique-name) :nicknames `(,unique-name)) + (error "Cannot create package ~s" unique-name)))))) + (defun extend-namespaces (attributes namespaces) "Given possible 'xmlns[:prefix]' attributes, extend the namespaces bindings" (unless *ignore-namespaces* @@ -246,19 +265,13 @@ (prefix name) (namespace (find-namespace uri))) (unless namespace - (setf namespace - (register-namespace uri - prefix - (or (find-package prefix) - (if *auto-create-namespace-packages* - (make-package prefix :nicknames `(,(string-upcase prefix))) - (error "Cannot find or create package ~s" prefix)))))) + (setf namespace (new-namespace uri prefix))) (push `(,prefix . ,namespace) namespaces)))))) (when default-namespace-uri (let ((namespace (find-namespace default-namespace-uri))) - (if namespace - (push `("" . namespace) namespaces) - (error "No prefix found for default namespace ~s" default-namespace-uri)))))) + (unless namespace + (setf namespace (new-namespace default-namespace-uri))) + (push `("" . ,namespace) namespaces))))) namespaces) (defun print-identifier (identifier stream &optional as-attribute) From scaekenberghe at common-lisp.net Thu Sep 8 15:39:31 2005 From: scaekenberghe at common-lisp.net (Sven Van Caekenberghe) Date: Thu, 8 Sep 2005 17:39:31 +0200 (CEST) Subject: [s-xml-cvs] CVS update: s-xml/src/xml.lisp Message-ID: <20050908153931.CEF988802E@common-lisp.net> Update of /project/s-xml/cvsroot/s-xml/src In directory common-lisp.net:/tmp/cvs-serv3812/src Modified Files: xml.lisp Log Message: bugfix (thx to carlos.ungil at bluewin.ch) Date: Thu Sep 8 17:39:29 2005 Author: scaekenberghe Index: s-xml/src/xml.lisp diff -u s-xml/src/xml.lisp:1.11 s-xml/src/xml.lisp:1.12 --- s-xml/src/xml.lisp:1.11 Fri Sep 2 16:38:39 2005 +++ s-xml/src/xml.lisp Thu Sep 8 17:39:29 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: xml.lisp,v 1.11 2005/09/02 14:38:39 scaekenberghe Exp $ +;;;; $Id: xml.lisp,v 1.12 2005/09/08 15:39:29 scaekenberghe Exp $ ;;;; ;;;; This is a Common Lisp implementation of a basic but usable XML parser. ;;;; The parser is non-validating and not complete (no CDATA). @@ -180,7 +180,7 @@ *known-namespaces*)) namespace)) -(defvar *namespaces* `(("" . *local-namespace*)) +(defvar *namespaces* `(("" . ,*local-namespace*)) "Ordered list of (prefix . XML-namespace) bindings currently in effect - special variable") (defun find-namespace-binding (prefix namespaces) From scaekenberghe at common-lisp.net Tue Sep 13 18:09:34 2005 From: scaekenberghe at common-lisp.net (Sven Van Caekenberghe) Date: Tue, 13 Sep 2005 20:09:34 +0200 (CEST) Subject: [s-xml-cvs] CVS update: s-xml/src/package.lisp Message-ID: <20050913180934.BE413880DE@common-lisp.net> Update of /project/s-xml/cvsroot/s-xml/src In directory common-lisp.net:/tmp/cvs-serv2248/src Modified Files: package.lisp Log Message: added split-identifier to exports Date: Tue Sep 13 20:09:34 2005 Author: scaekenberghe Index: s-xml/src/package.lisp diff -u s-xml/src/package.lisp:1.3 s-xml/src/package.lisp:1.4 --- s-xml/src/package.lisp:1.3 Tue Aug 30 12:37:06 2005 +++ s-xml/src/package.lisp Tue Sep 13 20:09:34 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: package.lisp,v 1.3 2005/08/30 10:37:06 scaekenberghe Exp $ +;;;; $Id: package.lisp,v 1.4 2005/09/13 18:09:34 scaekenberghe Exp $ ;;;; ;;;; This is a Common Lisp implementation of a very basic XML parser. ;;;; The parser is non-validating and not at all complete (no CDATA). @@ -34,7 +34,7 @@ #:*ignore-namespaces* #:*local-namespace* #:*namespaces* #:*require-existing-symbols* #:*auto-export-symbols* #:*auto-create-namespace-packages* #:find-namespace #:register-namespace - #:resolve-identifier #:extend-namespaces #:print-identifier) + #:resolve-identifier #:extend-namespaces #:print-identifier #:split-identifier) (:documentation "A simple XML parser with an efficient, purely functional, event-based interface as well as a DOM interface")) From scaekenberghe at common-lisp.net Tue Sep 20 09:57:49 2005 From: scaekenberghe at common-lisp.net (Sven Van Caekenberghe) Date: Tue, 20 Sep 2005 11:57:49 +0200 (CEST) Subject: [s-xml-cvs] CVS update: s-xml/src/lxml-dom.lisp s-xml/src/sxml-dom.lisp s-xml/src/xml-struct-dom.lisp Message-ID: <20050920095749.C19428815C@common-lisp.net> Update of /project/s-xml/cvsroot/s-xml/src In directory common-lisp.net:/tmp/cvs-serv26534/src Modified Files: lxml-dom.lisp sxml-dom.lisp xml-struct-dom.lisp Log Message: minor fix to XML pretty printing Date: Tue Sep 20 11:57:48 2005 Author: scaekenberghe Index: s-xml/src/lxml-dom.lisp diff -u s-xml/src/lxml-dom.lisp:1.4 s-xml/src/lxml-dom.lisp:1.5 --- s-xml/src/lxml-dom.lisp:1.4 Mon Aug 29 17:01:47 2005 +++ s-xml/src/lxml-dom.lisp Tue Sep 20 11:57:44 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: lxml-dom.lisp,v 1.4 2005/08/29 15:01:47 scaekenberghe Exp $ +;;;; $Id: lxml-dom.lisp,v 1.5 2005/09/20 09:57:44 scaekenberghe Exp $ ;;;; ;;;; LXML implementation of the generic DOM parser and printer. ;;;; @@ -75,7 +75,7 @@ (if (stringp child) (print-string-xml child stream) (print-xml-dom child input-type stream pretty (1+ level)))) - (when pretty (print-spaces (* 2 level) stream)))) + (when pretty (print-spaces (* 2 (1- level)) stream)))) (print-closing-tag tag stream)) (write-string "/>" stream))))) (t (error "Input not recognized as LXML ~s" dom)))) Index: s-xml/src/sxml-dom.lisp diff -u s-xml/src/sxml-dom.lisp:1.3 s-xml/src/sxml-dom.lisp:1.4 --- s-xml/src/sxml-dom.lisp:1.3 Mon Aug 29 17:01:47 2005 +++ s-xml/src/sxml-dom.lisp Tue Sep 20 11:57:48 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: sxml-dom.lisp,v 1.3 2005/08/29 15:01:47 scaekenberghe Exp $ +;;;; $Id: sxml-dom.lisp,v 1.4 2005/09/20 09:57:48 scaekenberghe Exp $ ;;;; ;;;; LXML implementation of the generic DOM parser and printer. ;;;; @@ -68,7 +68,7 @@ (if (stringp child) (print-string-xml child stream) (print-xml-dom child input-type stream pretty (1+ level)))) - (when pretty (print-spaces (* 2 level) stream)))) + (when pretty (print-spaces (* 2 (1- level)) stream)))) (print-closing-tag tag stream)) (write-string "/>" stream))))) (t (error "Input not recognized as SXML ~s" dom)))) Index: s-xml/src/xml-struct-dom.lisp diff -u s-xml/src/xml-struct-dom.lisp:1.2 s-xml/src/xml-struct-dom.lisp:1.3 --- s-xml/src/xml-struct-dom.lisp:1.2 Mon Aug 29 17:01:47 2005 +++ s-xml/src/xml-struct-dom.lisp Tue Sep 20 11:57:48 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: xml-struct-dom.lisp,v 1.2 2005/08/29 15:01:47 scaekenberghe Exp $ +;;;; $Id: xml-struct-dom.lisp,v 1.3 2005/09/20 09:57:48 scaekenberghe Exp $ ;;;; ;;;; XML-STRUCT implementation of the generic DOM parser and printer. ;;;; @@ -94,7 +94,7 @@ (if (stringp child) (print-string-xml child stream) (print-xml-dom child input-type stream pretty (1+ level)))) - (when pretty (print-spaces (* 2 level) stream)))) + (when pretty (print-spaces (* 2 (1- level)) stream)))) (print-closing-tag (xml-element-name xml-element) stream)) (write-string "/>" stream))))) From scaekenberghe at common-lisp.net Wed Sep 21 17:06:24 2005 From: scaekenberghe at common-lisp.net (Sven Van Caekenberghe) Date: Wed, 21 Sep 2005 19:06:24 +0200 (CEST) Subject: [s-xml-cvs] CVS update: s-xml/src/package.lisp Message-ID: <20050921170624.CDDF7880DE@common-lisp.net> Update of /project/s-xml/cvsroot/s-xml/src In directory common-lisp.net:/tmp/cvs-serv31377/src Modified Files: package.lisp Log Message: added some more exports Date: Wed Sep 21 19:06:24 2005 Author: scaekenberghe Index: s-xml/src/package.lisp diff -u s-xml/src/package.lisp:1.4 s-xml/src/package.lisp:1.5 --- s-xml/src/package.lisp:1.4 Tue Sep 13 20:09:34 2005 +++ s-xml/src/package.lisp Wed Sep 21 19:06:24 2005 @@ -1,6 +1,6 @@ ;;;; -*- mode: lisp -*- ;;;; -;;;; $Id: package.lisp,v 1.4 2005/09/13 18:09:34 scaekenberghe Exp $ +;;;; $Id: package.lisp,v 1.5 2005/09/21 17:06:24 scaekenberghe Exp $ ;;;; ;;;; This is a Common Lisp implementation of a very basic XML parser. ;;;; The parser is non-validating and not at all complete (no CDATA). @@ -33,7 +33,7 @@ ;; namespaces #:*ignore-namespaces* #:*local-namespace* #:*namespaces* #:*require-existing-symbols* #:*auto-export-symbols* #:*auto-create-namespace-packages* - #:find-namespace #:register-namespace + #:find-namespace #:register-namespace #:get-prefix #:get-uri #:get-package #:resolve-identifier #:extend-namespaces #:print-identifier #:split-identifier) (:documentation "A simple XML parser with an efficient, purely functional, event-based interface as well as a DOM interface"))