From 5363dadbb8ca443011a31053e95f2308ad6a2450 Mon Sep 17 00:00:00 2001
From: dlichteblau
Date: Sun, 11 Dec 2005 23:56:45 +0000
Subject: [PATCH] namespace normalization
---
README.html | 7 +-
cxml.asd | 1 +
doc/using.html | 75 ++++++++++++++--------
dom/dom-impl.lisp | 24 +++----
dom/unparse.lisp | 2 +
xml/package.lisp | 3 +-
xml/sax-proxy.lisp | 2 +
xml/xmlns-normalizer.lisp | 130 ++++++++++++++++++++++++++++++++++++++
8 files changed, 205 insertions(+), 39 deletions(-)
create mode 100644 xml/xmlns-normalizer.lisp
diff --git a/README.html b/README.html
index c00dd22..93cd5ef 100644
--- a/README.html
+++ b/README.html
@@ -90,7 +90,12 @@
Recent Changes
rel-2005-xx-yy
- - Implemented DOM 2 Core.
+ -
+ Implemented DOM 2 Core.
+ (A handler for DOM 3-style namespace normalization is provided and
+ used by default for serialization of DOM documents if namespace
+ support is enabled.)
+
-
Error handling overhaul: All syntax errors should now be
reported as instances of well-formedness-violation. We
diff --git a/cxml.asd b/cxml.asd
index b8d5d9d..550ef58 100644
--- a/cxml.asd
+++ b/cxml.asd
@@ -68,6 +68,7 @@
(:file "unparse" :depends-on ("xml-parse"))
(:file "xmls-compat" :depends-on ("xml-parse"))
(:file "recoder" :depends-on ("xml-parse"))
+ (:file "xmlns-normalizer" :depends-on ("xml-parse"))
(:file "catalog" :depends-on ("xml-parse"))
(:file "sax-proxy" :depends-on ("xml-parse")))
:depends-on (:cxml-runes :puri :trivial-gray-streams))
diff --git a/doc/using.html b/doc/using.html
index f31ae5e..c651d4a 100644
--- a/doc/using.html
+++ b/doc/using.html
@@ -155,12 +155,6 @@
(an URI object).
-
-
Function DOM:MAKE-DOM-BUILDER ()
- Create a SAX handler which builds a DOM document. Example:
-
- (cxml:parse-file "test.xml" (dom:make-dom-builder))
-
Condition class CXML:XML-PARSE-ERROR ()
Superclass of all conditions signalled by the CXML parser.
@@ -183,7 +177,8 @@
Function CXML:UNPARSE-DOCUMENT (document stream &rest keys)
Function CXML:UNPARSE-DOCUMENT-TO-OCTETS (document &rest keys) => vector
- Serialize a DOM document object.
+ Serialize a DOM document object. These convenience functions are
+ wrappers around dom:map-document.
- document -- a DOM document object
@@ -223,6 +218,10 @@
changes the document model and should only be used if whitespace
does not matter to the application.
+
+ If namespace support is enabled (the default), these functions use
+ a namespace normalizer (cxml:make-namespace-normalizer).
+
unparse-document-to-octets returns an (unsigned-byte
8) array, whereas unparse-document writes
@@ -247,7 +246,7 @@
-
Macro CXML:WITH-XML-OUTPUT (sink &body body) => vector
+ Macro CXML:WITH-XML-OUTPUT (sink &body body) => sink-specific result
Macro CXML:WITH-ELEMENT (qname &body body) => result
Function CXML:ATTRIBUTE (name value) => value
Function CXML:TEXT (data) => data
@@ -319,12 +318,6 @@
(x (parse-dtd-file "~/test.dtd")))
(dom:map-document (cxml:make-validator x #"foo") d))
-
-
Function DOM:MAP-DOCUMENT (handler document &key include-xmlns-attributes include-default-values)
- Traverse a DOM document and call SAX functions as if an XML
- representation of the document were processed by a SAX parser.
-
-
Class CXML:SAX-PROXY ()
Accessor CXML:PROXY-CHAINED-HANDLER
@@ -338,6 +331,17 @@
handler unmodified.
+
+
Accessor CXML:MAKE-NAMESPACE-NORMALIZER (next-handler)
+
+
+ Return a SAX handler that performs DOM
+ 3-style namespace normalization on Attribute lists in
+ start-element events before passing them on the next
+ handler.
+
+
XMLS Compatibility
@@ -649,19 +653,45 @@ NIL
DOM Notes
- CXML implements the DOM Level 2 Core interfaces. Explaining
- DOM is better left to the specification,
- so please refer to the official W3C documents for DOM.
+ CXML implements the DOM Level 2 Core interfaces. For details
+ on DOM, please refer to the specification.
- However, there is no "standard" DOM mapping for Lisp. DOM
+ However, note that there is no "standard" DOM mapping for Lisp. DOM
is specified
in CORBA IDL, but it refrains from using object-oriented IDL
features, allowing for a much more natural Lisp implemenation than
- the the ordinary IDL/Lisp mapping would.
+ the the ordinary IDL/Lisp mapping would. The mapping chosen for
+ cxml is explained below.
+
+ Example
+
XML(97): (dom:node-type
+ (dom:document-element
+ (cxml:parse-file "~/test.xml" (dom:make-dom-builder))))
+:ELEMENT
+
+ CXML-specific functions
+
+
Function DOM:MAKE-DOM-BUILDER ()
+ Create a SAX handler which builds a DOM document. Example:
+
+ (cxml:parse-file "test.xml" (dom:make-dom-builder))
+
+
+
Function DOM:MAP-DOCUMENT (handler document &key include-xmlns-attributes include-default-values)
+ Traverse a DOM document and call SAX functions as if an XML
+ representation of the document were processed by a SAX parser.
+
+
+ dom:map-document is the low-level building-block used to
+ implement the serialization functions
+ like unparse-document, but can also be used directly.
+
+
+ DOM/Lisp mapping
Differences between CXML's DOM and the direct IDL/Lisp mapping:
@@ -715,10 +745,5 @@ NIL
dom:do-node-list, which can be implemented portably.
- Example:
- XML(97): (dom:node-type
- (dom:document-element
- (cxml:parse-file "~/test.xml" (dom:make-dom-builder))))
-:ELEMENT