new function cxml:parse
This commit is contained in:
@ -2,4 +2,5 @@ all: dom.html index.html installation.html klacks.html quickstart.html sax.html
|
||||
|
||||
%.html: %.xml html.xsl
|
||||
xsltproc html.xsl $< >$@.tmp
|
||||
chmod -w *.html
|
||||
mv $@.tmp $@
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
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>
|
||||
@ -83,11 +84,11 @@
|
||||
</ul>
|
||||
<p class="nomargin"><tt>rel-2007-05-26</tt></p>
|
||||
<ul class="nomargin">
|
||||
<li><b>cxml.asd has been split up into <tt>cxml.asd</tt> for the
|
||||
<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>.</b></li>
|
||||
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>
|
||||
|
||||
58
doc/sax.xml
58
doc/sax.xml
@ -43,17 +43,63 @@
|
||||
</p>
|
||||
|
||||
<h3>Parsing and Validating</h3>
|
||||
<div style="border: 1px dotted black;
|
||||
width: 70%;
|
||||
padding: 1em">
|
||||
<p>
|
||||
<div class="def">Function CXML:PARSE-FILE (pathname handler &key ...)</div>
|
||||
<div class="def">Function CXML:PARSE-STREAM (stream handler &key ...)</div>
|
||||
<div class="def">Function CXML:PARSE-OCTETS (octets handler &key ...)</div>
|
||||
<div class="def">Function CXML:PARSE-ROD (rod handler &key ...)</div>
|
||||
Parse an XML document. 
|
||||
Old-style convenience functions:
|
||||
</p>
|
||||
<div style="font-weight: bold">Function CXML:PARSE-FILE (pathname handler &key ...)</div>
|
||||
<p style="margin-left: 2em">Same as <tt>cxml:parse</tt> with a pathname argument.
|
||||
(But note that <tt>cxml:parse-file</tt> interprets string
|
||||
arguments as namestrings, while <tt>cxml:parse</tt> expects
|
||||
literal XML documents.)
|
||||
</p>
|
||||
<div style="font-weight: bold">Function CXML:PARSE-STREAM (stream handler &key ...)</div>
|
||||
<p style="margin-left: 2em">Same as <tt>cxml:parse</tt> with a stream argument.</p>
|
||||
<div style="font-weight: bold">Function CXML:PARSE-OCTETS (octets handler &key ...)</div>
|
||||
<p style="margin-left: 2em">Same as <tt>cxml:parse</tt> with an octet vector argument.</p>
|
||||
<div style="font-weight: bold">Function CXML:PARSE-ROD (rod handler &key ...)</div>
|
||||
<p style="margin-left: 2em">Same as <tt>cxml:parse</tt> with a string argument.</p>
|
||||
</div>
|
||||
|
||||
<h4>
|
||||
New all-in-one parser interface:
|
||||
</h4>
|
||||
<div class="def">Function CXML:PARSE (input handler &key ...)</div>
|
||||
<p>
|
||||
Parse an XML document, where input is a string, pathname, octet
|
||||
vector, or stream.
|
||||
Return values from this function depend on the SAX handler used.<br/>
|
||||
Arguments:
|
||||
</p>
|
||||
<ul>
|
||||
<li><tt>pathname</tt> -- a Common Lisp pathname</li>
|
||||
<li>
|
||||
<tt>input</tt> -- one of:<br/>
|
||||
<ul>
|
||||
<li>
|
||||
<tt>pathname</tt> -- a Common Lisp pathname.
|
||||
Open the file specified by the pathname and create a source for
|
||||
the resulting stream. See below for information on how to
|
||||
close the stream.
|
||||
</li>
|
||||
<li><tt>stream</tt> -- a Common Lisp stream with element-type
|
||||
<tt>(unsigned-byte 8)</tt>. See below for information on how to
|
||||
close the stream.
|
||||
</li>
|
||||
<li>
|
||||
<tt>octets</tt> -- an <tt>(unsigned-byte 8)</tt> array.
|
||||
The array is parsed directly, and interpreted according to the
|
||||
encoding it specifies.
|
||||
</li>
|
||||
<li>
|
||||
<tt>string</tt>/<tt>rod</tt> -- a rod (or <tt>string</tt> on
|
||||
unicode-capable implementations).
|
||||
Parses an XML document from the input string that has already
|
||||
undergone external-format decoding.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><tt>stream</tt> -- a Common Lisp stream with element-type
|
||||
<tt>(unsigned-byte 8)</tt></li>
|
||||
<li><tt>octets</tt> -- an <tt>(unsigned-byte 8)</tt> array</li>
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#:attribute-qname
|
||||
#:attribute-value
|
||||
|
||||
#:parse
|
||||
#:parse-file
|
||||
#:parse-stream
|
||||
#:parse-rod
|
||||
|
||||
@ -3094,6 +3094,32 @@
|
||||
(setf (slot-value pathname 'lisp::host) "localhost"))
|
||||
pathname))
|
||||
|
||||
(defun parse
|
||||
(input handler &rest args
|
||||
&key validate dtd root entity-resolver disallow-internal-subset
|
||||
recode pathname)
|
||||
(declare (ignore validate dtd root entity-resolver disallow-internal-subset
|
||||
recode))
|
||||
(let ((args
|
||||
(loop
|
||||
for (name value) on args by #'cddr
|
||||
unless (eq name :pathname)
|
||||
append (list name value))))
|
||||
(etypecase input
|
||||
(xstream (apply #'make-xstream input handler args))
|
||||
(pathname (apply #'parse-file input handler args))
|
||||
(rod (apply #'parse-rod input handler args))
|
||||
(array (apply #'parse-octets input handler args))
|
||||
(stream
|
||||
(let ((xstream (make-xstream input :speed 8192)))
|
||||
(setf (xstream-name xstream)
|
||||
(make-stream-name
|
||||
:entity-name "main document"
|
||||
:entity-kind :main
|
||||
:uri (pathname-to-uri
|
||||
(merge-pathnames (or pathname (pathname input))))))
|
||||
(apply #'parse-xstream xstream handler args))))))
|
||||
|
||||
(defun parse-xstream (xstream handler &rest args)
|
||||
(let ((*ctx* nil))
|
||||
(handler-case
|
||||
|
||||
Reference in New Issue
Block a user