...
 
Commits (216)
--- orig/xml/xml-parse.lisp
+++ mod/xml/xml-parse.lisp
@@ -525,7 +525,10 @@
(declaim (type (simple-array rune (*))
*scratch-pad* *scratch-pad-2* *scratch-pad-3* *scratch-pad-4*))
-(defmacro with-scratch-pads (() &body body)
+(defmacro with-scratch-pads (#-clisp ()
+ ;; clisp does not allow () as macro argument list
+ #+clisp (&key &allow-other-keys)
+ &body body)
`(let ((*scratch-pad* (make-array 1024 :element-type 'rune))
(*scratch-pad-2* (make-array 1024 :element-type 'rune))
(*scratch-pad-3* (make-array 1024 :element-type 'rune))
Preamble to the Gnu Lesser General Public License
Closure XML -- a Common Lisp XML parser
Copyright (c) 1999 by Gilbert Baumann
Copyright (c) 2003 by Henrik Motakef
Copyright (c) 2004 knowledgeTools Int. GmbH
Copyright (c) 2004,2005 David Lichteblau
Copyright (c) 2000 Franz Incorporated, Berkeley, CA 94704
Preamble to the Gnu Lesser General Public License
The concept of the GNU Lesser General Public License version 2.1
("LGPL") has been adopted to govern the use and distribution of
......
This diff is collapsed.
......@@ -4,5 +4,4 @@ all:
.PHONY: clean
clean:
touch dummy.fasl
find . \( -name \*.fasl -o -name \*.x86f \) -print0 | xargs -0 rm
find . \( -name \*.fasl -o -name \*.x86f -o -name \*.lx64fsl \) -print0 | xargs -0 rm -f
Changes to Gilbert Baumann's Code
========================================
(Stand dieser Liste: patch-54)
base-0
Import of Closure's src/xml and src/glisp
Build system
----------------
patch-14
dom-builder.lsp braucht package.lisp
patch-17
xml-parse braucht dom-impl
patch-18
xml-parse braucht encodings
patch-19
xml-parse.lisp needs xml-stream.lisp
Interface changes
----------------
patch-2
export UNPARSE-DOCUMENT
Portability issues
----------------
patch-1
ACL port aktualisiert
patch-8
fixed more mlisp breakage
DOM fixes
----------------
patch-3
add dom:remove-child, dom:import-node
patch-6
fixed dom:remove-child
patch-7
strings->rods in set-attribute, too
patch-21
dom:item und dom:length fuer NodeList implementiert
patch-22
s/remove-atttribute/remove-attribute
patch-23
dom:remove-attribute-node korrigiert
patch-24
neu: dom:remove-attribute
patch-25
dom:normalize implementiert
patch-26
get-elements-by-tag-name fuer Element implementiert
patch-32
s/data/value/ fuer CHARACTER-DATA
patch-33
Aufruf von Setter-Methoden
patch-34
(setf value) nachgetragen
patch-35
(DOM:NODE-VALUE ATTRIBUTE) korrigiert
patch-36
writer fuer DOM:DATA
patch-37
(setf dom:node-value) implementiert
patch-43
hack: implemented CHILD-NODES for ENTITY-REFERENCE
patch-44
ENTITY-REFERENCE-Kinder als read-only markieren
patch-45
DOM-EXCEPTION implementiert
patch-46
fixed special cases in delete-data and replace-data
patch-47
delete-data: Arraytyp korrigiert
patch-48
DOM:INSERT-DATA implementiert
patch-49
bugfix: replace-data for count != (length arg)
patch-50
patch-46 nachgebessert: offset == length ist OK
patch-51
fixed special cases in dom:substring-data
patch-52
fixed patch-36, my (setf dom:data) implementation was bogus
xml-parse.lisp changes
----------------
patch-5
(assert (eql initial-speed 1)) in make-xstream
patch-20
added a forward declaration for *namespace-bindings*
patch-39
fix for thread safety in p/document
patch-41
Warnung ueber (nicht) redefinierte Attribute abschalten koennen
patch-54
call sax:comment; create comment nodes
String-Handling
----------------
patch-4
renamed dom to cdom, added string-dom
patch-38
diverse setter nachgetragen
Misc.
----------------
patch-9
print elements with their tag-name
patch-11
print attributes with name and value
patch-10
(reverted by patch-10)
patch-12
REVERT patch-10
domtest.cl
----------------
patch-27
alle DOM Level 1 CORE Tests uebersetzen koennen (mehr schlecht als recht)
patch-28
so, jetzt kompilieren die DOM-Tests auch (wenngleich zwei drittel noch fehlschlagen)
patch-29
einzelnen Test ausfuehren koennen
patch-30
<length/> workaround
patch-31
<equals/> fuer nicht-Strings
patch-40
?
patch-42
implementationAttribute-Probleme zwar ausgeben, aber kein WARN machen
patch-53
domtest fixes fuer <var/> und <nodeType>
xmlconf.cl
----------------
patch-13
Testfunktion fuer XML Conformance Test Suite
patch-15
run only tests for namespace-aware XML-1.0 parsers
patch-16
mit korrektem OUTPUT abgleichen
Closure XML Parser
An XML parser written in Common Lisp.
Closure XML was written by Gilbert Baumann (unk6 at
rz.uni-karlsruhe.de) as part of the Closure web browser.
Contributions to the parser by
* Henrik Motakef (hmot at henrik-motakef.de)
* David Lichteblau (david@lichteblau.com)
CXML implements a namespace-aware, validating XML 1.0 parser
as well as the DOM Level 2 Core interfaces. Two parser interfaces
are offered, one SAX-like, the other similar to StAX.
CXML is licensed under Lisp-LGPL.
Send bug reports to cxml-devel@common-lisp.net
(http://common-lisp.net/cgi-bin/mailman/listinfo/cxml-devel)
Documentation
Please refer to http://common-lisp.net/project/cxml/ for details.
The documentation is also available in the doc/ subdirectory of this
source distribution, run `make' in that directory to build HTML
for the XML sources (requires xsltproc).
<html>
<body>
<h1>Closure XML Parser</h1>
<p>An XML parser written in Common Lisp.</p>
<p>
Closure XML was written by <a
href="http://www.stud.uni-karlsruhe.de/~unk6/">Gilbert Baumann</a>
(unk6 at rz.uni-karlsruhe.de) as part of the Closure web
browser.<br>
Contributions to the parser by
<ul>
<li>
Henrik Motakef (hmot at henrik-motakef.de)<br>
(SAX layer; namespace support)
</li>
<li>
David Lichteblau at knowledgeTools &lt;david@knowledgetools.de&gt;<br>
(conversion into an independent package; DOM bug fixing)
</li>
</ul>
</p>
<p>
<h2>CXML Modules</h2>
CXML provides three packages:
<ul>
<li>
<tt>RUNES</tt>, a portable implementation of Unicode strings.
</li>
<li>
<tt>XML</tt>, a namespace-aware SAX parser implementing the <a
href="http://www.w3.org/TR/2000/REC-xml-20001006">XML 1.0
specification</a>.
</li>
<li>
<tt>DOM</tt>, an implementation of the <a
href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">DOM
Level 1 Core</a> interfaces.
</li>
</ul>
</p>
<p>
<h2>Installation</h2>
<b>Prerequisites.</b> CXML is written in Common Lisp and should be
portable to all Common Lisp implementations.&nbsp; Currently known
to work are ACL, SBCL, CMUCL, and CLISP. (<i>fixme</i>: check
this list)
</p>
</p>
<a href="http://www.cliki.net/asdf">ASDF</a> is used for
compilation. These instructions assume that ASDF has already been
loaded. (Some Lisps include ASDF, for example SBCL and any Lisp
on Debian and Gentoo. For other Lisps please load asdf.lisp
manually before proceeding.)
</p>
<p>
<b>Configuration (optional).</b>
CXML has full Unicode code support -- even on Lisps without
Unicode strings. On non-unicode aware Lisps, <tt>DOMString</tt>
is implemented as an array of character codes. If your Lisp
supports 16 bit characters natively, you can enable feature
<tt>RUNE-IS-CHARACTER</tt> to select an alternative
<tt>DOMString</tt> implementatation, which uses real characters
instead of characters codes.
<pre> * (pushnew :rune-is-character *features*)</pre>
</p>
<p>
<b>Compiling and loading CXML.</b>
Register the .asd file, e.g. by symlinking it:
<pre> $ ln -sf `pwd`/cxms.asd /path/to/your/registry</pre>
Compile CXML using:
<pre> * (asdf:operate 'asdf:load-op :cxml)</pre>
</p>
<p>
<h2>Tests</h2>
Check out the XML and DOM testsuites:
<pre> $ export CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public
$ cvs login # password is "anonymous"
$ cvs co 2001/XML-Test-Suite/xmlconf
$ cvs co 2001/DOM-Test-Suite</pre>
Run all applicable tests using:
<pre> * (xmlconf:run-all-tests "/path/to/2001/XML-Test-Suite/xmlconf/")
* (domtest:run-all-tests "/path/to/2001/2001/DOM-Test-Suite/")</pre>
(As always in Lisp, the trailing slash is significant.)
<p>
</p>
<i>fixme</i>: Add an explanation of xml/sax-tests here.
</p>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,57 +2,118 @@
(:use :asdf :cl))
(in-package :cxml-system)
(cerror "continue anyway"
"You're still using the CVS version of cxml, which
has been moved to git. Please use
git clone git://repo.or.cz/cxml.git
instead. (Select the restart to continue anyway.)")
(defclass dummy-cxml-component () ())
(defmethod asdf:component-name ((c dummy-cxml-component))
:cxml)
;; force loading of closure-common.asd, which installs *FEATURES* this
;; file depends on. Use MISSING-DEPENDENCY for asdf-install.
(unless (find-system :closure-common nil)
(error 'missing-dependency
:required-by (make-instance 'dummy-cxml-component)
:version nil
:requires :closure-common))
(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.
(handler-bind ((sb-ext:compiler-note #'muffle-warning))
(call-next-method)))
(let (#+sbcl (*compile-print* nil))
(call-next-method))))
(asdf:defsystem :cxml-xml
:default-component-class closure-source-file
:pathname (merge-pathnames
"xml/"
(make-pathname :name nil :type nil :defaults *load-truename*))
:components
((:file "package")
(:file "util" :depends-on ("package"))
(:file "sax-handler")
(:file "xml-name-rune-p" :depends-on ("package" "util"))
(:file "split-sequence" :depends-on ("package"))
(:file "xml-parse" :depends-on ("package" "util" "sax-handler" "split-sequence" "xml-name-rune-p"))
(: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 "space-normalizer" :depends-on ("xml-parse"))
(:file "catalog" :depends-on ("xml-parse"))
(:file "sax-proxy" :depends-on ("xml-parse")))
:depends-on (:closure-common :puri #-scl :trivial-gray-streams))
(defclass utf8dom-file (closure-source-file) ((of)))
(unless (find-package :glisp)
(defpackage :glisp))
(defmethod output-files ((operation compile-op) (c utf8dom-file))
(let* ((normal (car (call-next-method)))
(name (concatenate 'string (pathname-name normal) "-utf8")))
(list (make-pathname :name name :defaults normal))))
(defsystem glisp
;; must be an extra method because of common-lisp-controller's :around method
(defmethod output-files :around ((operation compile-op) (c utf8dom-file))
(let ((x (call-next-method)))
(setf (slot-value c 'of) (car x))
x))
(defmethod perform ((o load-op) (c utf8dom-file))
(load (slot-value c 'of)))
(defmethod perform ((operation compile-op) (c utf8dom-file))
(let ((*features* (cons 'utf8dom-file *features*))
(*readtable*
(symbol-value (find-symbol "*UTF8-RUNES-READTABLE*"
:closure-common-system))))
(call-next-method)))
(asdf:defsystem :cxml-dom
:default-component-class closure-source-file
:pathname (merge-pathnames
"glisp/"
"dom/"
(make-pathname :name nil :type nil :defaults *load-truename*))
:components
((:file dependent
:pathname
#+CLISP "dep-clisp"
#+(AND :CMU (NOT :PTHREAD)) "dep-cmucl"
#+sbcl "dep-sbcl"
#+(AND :CMU :PTHREAD) "dep-cmucl-dtc"
#+(and allegro allegro-v5.0) "dep-acl5"
#+(and allegro (not allegro-v5.0)) "dep-acl"
#+GCL "dep-gcl"
#-(or sbcl CLISP CMU allegro GCL) #.(error "Configure!"))
(:file "package"
:depends-on (dependent))
(:file "runes"
:depends-on ("package" dependent))
(:file "util"
:depends-on ("package" dependent "runes"))
(:file "match"
:depends-on ("package" dependent "runes" "util"))))
((:file "package")
(:file rune-impl :pathname "dom-impl" :depends-on ("package"))
(:file rune-builder :pathname "dom-builder" :depends-on (rune-impl))
#+rune-is-integer
(utf8dom-file utf8-impl :pathname "dom-impl" :depends-on ("package"))
#+rune-is-integer
(utf8dom-file utf8-builder :pathname "dom-builder" :depends-on (utf8-impl))
(:file "dom-sax" :depends-on ("package")))
:depends-on (:cxml-xml))
(asdf:defsystem :cxml
(asdf:defsystem :cxml-klacks
:default-component-class closure-source-file
:pathname (merge-pathnames
"cxml/"
"klacks/"
(make-pathname :name nil :type nil :defaults *load-truename*))
:serial t
:components
((:file "package")
(:file "encodings" :depends-on ("package"))
(:file "encodings-data" :depends-on ("package" "encodings"))
(:file "sax-handler")
(:file "dompack")
(:file "dom-impl" :depends-on ("dompack"))
(:file "dom-builder" :depends-on ("dom-impl" "sax-handler"))
(:file "xml-stream" :depends-on ("package"))
(:file "xml-name-rune-p" :depends-on ("package"))
(:file "xml-parse" :depends-on ("package" "dompack" "sax-handler"))
(:file "xml-canonic" :depends-on ("package" "dompack" "xml-parse")))
:depends-on (:glisp))
(:file "klacks")
(:file "klacks-impl")
(:file "tap-source"))
:depends-on (:cxml-xml))
(asdf:defsystem :cxml-test
:default-component-class closure-source-file
:pathname (merge-pathnames
"test/"
(make-pathname :name nil :type nil :defaults *load-truename*))
:components ((:file "domtest") (:file "xmlconf"))
:depends-on (:cxml-xml :cxml-klacks :cxml-dom))
(asdf:defsystem :cxml
:components ()
:depends-on (:cxml-dom :cxml-klacks :cxml-test))
#!/bin/sh
cd $(dirname $0)
home=$(pwd)
name=$(basename $home)
dir=${name}-$(date --iso)
TMPDIR=`mktemp -d /tmp/dist.XXXXXXXXXX`
cleanup() {
cd
rm -rf $TMPDIR
}
trap cleanup exit
cd $TMPDIR
cvs -d "`cat $home/CVS/Root`" export -r HEAD -d "$dir" "$name"
make -C $dir/doc
tgz=$TMPDIR/${dir}.tgz
tar czf $tgz $dir
gpg -b -a $tgz
mv $tgz $tgz.asc $home/
all: dom.html index.html installation.html klacks.html quickstart.html sax.html xmls-compat.html
%.html: %.xml html.xsl
xsltproc html.xsl $< >$@.tmp
mv $@.tmp $@
chmod -w $@
div.sidebar {
float: right;
min-width: 15%;
padding: 0pt 5pt 5pt 5pt;
font-family: verdana, arial;
}
div.sidebar-title {
font-weight: bold;
background-color: #9c0000;
border: solid #9c0000;
border-top-width: 1px;
border-bottom-width: 2px;
border-left-width: 4px;
border-right-width: 0px;
padding-left: 1px;
margin: 0em 2pt 0px 2em;
}
div.sidebar-title a {
color: #ffffff;
}
div.sidebar-main {
background-color: #f7f7f7;
border: solid #9c0000;
border-top-width: 0px;
border-bottom-width: 0px;
border-left-width: 4px;
border-right-width: 0px;
margin: 0em 2pt 1em 2em;
padding: 1em;
}
div.sidebar ul.main {
padding: 0pt 0pt 0pt 1em;
margin: 0 0 1em;
}
div.sidebar ul.sub {
list-style-type: square;
padding: 0pt 0pt 0pt 1em;
margin: 0 0 1em;
}
div.sidebar ul.hack {
padding: 0 0 0 0;
margin: 0 0 1em;
list-style-type: none;
}
body {
color: #000000;
background-color: #ffffff;
margin-right: 0pt;
margin-bottom: 10%;
margin-left: 40px;
padding-left: 30px;
font-family: verdana, arial;
background-image: url(bg.png);
background-position: top left;
background-attachment: fixed;
background-repeat: no-repeat;
}
h1 {
margin-left: -30px;
}
h2,h3 {
margin-left: -30px;
margin-top: 2em;
}
pre {
background-color: #eeeeee;
border: solid 1px #d0d0d0;
padding: 1em;
margin-right: 10%;
}
.def {
background-color: #ddddff;
font-weight: bold;
}
.nomargin {
margin-bottom: 0;
margin-top: 0;
}
<documentation title="CXML W3C DOM">
<h1>W3C DOM</h1>
<p>
CXML implements the DOM Level 2 Core interfaces.&#160; For details
on DOM, please refer to the <a
href="http://www.w3.org/TR/DOM-Level-2-Core/core.html">specification</a>.
</p>
<a name="parser"/>
<h3>Parsing into DOM</h3>
<p>
To parse an XML document into a DOM tree, use the SAX parser with a
DOM builder as the SAX handler. Example:
</p>
<pre>(cxml:parse-file "test.xml" (cxml-dom:make-dom-builder))</pre>
<p>
<div class="def">Function CXML-DOM:MAKE-DOM-BUILDER ()</div>
Create a SAX handler which builds a DOM document.
<p>
</p>
This functions returns a DOM builder that will work with the default
configuration of the SAX parser and is guaranteed to use
characters/strings instead of runes/rods, if that makes a
difference on the Lisp in question.
<p>
</p>
This is the same as <tt>rune-dom:make-dom-builder</tt> on Lisps
with Unicode support, and the same as
<tt>utf8-dom:make-dom-builder</tt> otherwise.
</p>
<p>
<div class="def">Function RUNE-DOM:MAKE-DOM-BUILDER ()</div>
Create a SAX handler which builds a DOM document using runes and rods.
</p>
<p>
<div class="def">Function UTF8-DOM:MAKE-DOM-BUILDER ()</div>
(Only on Lisps without Unicode support:)
Create a SAX handler which builds a DOM document using
UTF-8-encoded strings.
</p>
<a name="serialization"/>
<h3>Serializing DOM</h3>
<p>
To serialize a DOM document, use a SAX serialization sink as the
argument to <tt>dom:map-document</tt>, which generates SAX events
for the DOM tree.
</p>
<p>
Applications dealing with namespaces might want to inject a
<a href="sax.html#misc">namespace normalizer</a> into the
sink chain.
</p>
<p>
<div class="def">Function DOM:MAP-DOCUMENT (handler document &amp;key include-xmlns-attributes include-default-values include-doctype)</div>
Traverse a DOM document and call SAX functions as if an XML
representation of the document was processed by a SAX parser.
</p>
<p>Keyword arguments:</p>
<ul>
<li>
<tt>include-xmlns-attributes</tt> -- defaults to
<tt>sax:*include-xmlns-attributes*</tt>
</li>
<li>
<tt>include-doctype</tt> -- One of <tt>nil</tt> (no doctype
declaration), <tt>:full-internal-subset</tt> (include a doctype
declaration and the full internal subset), or
<tt>:canonical-notations</tt> (write a doctype declaration
with an internal subset including only notations, as required
for canonical serialization).
</li>
<li>
<tt>include-default-values</tt> -- include attribute nodes with nil
<tt>dom:specified</tt>.
</li>
<li>
<tt>recode</tt> -- (ignored on Lisps with Unicode support.) If
true, recode UTF-8 strings to rods. Defaults to true if used
with a UTF-8 DOM document. It can be set to false manually to
suppress recoding in this case.
</li>
</ul>
<a name="mapping"/>
<h3>DOM/Lisp mapping</h3>
<p>
Note that there is no "standard" DOM mapping for Lisp.
</p>
<p>
DOM is <a
href="http://www.w3.org/TR/DOM-Level-2-Core/idl-definitions.html">specified
in CORBA IDL</a>, 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.&#160;
Differences between CXML's DOM and the direct IDL/Lisp mapping:
</p>
<ul>
<li>
DOM function names are symbols in the <tt>DOM</tt> package (not
the <tt>OP</tt> package).
</li>
<li>
DOM functions have proper required arguments, not a huge
<tt>&amp;rest</tt> lambda list.
</li>
<li>
Although most IDL interfaces are implemented as CLOS classes by
CXML, the Lisp types of DOM objects is not documented and cannot
be relied upon.&#160; A node's type can be determined using
<tt>dom:node-type</tt> instead.
</li>
<li>
<tt>DOMString</tt> is mapped to <tt>rod</tt>, which is either
an <tt>(unsigned-byte 16)</tt> array type or a string type.
</li>
<li>
The IDL/Lisp mapping maps CORBA enums to Lisp keywords.&#160;
Unfortunately, the DOM IDL does not use enums.&#160; Instead,
both exception types and node types are defined integer
constants.&#160; CXML chooses to ignore this definition and uses
keywords instead.
</li>
<li>
DOM uses StudlyCaps.&#160; Lisp programmers don't.&#160; We
insert <tt>#\-</tt> before every upper case letter preceded by a
lower case letter and before every upper case letter which is
followed by a lower case letter, but preceded by a capital
letter.&#160; This algorithms leads to the natural Lisp spelling
of DOM function names.
</li>
<li>
Implementation note: DOM's <tt>NodeList</tt> does not
necessarily map to a native "sequence" type.&#160; (For example,
node lists are objects in Java, not arrays.)&#160;
<tt>NodeList</tt> is specified to reflect changes done after a
node list was created, so node lists cannot be Lisp lists.&#160;
(A node list could be implemented as a CLOS object pointing to
said list though.)&#160; Instead, CXML currently implements node
lists as adjustable vectors.&#160; Note that code which relies on
this implementation and uses Lisp sequence functions
instead of sticking to <tt>dom:item</tt> and <tt>dom:length</tt>
is not portable.&#160; As a compromise, you can use our
extensions <tt>dom:map-node-list</tt> or
<tt>dom:do-node-list</tt>, which can be implemented portably.
</li>
</ul>
</documentation>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="documentation">
<html>
<head>
<title>
<xsl:value-of select="@title"/>
</title>
<link rel="stylesheet" type="text/css" href="cxml.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div class="sidebar">
<div class="sidebar-title">
<a href="index.html">Closure XML</a>
</div>
<div class="sidebar-main">
<ul class="main">
<li>
<a href="installation.html">Installing Closure XML</a>
<ul class="sub">
<li><a href="installation.html#download"><b>Download</b></a></li>
<li><a href="installation.html#implementations">Implementation-specific notes</a></li>
<li><a href="installation.html#compilation">Compilation</a></li>
<li><a href="installation.html#tests">Tests</a></li>
</ul>
</li>
<li>
<ul class="hack">
<li>
<a href="quickstart.html"><b>Quick-Start Example / FAQ</b></a>
</li>
</ul>
</li>
<li>
<a href="sax.html">SAX parsing and serialization</a>
<ul class="sub">
<li><a href="sax.html#parser">Parsing and Validating</a></li>
<li><a href="sax.html#serialization">Serialization</a></li>
<li><a href="sax.html#misc">Miscellaneous SAX handlers</a></li>
<li><a href="sax.html#rods">Recoders</a></li>
<li><a href="sax.html#dtdcache">Caching of DTD Objects</a></li>
<li><a href="sax.html#catalogs">XML Catalogs</a></li>
<li><a href="sax.html#sax">SAX Interface</a></li>
</ul>
</li>
<li>
<a href="klacks.html">Klacks parser</a>
<ul class="sub">
<li><a href="klacks.html#sources">Parsing incrementally</a></li>
<li><a href="klacks.html#convenience">Convenience functions</a></li>
<li><a href="klacks.html#klacksax">Bridging Klacks and SAX</a></li>
<li><a href="klacks.html#locator">Location information</a></li>
<li><a href="klacks.html#klacksax">Examples</a></li>
</ul>
</li>
<li>
<a href="dom.html">DOM implementation</a>
<ul class="sub">
<li><a href="dom.html#parser">Parsing with the DOM builder</a></li>
<li><a href="dom.html#serialization">Serialization</a></li>
<li><a href="dom.html#mapping">DOM/Lisp mapping</a></li>
</ul>
</li>
<li>
<ul class="hack">
<li><a href="xmls-compat.html">XMLS Builder</a></li>
</ul>
</li>
</ul>
</div>
</div>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="page-index">
<ul>
<xsl:for-each select="//heading">
<li>
<a href="#{generate-id()}">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="heading">
<a name="{generate-id()}"/>
<h3>
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</h3>
</xsl:template>
</xsl:stylesheet>
<documentation title="Closure XML">
<h1>Closure XML Parser</h1>
<p>An XML parser written in Common Lisp.</p>
<p>
Closure XML was written
by <a href="http://www.stud.uni-karlsruhe.de/~unk6/">Gilbert
Baumann</a> as part of the Closure web browser and is now
maintained by
<a href="mailto:david@lichteblau.com">David Lichteblau</a>.
It is licensed under Lisp-LGPL.
</p>
<p>
CXML implements a <a
href="http://www.w3.org/TR/REC-xml-names/">namespace-aware</a>,
validating <a
href="http://www.w3.org/TR/2000/REC-xml-20001006">XML&#160;1.0</a>
parser as well as the <a
href="http://www.w3.org/TR/DOM-Level-2-Core/">DOM&#160;Level&#160;2&#160;Core</a>
interfaces. Two parser interfaces are offered, one SAX-like, the
other similar to StAX.
</p>
<p>
Send bug reports to <a
href="mailto:cxml-devel@common-lisp.net">cxml-devel@common-lisp.net</a>
(<a
href="http://common-lisp.net/cgi-bin/mailman/listinfo/cxml-devel">list
information</a>).
</p>
<h3>Add-on features</h3>
<p>
The following libraries are available as separate downloads:
</p>
<ul style="list-style-type: square">
<li>
<a href="http://www.lichteblau.com/cxml-rng/">cxml-rng</a>:
Relax NG validation
</li>
<li>
<a href="http://www.lichteblau.com/cxml-stp/">cxml-stp</a>:
STP, an alternative to DOM
</li>
<li>
<a href="http://common-lisp.net/project/plexippus-xpath/">Plexippus</a>:
XPath 1.0
</li>
<!--
<li>
<a href="http://repo.or.cz/w/xuriella.git">Xuriella</a>:
XSLT 1.0 (work in progress)
</li>
-->
<li>
<a href="http://common-lisp.net/project/closure/closure-html/">Closure
HTML</a>:
parse HTML 4; convert between HTML and XHTML
</li>
</ul>
<a name="changes"/>
<h3>Recent Changes</h3>
<p class="nomargin"><tt>rel-2007-10-21</tt></p>
<ul class="nomargin">
<li>
Lisps using full 21 bit code points as characters are now fully
supported (including SBCL and Clozure CL) addition to the
existing support for 16 bit characters using UTF-16 (including
Allegro and LispWorks). The feature <tt>rune-is-utf-16</tt> is
now set on 16 bit Lisps.<br/><br/> Make sure to update and
recompile both cxml and closure-common when upgrading.
</li>
<li>
New sink slot omit-xml-declaration-p; functions cxml:unescaped
and sax:unescaped.
</li>
<li>
Added XPath support to the XMLS compatibility model.
</li>
<li>
Fixed various DTD serialization bugs. Fixed xmls compatibility
bugs. Fixed variable names in with-source. Fixed
klacks-error export. Consistently use strings as base URIs.
Fixed PARSE for non-file-streams.
</li>
</ul>
<div style="background-color: #f7f7f7;
width: 60%;
border: solid #9c0000;
margin: 0em 2pt 1em 2em;
padding: 1em">
Runes have now been moved into
a <b>separate CVS module</b> unter the
name <b>closure-common</b>. Releases will be available
as <b>separate tarballs</b> in the download directory. Please
refer to the <a href="installation.html#download">
installation instructions</a> for details.
</div>
<p class="nomargin"><tt>rel-2007-10-21</tt></p>
<ul class="nomargin">
<li>
Moved runes into a separate project.
</li>
<li>
Incompatible SAX changes: Added new classes
sax:abstract-handler, sax:content-handler, sax:default-handler.
Implementations of SAX handlers should now subclass one of
these classes.
</li>
<li>
fixed make-source :buffering nil, thanks to Magnus Henoch for
the report
</li>
<li>
fixed time and space usage in cases where entity references
follow each other (thanks to Ivan Shvedunov for the report)
</li>
<li>
In the DOM builder, grow a buffer for string normalization
exponentially, fixing a long-standing speed issue.
</li>
</ul>
<p class="nomargin"><tt>rel-2007-08-05</tt></p>
<ul class="nomargin">
<li>Various DTD serialization fixes</li>
<li>UTF-8 fix, thanks to Francis Leboutte</li>
</ul>
<p class="nomargin"><tt>rel-2007-07-07</tt></p>
<ul class="nomargin">
<li>
Fixed build on non-Unicode lisps. Fixed parsing on
non-Unicode lisps. Fixed Unicode detection on OpenMCL.
</li>
<li>New function <tt>cxml:parse</tt>.</li>
<li>Serialization no longer defaults to canonical form.</li>
<li>Fixed octet array argument to make-source.</li>
<li>
XMLS compatibility is not <i>bug-for-bug</i>-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.)
</li>
<li>
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).
</li>
<li>new convenience serialization function cxml:doctype. Various
DTD serialization fixes.</li>
</ul>
<p class="nomargin"><tt>rel-2007-05-26</tt></p>
<ul class="nomargin">
<li>cxml.asd has been split up into <tt>cxml.asd</tt> for the
XML parser and <tt>runes.asd</tt> for the runes package, in
preparation of a complete split of the two systems. Future CXML
releases will use separate tarballs for <tt>runes</tt>
and <tt>cxml</tt>.</li>
<li>xml:base support (SAX and Klacks only, not yet used in DOM).
See documentation <a href="sax.html#saxparser">here</a> and <a
href="klacks.html#locator">here</a>.</li>
<li>New class <tt>broadcast-handler</tt> as a generalization
of the older <tt>sax-proxy</tt>.</li>
<li>New class <tt>tapping-source</tt>, a klacks source that
relays events from an upstream klacks source unchanged, while also
emitting them as SAX events to a user-specified handler at the
same time.</li>
<li>Changed attributes to carry an lname even when occurring
without a namespace. Added new functions attribute*,
unparse-attribute, and macro with-element*, with-namespace* to
the SAX generation wrapper API.</li>
<li>Klacks improvements: Incompatibly changed
klacks:find-element and find-event to consider the current event
as a result. Added klacks-error, klacks:expect, klacks:skip,
klacks:expecting-element. Fixed serialize-event to generate
start-prefix-mapping and end-prefix-mapping events. New function
map-current-namespace-declarations.</li>
<li>fixed build with common-lisp-controller</li>
</ul>
<p class="nomargin"><tt>rel-2007-02-18</tt></p>
<ul class="nomargin">
<li>New StAX-like parser interface.</li>
<li>Serialization fixes (thanks to Nathan Bird, Donavon Keithley).</li>
<li>characters.lisp cleanup (thanks to Nathan Bird).</li>
<li>Namespace normalizer bugfixes.</li>
<li>Minor changes: clone-node on document as an extension. DOM
class hierarchy reworked. New function parse-empty-document.
Fixed the DOM serializer to not throw away local names.
Fixed a long-standing bug in the parser for documents without a
doctype. ANSI conformance fixes.</li>
</ul>
<p class="nomargin"><tt>rel-2006-01-05</tt></p>
<ul class="nomargin">
<li>Implemented DOM 2 Core.</li>
<li>Error handling overhaul.</li>
<li>UTF-8 string support in DOM on Lisps without Unicode characters.</li>
<li>Sink API has been changed.</li>
<li>Support internal subset serialization.</li>
<li>Whitespace normalizer.</li>
<li>Gilbert Baumann has clarified the license as Lisp-LGPL.</li>
<li>Use trivial-gray-streams.</li>
</ul>
<p class="nomargin"><tt>rel-2005-06-25</tt></p>
<ul class="nomargin">
<li>Port to OpenMCL (thanks to Rudi Schlatte).</li>
<li>Port to LispWorks (thanks to Edi Weitz).</li>
<li>Minor new features: <tt>include-default-values</tt> argument to
<tt>make-xmls-builder</tt>; <tt>handler</tt> argument
to <tt>parse-dtd-stream</tt>; SAX proxy class</li>
<li>Various bugfixes.</li>
</ul>
<p class="nomargin"><tt>patch-357</tt> (2004-10-10)</p>
<ul class="nomargin">
<li>Auto-detect unicode support for better asdf-installability.</li>
<li>Use the puri library for Sys-ID handling.</li>
<li>Semi-automatic caching of DTD instances.</li>
<li>Support user-defined entity resolvers.</li>
<li>Support for Oasis XML Catalogs.</li>
<li>xhtmlgen version of Franz htmlgen.</li>
<li>Fixes for SBCL's unicode support.</li>
</ul>
<p class="nomargin"><tt>patch-306</tt> (2004-09-03)</p>
<ul class="nomargin">
<li>Event-based serialization which does not require DOM documents</li>
<li>XMLS compatiblity</li>
<li>minor bugfixes (thread safety; should work on clisp again)</li>
</ul>
<p class="nomargin"><tt>patch-279</tt> (2004-05-11)</p>
<ul class="nomargin">
<li>Validation</li>
<li>bugfixes; XHTML DTD parses again; corrected SAX entity handling</li>
</ul>
<p class="nomargin"><tt>patch-204</tt></p>
<ul class="nomargin">
<li>Renamed package <tt>XML</tt> to <tt>CXML</tt>.</li>
<li>The unparse functions support non-canonical output now.</li>
</ul>
<p class="nomargin"><tt>patch-191</tt> (2004-03-18)</p>
<ul class="nomargin">
<li>Initial release.</li>
</ul>
</documentation>
<documentation title="CXML Installation">
<h1>Installation of Closure XML</h1>
<a name="download"/>
<h2>Download</h2>
<ul>
<li>
<div>Download <a href="http://common-lisp.net/project/cxml/download/">tarballs</a> for both cxml itself and closure-common.</div>
</li>
<li>
<div>
Or use anonymous CVS (<a href="http://common-lisp.net/cgi-bin/viewcvs.cgi/cxml/?cvsroot=cxml">browse</a>):
<pre>export CVSROOT=:pserver:anonymous:anonymous@common-lisp.net:/project/cxml/cvsroot
cvs co cxml
cvs co closure-common</pre>
</div>
</li>
</ul>
<a name="implementations"/>
<h2>Implementation-specific notes</h2>
<p>
CXML should be portable to all Common Lisp implementations
supported by <a
href="http://common-lisp.net/project/cl-plus-ssl/#trivial-gray-streams">trivial-gray-streams</a>.
</p>
<p>
On Lisps without Unicode support, cxml uses integers instead of
characters to represent code points internally. By default,
however, the parser will recode all data to strings containing
characters representing UTF-8 bytes before passing it to user
code.
</p>
<a name="compilation"/>
<h2>Compilation</h2>
<p>
<a href="http://www.cliki.net/asdf">ASDF</a> is used for
compilation. The following instructions assume that ASDF has
already been loaded.
</p>
<p>
<b>Prerequisites.</b>
CXML needs <a href="http://www.cliki.net/Puri">puri</a> and
<a href="http://www.common-lisp.net/project/cl-plus-ssl/#trivial-gray-streams">trivial-gray-streams</a>.
In addition,
<a href="http://www.cliki.net/closure-common">closure-common</a>
is required, which is a separate module in cxml CVS (see above for
check-out instructions).
</p>
<p>
<b>Compiling and loading CXML.</b>
Register the .asd file, e.g. by symlinking it:
</p>
<pre>$ ln -sf `pwd`/cxml/cxml.asd /path/to/your/registry/
$ ln -sf `pwd`/closure-common/closure-common.asd /path/to/your/registry/</pre>
<p>Then compile CXML using:</p>
<pre>* (asdf:operate 'asdf:load-op :cxml)</pre>
<p>
You can then try the <a href="quickstart.html">quick-start example</a>.
</p>
<a name="tests"/>
<h2>Tests</h2>
<p>Check out the XML and DOM testsuites:</p>
<pre>$ export CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public
$ cvs login # password is "anonymous"
$ cvs co 2001/XML-Test-Suite/xmlconf
$ cvs co -D '2005-05-06 23:00' 2001/DOM-Test-Suite
$ cd 2001/DOM-Test-Suite &amp;&amp; ant dom1-dtd dom2-dtd</pre>
<p>
Omit <tt>-D</tt> to get the latest version, which may not work
with cxml yet. The <tt>ant</tt> step is necessary to run the DOM
tests.
</p>
<p>Usage:</p>
<pre>* (xmlconf:run-all-tests "/path/to/2001/XML-Test-Suite/xmlconf/")
* (domtest:run-all-tests "/path/to/2001/DOM-Test-Suite/")
</pre>
<p>
To compare your results with known output, refer to the files
<tt>XMLCONF</tt> and <tt>DOMTEST</tt> in the cxml distribution.
</p>
<p>
<i>fixme</i>: Add an explanation of xml/sax-tests here.
</p>
<p>
<b>fixme</b> domtest.lisp does not understand the current
testsuite driver anymore.&#160; To fix this problem, revert the
affected files manually after check-out:
</p>
<pre>$ cd 2001/XML-Test-Suite/xmlconf/
xmltest$ patch -p0 -R &lt;/path/to/cxml/test/xmlconf-base.diff</pre>
<p>
The log message for the changes reads "<i>Removed unnecessary
xml:base attribute</i>".&#160; If I understand correctly, only
DOM&#160;3 parsers provide the baseURI attribute necessary for
understanding <tt>xmlconf.xml</tt> now.&#160; We don't have that
yet.
</p>
</documentation>
This diff is collapsed.
<documentation title="CXML Quick-Start Example">
<h1>Quick-Start Example / FAQ</h1>
<p>
Make sure to <a href="installation.html#installation">install and load</a> cxml first.
</p>
<h3>
On this page
</h3>
<page-index/>
<p>
To try the following examples, create a test file
called <tt>example.xml</tt>:
</p>
<pre>* <b>(with-open-file (s "example.xml" :direction :output)
(write-string "&lt;test a='b'&gt;&lt;child/&gt;&lt;/test>" s))</b></pre>
<heading>Parsing a file</heading>
<p>Parse <tt>example.xml</tt> into a DOM tree (<a href="sax.html#parser">read
more</a>):</p>
<pre>* <b>(cxml:parse-file "example.xml" (cxml-dom:make-dom-builder))</b>
#&lt;DOM-IMPL::DOCUMENT @ #x72206172>
;; save result for later:
* <b>(defparameter *example* *)</b>
*EXAMPLE*</pre>
<heading>Using DOM</heading>
<p>Inspect the DOM tree (<a href="sax.html#dom">read more</a>):</p>
<pre>* <b>(dom:document-element *example*)</b>
#&lt;DOM-IMPL::ELEMENT test @ #x722b6ba2&gt;
* (<b>dom:tag-name</b> (dom:document-element *example*))
"test"
* (<b>dom:child-nodes</b> (dom:document-element *example*))
#(#&lt;DOM-IMPL::ELEMENT child @ #x722b6d8a&gt;)
* (<b>dom:get-attribute</b> (dom:document-element *example*) <b>"a"</b>)
"b"</pre>
<heading>Serializing DOM</heading>
<p>Serialize the DOM document back into a file (<a
href="sax.html#serialization">read more</a>):</p>
<pre>(with-open-file (out "example.out" :direction :output :element-type '(unsigned-byte 8))
<b>(dom:map-document (cxml:make-octet-stream-sink out) *example*)</b></pre>
<heading>Parsing into XMLS-like lists</heading>
<p>
If DOM is not the representation you want to you, parsing into
other data structures is possible using the same SAX parser
function, while using a different handler.
The XMLS builder is included for compatibility with XMLS, and also
also sample code (see cxml/xml/xmls-compat.lisp) for your own
handlers.
</p>
<p>As an alternative to DOM, parse into xmls-compatible list
structure (<a href="xmls-compat.html">read more</a>):</p>
<pre>* <b>(cxml:parse-file "example.xml" (cxml-xmls:make-xmls-builder))</b>
("test" (("a" "b")) ("child" NIL))</pre>
<p>
Again, serialization into XML is done using a sink as a SAX
handler and a data-structure specific function to generate SAX
events for the document, in this case <tt>cxml-xmls:map-node</tt>.
</p>
<pre>* (with-open-file (out "example.out" :direction :output :element-type '(unsigned-byte 8))
(<b>cxml-xmls:map-node (cxml:make-octet-stream-sink out)
'("test" (("a" "b")) ("child" nil)))</b>)</pre>
<heading>Parsing incrementally using Klacks</heading>
<p>Use klacks to read events from the parser incrementally. The
following example looks only for :start-element and :end-element
events and prints them (<a href="klacks.html">read more</a>):</p>
<pre>* <b>(klacks:with-open-source
(s (cxml:make-source #p"example.xml"))</b>
(loop
for key = <b>(klacks:peek s)</b>
while key
do
(case key
(:start-element
(format t "~A {" <b>(klacks:current-qname s)</b>))
(:end-element
(format t "}")))
<b>(klacks:consume s)</b>))
test {child {}}</pre>
<heading>Writing XML</heading>
<p>
Serialization is always done using sinks, which accept SAX events,
but there are convenience functions and macros to make that easier
to use:
</p>
<pre>(cxml:with-xml-output (cxml:make-octet-stream-sink stream :indentation 2 :canonical nil)
(cxml:with-element "foo"
(cxml:attribute "xyz" "abc")
(cxml:with-element "bar"
(cxml:attribute "blub" "bla"))
(cxml:text "Hi there.")))</pre>
<p>
Prints this to <tt>stream</tt>:
</p>
<pre>&lt;foo xyz="abc"&gt;
&lt;bar blub="bla"&gt;&lt;/bar&gt;
Hi there.
&lt;/foo&gt;</pre>
<heading>Help! CXML says 'URI scheme :HTTP not supported'</heading>
<p>
By default, this error will occur when the DTD (or generally, any
entity) has an http:// URL as its system ID. CXML itself
understands only file:// URLs, but allows users to customize the
behaviour for all URLs.
</p>
<p>
The are several solutions to this, covered in detail below:
<ul>
<li>
Load the DTD/entity from local files using an entity resolver
</li>
<li>
Skip parsing of the DTD/entity entirely by pretending it is
empty, again using an entity resolver.
</li>
<li>
Use a <em>catalog</em> to make CXML find DTDs in the local
filesystem automatically.
</li>
<li>
Teach CXML actually load DTDs using HTTP.
</li>
</ul>
</p>
<p>
Here are the example files for the following solutions to this
problem:
</p>
<a href="http://www.lichteblau.com/blubba/dtdexample.xml">
<tt>dtdexample.xml</tt>:</a>
<pre>&lt;!DOCTYPE test SYSTEM 'http://www.lichteblau.com/blubba/dtdexample.dtd'>
&lt;test a='b'>blub&lt;child/>&lt;/test></pre>
<a href="http://www.lichteblau.com/blubba/dtdexample.dtd">
<tt>dtdexample.dtd</tt></a>:
<pre>&lt;!ELEMENT test (#PCDATA|child)*>
&lt;!ATTLIST test
a CDATA #REQUIRED
>
&lt;!ELEMENT child EMPTY>
</pre>
<heading>Loading DTDs from local files</heading>
<p>
Use the :entity-resolver argument to <tt>parse-file</tt> to
specify a function that maps System IDs and Public IDs to local
files of your choice:
</p>
<pre>(let ((uri "http://www.lichteblau.com/blubba/dtdexample.dtd")
(pathname "dtdexample.dtd"))
(flet ((resolver (pubid sysid)
(declare (ignore pubid))
<b>(when (puri:uri= sysid (puri:parse-uri uri))
(open pathname :element-type '(unsigned-byte 8)))</b>))
(cxml:parse-file "dtdexample.xml" (cxml-dom:make-dom-builder) <b>:entity-resolver #'resolver</b>)))</pre>
<heading>Can I skip loading of DTDs entirely?</heading>
<p>
Yes and no.
</p>
<p>
<i>Yes</i>, you can force CXML to do this, see the following example.
</p>
<p>
But no, skipping the DTD will not actually work if the document
references entities declared in the DTD, especially since neither
SAX nor DOM are able to report unresolved entity references in
attributes.
</p>
<p>
The trick to make CXML skip the DTD is to pretend that it is empty
by returning a zero-length stream instead:
</p>
<pre>(flet ((resolver (pubid sysid)
(declare (ignore pubid sysid))
<b>(flexi-streams:make-in-memory-input-stream nil)</b>))
(cxml:parse-file "dtdexample.xml" (cxml-dom:make-dom-builder) <b>:entity-resolver #'resolver</b>))</pre>
<heading>
Catalogs: How can I use the HTML DTD installed by my distribution?
</heading>
<p>
Rather than writing an entity resolver function yourself, CXML can
use XML catalogs to find DTDs and entity files on your local system.
</p>
<p>
Catalogs are particularly helpful for DTDs that are
pre-installed. For example, most Linux distributions include a
package for the XHTML DTD. The DTD will reside in a
distribution-dependent location, which the central catalog file
points to.
</p>
<p>By default, CXML looks for the catalog in /etc/xml/catalog
(Linux) and /usr/local/share/xml/catalog.ports (FreeBSD).
</p>
<pre>* <b>(setf cxml:*catalog* (cxml:make-catalog))</b>
* (cxml:parse-file "test.xhtml" (cxml-dom:make-dom-builder))</pre>
<heading>
Can I load DTDs through HTTP?
</heading>
<p>
Sure, just use an entity-resolver function that does it.
</p>
<p>
Install <a href="http://weitz.de/drakma/">Drakma</a> and try this:
</p>
<pre>(flet ((resolver (pubid sysid)
(declare (ignore pubid))
<b>(when (eq (puri:uri-scheme sysid) :http)
(drakma:http-request sysid :want-stream t))</b>))
(cxml:parse-file "dtdexample.xml" (cxml-dom:make-dom-builder) <b>:entity-resolver #'resolver</b>))</pre>
</documentation>
This diff is collapsed.
<documentation title="CXML XMLS Compatibility">
<h1>XMLS Builder</h1>
<p>
Like other XML parsers written in Lisp, CXML can work with
documents represented as list structures. The specific model
implemented by cxml is compatible with the <a
href="http://common-lisp.net/project/xmls/">xmls parser</a>. Xmls
list structures are a simpler and faster alternative to full DOM
document trees. They also serve as an example showing how to
implement user-defined document models as an independent layer
over the the base parser (c.f. <tt>xml/xmls-compat.lisp</tt> in
the cxml distribution). However, note that the list structures do
not include all information available in DOM documents
(notably, things like <tt>dom:parent-node</tt>) and are
sometimes more difficult to work with because of that since many
DOM functions cannot be implemented on them.
</p>
<p>
<b>New namespace handling:</b>
XMLS compatibility is not <i>bug-for-bug</i>-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.
</p>
<!--
<p>
<strike>
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 <em>and</em> the namespace URI. We
currently follow the xmls <em>implementation</em> and use the
namespace prefix instead of following its <em>documentation</em> 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.
</strike>
</p>
-->
<p>
<div class="def">Function CXML-XMLS:MAKE-XMLS-BUILDER (&amp;key include-default-values include-namespace-uri)</div>
Create a SAX handler which builds XMLS list structures.&#160;
If <tt>include-default-values</tt> is true, default values for
attributes declared in a DTD are included as attributes in the
xmls output. <tt>include-default-values</tt> is true by default
and can be set to <tt>nil</tt> to suppress inclusion of default
values.
</p>
<p>
If <tt>include-namespace-uri</tt> 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.
</p>
<p>
Example:
</p>
<pre>(cxml:parse-file "test.xml" (cxml-xmls:make-xmls-builder))</pre>
<p>
<div class="def">Function CXML-XMLS:MAP-NODE (handler node &amp;key include-xmlns-attributes include-namespace-uri)</div>
Traverse an XMLS document/node and call SAX functions as if an XML
representation of the document were processed by a SAX parser.
</p>
<p>
Use this function to serialize XMLS data. For example, we could
define a replacement for <tt>xmls:write-xml</tt> like this: