cxml.asd has been split up into cxml.asd for the
From dlichteblau at common-lisp.net Sat Jun 16 09:52:15 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 05:52:15 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml/test
Message-ID: <20070616095215.9864916011@common-lisp.net>
Update of /project/cxml/cvsroot/cxml/test
In directory clnet:/tmp/cvs-serv30886/test
Modified Files:
domtest.lisp
Log Message:
DTC patch-dom
o translate-uri-equals: should work on all CL implementations, not
just the Allegro CL because 'puri' is used for compatibility.
--- /project/cxml/cvsroot/cxml/test/domtest.lisp 2006/08/20 11:48:58 1.17
+++ /project/cxml/cvsroot/cxml/test/domtest.lisp 2007/06/16 09:52:15 1.18
@@ -274,13 +274,6 @@
(with-attributes (|type|) element
`(equal ,|type| "text/xml")))
-#-allegro
-(defun translate-uri-equals (element)
- (declare (ignore element))
- (warn "oops, assert-uri-equals needs Franz' URI package")
- (throw 'give-up nil))
-
-#+allegro
(defun translate-uri-equals (element)
(with-attributes
(|actual|
From dlichteblau at common-lisp.net Sat Jun 16 10:02:44 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 06:02:44 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml/xml
Message-ID: <20070616100244.16F7D4D052@common-lisp.net>
Update of /project/cxml/cvsroot/cxml/xml
In directory clnet:/tmp/cvs-serv2346
Modified Files:
unparse.lisp
Log Message:
DTC patch-rune
o make-string-sink/utf8, make-character-stream-sink/utf8: these functions
are not needed when compiling with the :rune-is-character feature.
--- /project/cxml/cvsroot/cxml/xml/unparse.lisp 2007/06/16 09:42:06 1.14
+++ /project/cxml/cvsroot/cxml/xml/unparse.lisp 2007/06/16 10:02:43 1.15
@@ -110,10 +110,10 @@
#+rune-is-character
(define-maker make-character-stream-sink make-character-stream-ystream stream)
- ;; #-rune-is-character
+ #-rune-is-character
(define-maker make-string-sink/utf8 make-string-ystream/utf8)
- ;; #-rune-is-character
+ #-rune-is-character
(define-maker make-character-stream-sink/utf8
make-character-stream-ystream/utf8
stream))
From dlichteblau at common-lisp.net Sat Jun 16 10:03:11 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 06:03:11 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml/test
Message-ID: <20070616100311.90AA558333@common-lisp.net>
Update of /project/cxml/cvsroot/cxml/test
In directory clnet:/tmp/cvs-serv2457
Modified Files:
xmlconf.lisp
Log Message:
DTC patch-xmlconf
o dribble-tests: 'run-all-tests require the parser function.
--- /project/cxml/cvsroot/cxml/test/xmlconf.lisp 2007/02/18 14:35:16 1.14
+++ /project/cxml/cvsroot/cxml/test/xmlconf.lisp 2007/06/16 10:03:11 1.15
@@ -66,14 +66,14 @@
(read-sequence result s )
result)))
-(defun dribble-tests (directory)
+(defun dribble-tests (parser-fn directory)
(let ((base (slot-value (asdf:find-system :cxml) 'asdf::relative-pathname)))
(with-open-file (*standard-output*
(merge-pathnames "XMLCONF" base)
:direction :output
:external-format :iso-8859-1
:if-exists :supersede)
- (run-all-tests directory))))
+ (run-all-tests parser-fn directory))))
(defvar *parser-fn* 'sax-test)
From dlichteblau at common-lisp.net Sat Jun 16 11:07:58 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 07:07:58 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml/doc
Message-ID: <20070616110758.55B531B000@common-lisp.net>
Update of /project/cxml/cvsroot/cxml/doc
In directory clnet:/tmp/cvs-serv16419/doc
Modified Files:
index.xml xmls-compat.xml
Log Message:
XMLS compatibility is not bug-for-bug-compatible with
XMLS any more. There is now a mode using pairs of local name
and namespace URI, and a second mode using qualified names
only. The old behaviour using pairs of prefix and local names
was removed. (Thanks to Douglas Crosher.)
--- /project/cxml/cvsroot/cxml/doc/index.xml 2007/06/16 09:42:06 1.9
+++ /project/cxml/cvsroot/cxml/doc/index.xml 2007/06/16 11:07:58 1.10
@@ -61,6 +61,13 @@
- Serialization no longer defaults to canonical form.
- Fixed octet array argument to make-source.
+ -
+ XMLS compatibility is not bug-for-bug-compatible with
+ XMLS any more. There is now a mode using pairs of local name
+ and namespace URI, and a second mode using qualified names
+ only. The old behaviour using pairs of prefix and local names
+ was removed. (Thanks to Douglas Crosher.)
+
rel-2007-05-26
--- /project/cxml/cvsroot/cxml/doc/xmls-compat.xml 2007/02/18 12:35:50 1.1
+++ /project/cxml/cvsroot/cxml/doc/xmls-compat.xml 2007/06/16 11:07:58 1.2
@@ -16,7 +16,28 @@
DOM functions cannot be implemented on them.
-
Function CXML-XMLS:MAKE-XMLS-BUILDER (&key include-default-values)
+ New namespace handling:
+ XMLS compatibility is not bug-for-bug-compatible with
+ XMLS any more. There is now a mode using pairs of local name
+ and namespace URI, and a second mode using qualified names
+ only. The old behaviour using pairs of prefix and local names
+ was removed.
+
+
+
+ fixme: It is unclear to me how namespaces are meant to
+ work in xmls, since xmls documentation differs from how xmls
+ actually works in current releases. Usually applications need to
+ know both the namespace prefix and the namespace URI. We
+ currently follow the xmls implementation and use the
+ namespace prefix instead of following its documentation which
+ shows the URI. We do not follow xmls in munging xmlns attribute
+ values. Attributes themselves have namespaces and it is not clear
+ to me how that works in xmls.
+
+
+
+
Function CXML-XMLS:MAKE-XMLS-BUILDER (&key include-default-values include-namespace-uri)
Create a SAX handler which builds XMLS list structures.
If include-default-values is true, default values for
attributes declared in a DTD are included as attributes in the
@@ -25,11 +46,18 @@
values.
+ If include-namespace-uri is true (the default), node
+ names and attribute names are pairs of local name and namespace
+ URI. (Except for attributes without a namespace, which are named
+ using a string.) Otherwise, nodes and attributes are named by
+ their qualified name.
+
+
Example:
(cxml:parse-file "test.xml" (cxml-xmls:make-xmls-builder))
-
Function CXML-XMLS:MAP-NODE (handler node &key include-xmlns-attributes)
+ Function CXML-XMLS:MAP-NODE (handler node &key include-xmlns-attributes include-namespace-uri)
Traverse an XMLS document/node and call SAX functions as if an XML
representation of the document were processed by a SAX parser.
@@ -52,17 +80,6 @@
and namespace prefix ns.
- fixme: It is unclear to me how namespaces are meant to
- work in xmls, since xmls documentation differs from how xmls
- actually works in current releases. Usually applications need to
- know both the namespace prefix and the namespace URI. We
- currently follow the xmls implementation and use the
- namespace prefix instead of following its documentation which
- shows the URI. We do not follow xmls in munging xmlns attribute
- values. Attributes themselves have namespaces and it is not clear
- to me how that works in xmls.
-
-
Accessor CXML-XMLS:NODE-NAME (node)
Accessor CXML-XMLS:NODE-NS (node)
Accessor CXML-XMLS:NODE-ATTRS (node)
From dlichteblau at common-lisp.net Sat Jun 16 11:07:59 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 07:07:59 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml/xml
Message-ID: <20070616110759.29DC01F009@common-lisp.net>
Update of /project/cxml/cvsroot/cxml/xml
In directory clnet:/tmp/cvs-serv16419/xml
Modified Files:
xmlns-normalizer.lisp xmls-compat.lisp
Log Message:
XMLS compatibility is not bug-for-bug-compatible with
XMLS any more. There is now a mode using pairs of local name
and namespace URI, and a second mode using qualified names
only. The old behaviour using pairs of prefix and local names
was removed. (Thanks to Douglas Crosher.)
--- /project/cxml/cvsroot/cxml/xml/xmlns-normalizer.lisp 2006/08/20 14:59:35 1.3
+++ /project/cxml/cvsroot/cxml/xml/xmlns-normalizer.lisp 2007/06/16 11:07:58 1.4
@@ -34,7 +34,7 @@
(make-instance 'namespace-normalizer
:xmlns-stack (list (mapcar (lambda (cons)
(make-xmlns-attribute (car cons) (cdr cons)))
- *namespace-bindings*))
+ *initial-namespace-bindings*))
:chained-handler chained-handler))
(defun normalizer-find-prefix (handler prefix)
@@ -74,7 +74,6 @@
(defmethod sax:start-element
((handler namespace-normalizer) uri lname qname attrs)
- (declare (ignore qname))
(when (null uri)
(setf uri #""))
(let ((normal-attrs '()))
@@ -85,8 +84,12 @@
(push a normal-attrs)))
(flet ((push-namespace (prefix uri)
(let ((new (make-xmlns-attribute prefix uri)))
- (push new (car (xmlns-stack handler)))
- (push new attrs))))
+ (unless (find (sax:attribute-qname new)
+ attrs
+ :test #'rod=
+ :key #'sax:attribute-qname)
+ (push new (car (xmlns-stack handler)))
+ (push new attrs)))))
(multiple-value-bind (prefix local-name) (split-qname qname)
(setf lname local-name)
(let ((binding (normalizer-find-prefix handler prefix)))
--- /project/cxml/cvsroot/cxml/xml/xmls-compat.lisp 2006/05/15 21:57:47 1.3
+++ /project/cxml/cvsroot/cxml/xml/xmls-compat.lisp 2007/06/16 11:07:58 1.4
@@ -69,32 +69,50 @@
(root :initform nil :accessor root)
(include-default-values :initform t
:initarg :include-default-values
- :accessor include-default-values)))
-
-(defun make-xmls-builder (&key (include-default-values t))
- (make-instance 'xmls-builder :include-default-values include-default-values))
+ :accessor include-default-values)
+ (include-namespace-uri :initform t
+ :initarg :include-namespace-uri
+ :accessor include-namespace-uri)))
+
+(defun make-xmls-builder (&key (include-default-values t)
+ (include-namespace-uri t))
+ "Make a XMLS style builder. When 'include-namespace-uri is true a modified
+ XMLS tree is generated that includes the element namespace URI rather than
+ the qualified name prefix and also includes the namespace URI for attributes."
+ (make-instance 'xmls-builder
+ :include-default-values include-default-values
+ :include-namespace-uri include-namespace-uri))
(defmethod sax:end-document ((handler xmls-builder))
(root handler))
(defmethod sax:start-element
((handler xmls-builder) namespace-uri local-name qname attributes)
- (declare (ignore namespace-uri))
- (setf local-name (or local-name qname))
- (let* ((attributes
+ (let* ((include-default-values (include-default-values handler))
+ (include-namespace-uri (include-namespace-uri handler))
+ (attributes
(loop
for attr in attributes
- when (or (sax:attribute-specified-p attr)
- (include-default-values handler))
+ for attr-namespace-uri = (sax:attribute-namespace-uri attr)
+ for attr-local-name = (sax:attribute-local-name attr)
+ when (and (or (sax:attribute-specified-p attr)
+ include-default-values)
+ #+(or)
+ (or (not include-namespace-uri)
+ (not attr-namespace-uri)
+ attr-local-name))
collect
- (list (sax:attribute-qname attr)
+ (list (cond (include-namespace-uri
+ (cond (attr-namespace-uri
+ (cons attr-local-name attr-namespace-uri))
+ (t
+ (sax:attribute-qname attr))))
+ (t
+ (sax:attribute-qname attr)))
(sax:attribute-value attr))))
+ (namespace (when include-namespace-uri namespace-uri))
(node (make-node :name local-name
- :ns (let ((lq (length qname))
- (ll (length local-name)))
- (if (eql lq ll)
- nil
- (subseq qname 0 (- lq ll 1))))
+ :ns namespace
:attrs attributes))
(parent (car (element-stack handler))))
(if parent
@@ -129,34 +147,100 @@
(defun map-node
(handler node
- &key (include-xmlns-attributes sax:*include-xmlns-attributes*))
+ &key (include-xmlns-attributes sax:*include-xmlns-attributes*)
+ (include-namespace-uri t))
+ (if include-namespace-uri
+ (map-node/lnames (cxml:make-namespace-normalizer handler)
+ node
+ include-xmlns-attributes)
+ (map-node/qnames handler node include-xmlns-attributes)))
+
+(defun map-node/lnames (handler node include-xmlns-attributes)
+ (sax:start-document handler)
+ (labels ((walk (node)
+ (unless (node-ns node)
+ (error "serializing with :INCLUDE-NAMESPACE-URI, but node ~
+ was created without namespace URI"))
+ (let* ((attlist
+ (compute-attributes/lnames node include-xmlns-attributes))
+ (uri (node-ns node))
+ (lname (node-name node))
+ (qname lname) ;let the normalizer fix it
+ )
+ (sax:start-element handler uri lname qname attlist)
+ (dolist (child (node-children node))
+ (typecase child
+ (list (walk child))
+ ((or string rod)
+ (sax:characters handler (string-rod child)))))
+ (sax:end-element handler uri lname qname))))
+ (walk node))
+ (sax:end-document handler))
+
+(defun map-node/qnames (handler node include-xmlns-attributes)
(sax:start-document handler)
(labels ((walk (node)
+ (when (node-ns node)
+ (error "serializing without :INCLUDE-NAMESPACE-URI, but node ~
+ was created with a namespace URI"))
(let* ((attlist
- (compute-attributes node include-xmlns-attributes))
- (lname (rod (node-name node)))
- (qname (if (node-ns node)
- (concatenate 'rod
- (rod (node-ns node))
- (rod ":")
- lname)
- lname)))
+ (compute-attributes/qnames node include-xmlns-attributes))
+ (qname (string-rod (node-name node)))
+ (lname (nth-value 1 (cxml::split-qname qname))))
(sax:start-element handler nil lname qname attlist)
(dolist (child (node-children node))
(typecase child
(list (walk child))
- ((or string rod) (sax:characters handler (rod child)))))
+ ((or string rod)
+ (sax:characters handler (string-rod child)))))
(sax:end-element handler nil lname qname))))
(walk node))
(sax:end-document handler))
-(defun compute-attributes (node xmlnsp)
+(defun compute-attributes/lnames (node xmlnsp)
+ (remove nil
+ (mapcar (lambda (a)
+ (destructuring-bind (name value) a
+ (unless (listp name)
+ (setf name (cons name nil)))
+ (destructuring-bind (lname &rest uri) name
+ (cond
+ ((not (equal uri "http://www.w3.org/2000/xmlns/"))
+ (sax:make-attribute
+ ;; let the normalizer fix the qname
+ :qname (if uri
+ (string-rod (concatenate 'string
+ "dummy:"
+ lname))
+ (string-rod lname))
+ :local-name (string-rod lname)
+ :namespace-uri uri
+ :value (string-rod value)
+ :specified-p t))
+ (xmlnsp
+ (sax:make-attribute
+ :qname (string-rod
+ (if lname
+ (concatenate 'string "xmlns:" lname)
+ "xmlns"))
+ :local-name (string-rod lname)
+ :namespace-uri uri
+ :value (string-rod value)
+ :specified-p t))))))
+ (node-attrs node))))
+
+(defun compute-attributes/qnames (node xmlnsp)
(remove nil
(mapcar (lambda (a)
(destructuring-bind (name value) a
- (if (or xmlnsp (not (cxml::xmlns-attr-p (rod name))))
- (sax:make-attribute :qname (rod name)
- :value (rod value)
+ (when (listp name)
+ (error "serializing without :INCLUDE-NAMESPACE-URI, ~
+ but attribute was created with a namespace ~
+ URI"))
+ (if (or xmlnsp
+ (not (cxml::xmlns-attr-p (string-rod name))))
+ (sax:make-attribute :qname (string-rod name)
+ :value (string-rod value)
:specified-p t)
nil)))
(node-attrs node))))
From dlichteblau at common-lisp.net Sat Jun 16 11:27:18 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 07:27:18 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml
Message-ID: <20070616112718.0289C19005@common-lisp.net>
Update of /project/cxml/cvsroot/cxml
In directory clnet:/tmp/cvs-serv20513
Modified Files:
cxml.asd runes.asd
Log Message:
SCL support (thanks to Douglas Crosher). Includes support for
implementations where URIs are valid namestrings, and a mode
where normal streams are used instead of xstreams and ystreams
(albeit both SCL-specific at this point).
--- /project/cxml/cvsroot/cxml/cxml.asd 2007/05/26 21:55:57 1.18
+++ /project/cxml/cvsroot/cxml/cxml.asd 2007/06/16 11:27:18 1.19
@@ -4,6 +4,9 @@
(defclass closure-source-file (cl-source-file) ())
+#+scl
+(pushnew 'uri-is-namestring *features*)
+
#+sbcl
(defmethod perform :around ((o compile-op) (s closure-source-file))
;; shut up already. Correctness first.
@@ -30,7 +33,7 @@
(:file "space-normalizer" :depends-on ("xml-parse"))
(:file "catalog" :depends-on ("xml-parse"))
(:file "sax-proxy" :depends-on ("xml-parse")))
- :depends-on (:runes :puri :trivial-gray-streams))
+ :depends-on (:runes :puri #-scl :trivial-gray-streams))
(defclass utf8dom-file (closure-source-file) ((of)))
--- /project/cxml/cvsroot/cxml/runes.asd 2007/05/26 22:05:13 1.1
+++ /project/cxml/cvsroot/cxml/runes.asd 2007/06/16 11:27:18 1.2
@@ -52,7 +52,9 @@
#+rune-is-character "characters")
#+rune-is-integer (:file "utf8")
(:file "syntax")
- (:file "encodings")
- (:file "encodings-data")
- (:file "xstream")
- (:file "ystream")))
+ #-x&y-streams-are-stream (:file "encodings")
+ #-x&y-streams-are-stream (:file "encodings-data")
+ #-x&y-streams-are-stream (:file "xstream")
+ #-x&y-streams-are-stream (:file "ystream")
+ #+x&y-streams-are-stream (:file #+scl "stream-scl")
+ ))
From dlichteblau at common-lisp.net Sat Jun 16 11:27:19 2007
From: dlichteblau at common-lisp.net (dlichteblau)
Date: Sat, 16 Jun 2007 07:27:19 -0400 (EDT)
Subject: [cxml-cvs] CVS cxml/doc
Message-ID: <20070616112719.3F4921B000@common-lisp.net>
Update of /project/cxml/cvsroot/cxml/doc
In directory clnet:/tmp/cvs-serv20513/doc
Modified Files:
index.xml
Log Message:
SCL support (thanks to Douglas Crosher). Includes support for
implementations where URIs are valid namestrings, and a mode
where normal streams are used instead of xstreams and ystreams
(albeit both SCL-specific at this point).
--- /project/cxml/cvsroot/cxml/doc/index.xml 2007/06/16 11:07:58 1.10
+++ /project/cxml/cvsroot/cxml/doc/index.xml 2007/06/16 11:27:19 1.11
@@ -68,6 +68,12 @@
only. The old behaviour using pairs of prefix and local names
was removed. (Thanks to Douglas Crosher.)
+