<li>Fixed attributes to carry an lname even without when occurring
without a namespace.</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.</li>
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
all: dom.html index.html installation.html klacks.html quickstart.html sax.html xmls-compat.html
|
all: dom.html index.html installation.html klacks.html quickstart.html sax.html xmls-compat.html
|
||||||
|
|
||||||
%.html: %.xml html.xsl
|
%.html: %.xml html.xsl
|
||||||
xsltproc html.xsl $< >$@
|
xsltproc html.xsl $< >$@.tmp
|
||||||
|
mv $@.tmp $@
|
||||||
|
|||||||
@ -50,6 +50,15 @@
|
|||||||
|
|
||||||
<a name="changes"/>
|
<a name="changes"/>
|
||||||
<h2>Recent Changes</h2>
|
<h2>Recent Changes</h2>
|
||||||
|
<p class="nomargin"><tt>rel-2007-xx-yy</tt></p>
|
||||||
|
<ul class="nomargin">
|
||||||
|
<li>Fixed attributes to carry an lname even without when occurring
|
||||||
|
without a namespace.</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.</li>
|
||||||
|
</ul>
|
||||||
<p class="nomargin"><tt>rel-2007-02-18</tt></p>
|
<p class="nomargin"><tt>rel-2007-02-18</tt></p>
|
||||||
<ul class="nomargin">
|
<ul class="nomargin">
|
||||||
<li>New StAX-like parser interface.</li>
|
<li>New StAX-like parser interface.</li>
|
||||||
|
|||||||
@ -10,11 +10,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<div>
|
<div>
|
||||||
Anoncvs (<a href="http://common-lisp.net/cgi-bin/viewcvs.cgi/cxml/?cvsroot=cxml">browse</a>):
|
Anoncvs (<a href="http://common-lisp.net/cgi-bin/viewcvs.cgi/cxml/?cvsroot=cxml">browse</a>):
|
||||||
<pre>$ export CVSROOT=:pserver:anonymous@common-lisp.net:/project/cxml/cvsroot
|
<pre>cvs -d :pserver:anonymous:anonymous@common-lisp.net:/project/cxml/cvsroot co cxml</pre>
|
||||||
$ cvs login
|
|
||||||
Logging in to :pserver:anonymous@common-lisp.net:2401/project/cxml/cvsroot
|
|
||||||
CVS password: anonymous
|
|
||||||
$ cvs co cxml</pre>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -231,6 +231,32 @@
|
|||||||
namespace matches. Return values like <tt>peek</tt> or NIL if no
|
namespace matches. Return values like <tt>peek</tt> or NIL if no
|
||||||
such event was found.
|
such event was found.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<div class="def">Condition KLACKS:KLACKS-ERROR (xml-parse-error)</div>
|
||||||
|
The condition class signalled by <tt>expect</tt>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div class="def">Function KLACKS:EXPECT (source key &optional
|
||||||
|
value1 value2 value3)</div>
|
||||||
|
Assert that the current event is equal to (key value1 value2
|
||||||
|
value3). (Ignore <i>value</i> arguments that are NIL.) If so,
|
||||||
|
return it as multiple values. Otherwise signal a
|
||||||
|
<tt>klacks-error</tt>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div class="def">Function KLACKS:SKIP (source key &optional
|
||||||
|
value1 value2 value3)</div>
|
||||||
|
<tt>expect</tt> the specific event, then <tt>consume</tt> it.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<div class="def">Macro KLACKS:EXPECTING-ELEMENT ((fn source
|
||||||
|
&optional lname uri) &body body</div>
|
||||||
|
Assert that the current event matches (:start-element uri lname).
|
||||||
|
(Ignore <i>value</i> arguments that are NIL) Otherwise signal a
|
||||||
|
<tt>klacks-error</tt>.
|
||||||
|
Evaluate <tt>body</tt> as an implicit progn. Finally assert that
|
||||||
|
the remaining event matches (:end-element uri lname).
|
||||||
|
</p>
|
||||||
|
|
||||||
<a name="klacksax"/>
|
<a name="klacksax"/>
|
||||||
<h3>Bridging Klacks and SAX</h3>
|
<h3>Bridging Klacks and SAX</h3>
|
||||||
|
|||||||
@ -148,7 +148,7 @@
|
|||||||
(defun klacks:find-element (source &optional lname uri)
|
(defun klacks:find-element (source &optional lname uri)
|
||||||
(loop
|
(loop
|
||||||
(multiple-value-bind (key current-uri current-lname current-qname)
|
(multiple-value-bind (key current-uri current-lname current-qname)
|
||||||
(klacks:peek-next source)
|
(klacks:peek source)
|
||||||
(case key
|
(case key
|
||||||
((nil)
|
((nil)
|
||||||
(return nil))
|
(return nil))
|
||||||
@ -159,14 +159,55 @@
|
|||||||
(or (null uri)
|
(or (null uri)
|
||||||
(equal uri (klacks:current-uri source))))
|
(equal uri (klacks:current-uri source))))
|
||||||
(return
|
(return
|
||||||
(values key current-uri current-lname current-qname))))))))
|
(values key current-uri current-lname current-qname)))))
|
||||||
|
(klacks:consume source))))
|
||||||
|
|
||||||
(defun klacks:find-event (source key)
|
(defun klacks:find-event (source key)
|
||||||
(loop
|
(loop
|
||||||
(multiple-value-bind (this a b c)
|
(multiple-value-bind (this a b c)
|
||||||
(klacks:peek-next source)
|
(klacks:peek source)
|
||||||
(cond
|
(cond
|
||||||
((null this)
|
((null this)
|
||||||
(return nil))
|
(return nil))
|
||||||
((eq this key)
|
((eq this key)
|
||||||
(return (values this a b c)))))))
|
(return (values this a b c))))
|
||||||
|
(klacks:consume source))))
|
||||||
|
|
||||||
|
(define-condition klacks-error (xml-parse-error) ())
|
||||||
|
|
||||||
|
(defun klacks-error (fmt &rest args)
|
||||||
|
(%error 'klacks-error
|
||||||
|
nil
|
||||||
|
(format nil "Klacks assertion failed: ~?" fmt args)))
|
||||||
|
|
||||||
|
(defun klacks:expect (source key &optional u v w)
|
||||||
|
(multiple-value-bind (this a b c)
|
||||||
|
(klacks:peek source)
|
||||||
|
(unless (eq this key) (klacks-error "expected ~A but got ~A" key this))
|
||||||
|
(when (and u (not (equal a u)))
|
||||||
|
(klacks-error "expected ~A but got ~A" u a))
|
||||||
|
(when (and v (not (equal b v)))
|
||||||
|
(klacks-error "expected ~A but got ~A" v b))
|
||||||
|
(when (and w (not (equal c w)))
|
||||||
|
(klacks-error "expected ~A but got ~A" w c))
|
||||||
|
(values this a b c)))
|
||||||
|
|
||||||
|
(defun klacks:skip (source key &optional a b c)
|
||||||
|
(klacks:expect source key a b c)
|
||||||
|
(klacks:consume source))
|
||||||
|
|
||||||
|
(defun invoke-expecting-element (fn source &optional lname uri)
|
||||||
|
(multiple-value-bind (key a b)
|
||||||
|
(klacks:peek source)
|
||||||
|
(unless (eq key :start-element)
|
||||||
|
(klacks-error "expected ~A but got ~A" (or lname "element") key))
|
||||||
|
(when (and uri (not (equal a uri)))
|
||||||
|
(klacks-error "expected ~A but got ~A" uri a))
|
||||||
|
(when (and lname (not (equal b lname)))
|
||||||
|
(klacks-error "expected ~A but got ~A" lname b))
|
||||||
|
(multiple-value-prog1
|
||||||
|
(funcall fn)
|
||||||
|
(klacks:skip source :end-element a b))))
|
||||||
|
|
||||||
|
(defmacro klacks:expecting-element ((source &optional lname uri) &body body)
|
||||||
|
`(invoke-expecting-element (lambda () ,@body) ,source ,lname ,uri))
|
||||||
|
|||||||
@ -27,8 +27,11 @@
|
|||||||
#:peek-next
|
#:peek-next
|
||||||
#:consume
|
#:consume
|
||||||
|
|
||||||
|
#:expect
|
||||||
|
#:skip
|
||||||
#:find-element
|
#:find-element
|
||||||
#:find-event
|
#:find-event
|
||||||
|
#:expecting-element
|
||||||
|
|
||||||
#:map-attributes
|
#:map-attributes
|
||||||
#:list-attributes
|
#:list-attributes
|
||||||
@ -40,4 +43,6 @@
|
|||||||
|
|
||||||
#:serialize-event
|
#:serialize-event
|
||||||
#:serialize-element
|
#:serialize-element
|
||||||
#:serialize-source))
|
#:serialize-source
|
||||||
|
|
||||||
|
#:klacks-error))
|
||||||
|
|||||||
@ -948,12 +948,9 @@
|
|||||||
(wf-error nil "Entity '~A' is not defined." (rod-string name)))
|
(wf-error nil "Entity '~A' is not defined." (rod-string name)))
|
||||||
def))
|
def))
|
||||||
|
|
||||||
(defun xstream-open-extid (extid)
|
(defun xstream-open-extid* (entity-resolver pubid sysid)
|
||||||
(let* ((sysid (extid-system extid))
|
(let* ((stream
|
||||||
(stream
|
(or (funcall (or entity-resolver (constantly nil)) pubid sysid)
|
||||||
(or (funcall (or (entity-resolver *ctx*) (constantly nil))
|
|
||||||
(extid-public extid)
|
|
||||||
(extid-system extid))
|
|
||||||
(open (uri-to-pathname sysid)
|
(open (uri-to-pathname sysid)
|
||||||
:element-type '(unsigned-byte 8)
|
:element-type '(unsigned-byte 8)
|
||||||
:direction :input))))
|
:direction :input))))
|
||||||
@ -961,6 +958,11 @@
|
|||||||
:name (make-stream-name :uri sysid)
|
:name (make-stream-name :uri sysid)
|
||||||
:initial-speed 1)))
|
:initial-speed 1)))
|
||||||
|
|
||||||
|
(defun xstream-open-extid (extid)
|
||||||
|
(xstream-open-extid* (entity-resolver *ctx*)
|
||||||
|
(extid-public extid)
|
||||||
|
(extid-system extid)))
|
||||||
|
|
||||||
(defun call-with-entity-expansion-as-stream (zstream cont name kind internalp)
|
(defun call-with-entity-expansion-as-stream (zstream cont name kind internalp)
|
||||||
;; `zstream' is for error messages
|
;; `zstream' is for error messages
|
||||||
(let ((in (entity->xstream zstream name kind internalp)))
|
(let ((in (entity->xstream zstream name kind internalp)))
|
||||||
@ -3568,15 +3570,12 @@
|
|||||||
(setf (sax:attribute-namespace-uri attribute)
|
(setf (sax:attribute-namespace-uri attribute)
|
||||||
#"http://www.w3.org/2000/xmlns/")
|
#"http://www.w3.org/2000/xmlns/")
|
||||||
(multiple-value-bind (prefix local-name) (split-qname qname)
|
(multiple-value-bind (prefix local-name) (split-qname qname)
|
||||||
(declare (ignorable local-name))
|
|
||||||
(when (and prefix ;; default namespace doesn't apply to attributes
|
(when (and prefix ;; default namespace doesn't apply to attributes
|
||||||
(or (not (rod= #"xmlns" prefix))
|
(or (not (rod= #"xmlns" prefix))
|
||||||
sax:*use-xmlns-namespace*))
|
sax:*use-xmlns-namespace*))
|
||||||
(multiple-value-bind (uri prefix local-name)
|
(setf (sax:attribute-namespace-uri attribute)
|
||||||
(decode-qname qname)
|
(decode-qname qname)))
|
||||||
(declare (ignore prefix))
|
(setf (sax:attribute-local-name attribute) local-name)))))
|
||||||
(setf (sax:attribute-namespace-uri attribute) uri)
|
|
||||||
(setf (sax:attribute-local-name attribute) local-name)))))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user