From dlichteblau at common-lisp.net Sun Mar 4 18:30:41 2007 From: dlichteblau at common-lisp.net (dlichteblau) Date: Sun, 4 Mar 2007 13:30:41 -0500 (EST) Subject: [cxml-cvs] CVS cxml/doc Message-ID: <20070304183041.5DF2C3D009@common-lisp.net> Update of /project/cxml/cvsroot/cxml/doc In directory clnet:/tmp/cvs-serv1722/doc Modified Files: GNUmakefile index.xml installation.xml klacks.xml Log Message:
  • Fixed attributes to carry an lname even without when occurring without a namespace.
  • 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.
  • --- /project/cxml/cvsroot/cxml/doc/GNUmakefile 2007/02/18 12:35:50 1.1 +++ /project/cxml/cvsroot/cxml/doc/GNUmakefile 2007/03/04 18:30:40 1.2 @@ -1,4 +1,5 @@ all: dom.html index.html installation.html klacks.html quickstart.html sax.html xmls-compat.html %.html: %.xml html.xsl - xsltproc html.xsl $< >$@ + xsltproc html.xsl $< >$@.tmp + mv $@.tmp $@ --- /project/cxml/cvsroot/cxml/doc/index.xml 2007/02/18 16:50:53 1.2 +++ /project/cxml/cvsroot/cxml/doc/index.xml 2007/03/04 18:30:41 1.3 @@ -50,6 +50,15 @@

    Recent Changes

    +

    rel-2007-xx-yy

    +

    rel-2007-02-18

    --- /project/cxml/cvsroot/cxml/doc/klacks.xml 2007/02/18 17:35:37 1.6 +++ /project/cxml/cvsroot/cxml/doc/klacks.xml 2007/03/04 18:30:41 1.7 @@ -231,6 +231,32 @@ namespace matches. Return values like peek or NIL if no such event was found.

    +

    +

    Condition KLACKS:KLACKS-ERROR (xml-parse-error)
    + The condition class signalled by expect. +

    +

    +

    Function KLACKS:EXPECT (source key &optional + value1 value2 value3)
    + Assert that the current event is equal to (key value1 value2 + value3). (Ignore value arguments that are NIL.) If so, + return it as multiple values. Otherwise signal a + klacks-error. +

    +

    +

    Function KLACKS:SKIP (source key &optional + value1 value2 value3)
    + expect the specific event, then consume it. +

    +

    +

    Macro KLACKS:EXPECTING-ELEMENT ((fn source + &optional lname uri) &body body
    + Assert that the current event matches (:start-element uri lname). + (Ignore value arguments that are NIL) Otherwise signal a + klacks-error. + Evaluate body as an implicit progn. Finally assert that + the remaining event matches (:end-element uri lname). +

    Bridging Klacks and SAX

    From dlichteblau at common-lisp.net Sun Mar 4 18:30:41 2007 From: dlichteblau at common-lisp.net (dlichteblau) Date: Sun, 4 Mar 2007 13:30:41 -0500 (EST) Subject: [cxml-cvs] CVS cxml/klacks Message-ID: <20070304183041.CA20C3E05A@common-lisp.net> Update of /project/cxml/cvsroot/cxml/klacks In directory clnet:/tmp/cvs-serv1722/klacks Modified Files: klacks.lisp package.lisp Log Message:
  • Fixed attributes to carry an lname even without when occurring without a namespace.
  • 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.
  • --- /project/cxml/cvsroot/cxml/klacks/klacks.lisp 2007/02/18 16:46:33 1.3 +++ /project/cxml/cvsroot/cxml/klacks/klacks.lisp 2007/03/04 18:30:41 1.4 @@ -148,7 +148,7 @@ (defun klacks:find-element (source &optional lname uri) (loop (multiple-value-bind (key current-uri current-lname current-qname) - (klacks:peek-next source) + (klacks:peek source) (case key ((nil) (return nil)) @@ -159,14 +159,55 @@ (or (null uri) (equal uri (klacks:current-uri source)))) (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) (loop (multiple-value-bind (this a b c) - (klacks:peek-next source) + (klacks:peek source) (cond ((null this) (return nil)) ((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 () , at body) ,source ,lname ,uri)) --- /project/cxml/cvsroot/cxml/klacks/package.lisp 2007/02/18 16:46:33 1.2 +++ /project/cxml/cvsroot/cxml/klacks/package.lisp 2007/03/04 18:30:41 1.3 @@ -27,8 +27,11 @@ #:peek-next #:consume + #:expect + #:skip #:find-element #:find-event + #:expecting-element #:map-attributes #:list-attributes @@ -40,4 +43,6 @@ #:serialize-event #:serialize-element - #:serialize-source)) + #:serialize-source + + #:klacks-error)) From dlichteblau at common-lisp.net Sun Mar 4 18:30:42 2007 From: dlichteblau at common-lisp.net (dlichteblau) Date: Sun, 4 Mar 2007 13:30:42 -0500 (EST) Subject: [cxml-cvs] CVS cxml/xml Message-ID: <20070304183042.F26A53F00C@common-lisp.net> Update of /project/cxml/cvsroot/cxml/xml In directory clnet:/tmp/cvs-serv1722/xml Modified Files: xml-parse.lisp Log Message:
  • Fixed attributes to carry an lname even without when occurring without a namespace.
  • 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.
  • --- /project/cxml/cvsroot/cxml/xml/xml-parse.lisp 2007/02/11 18:21:22 1.65 +++ /project/cxml/cvsroot/cxml/xml/xml-parse.lisp 2007/03/04 18:30:42 1.66 @@ -948,12 +948,9 @@ (wf-error nil "Entity '~A' is not defined." (rod-string name))) def)) -(defun xstream-open-extid (extid) - (let* ((sysid (extid-system extid)) - (stream - (or (funcall (or (entity-resolver *ctx*) (constantly nil)) - (extid-public extid) - (extid-system extid)) +(defun xstream-open-extid* (entity-resolver pubid sysid) + (let* ((stream + (or (funcall (or entity-resolver (constantly nil)) pubid sysid) (open (uri-to-pathname sysid) :element-type '(unsigned-byte 8) :direction :input)))) @@ -961,6 +958,11 @@ :name (make-stream-name :uri sysid) :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) ;; `zstream' is for error messages (let ((in (entity->xstream zstream name kind internalp))) @@ -3568,15 +3570,12 @@ (setf (sax:attribute-namespace-uri attribute) #"http://www.w3.org/2000/xmlns/") (multiple-value-bind (prefix local-name) (split-qname qname) - (declare (ignorable local-name)) (when (and prefix ;; default namespace doesn't apply to attributes (or (not (rod= #"xmlns" prefix)) sax:*use-xmlns-namespace*)) - (multiple-value-bind (uri prefix local-name) - (decode-qname qname) - (declare (ignore prefix)) - (setf (sax:attribute-namespace-uri attribute) uri) - (setf (sax:attribute-local-name attribute) local-name))))))) + (setf (sax:attribute-namespace-uri attribute) + (decode-qname qname))) + (setf (sax:attribute-local-name attribute) local-name))))) ;;;;;;;;;;;;;;;;; From dlichteblau at common-lisp.net Sun Mar 4 21:04:12 2007 From: dlichteblau at common-lisp.net (dlichteblau) Date: Sun, 4 Mar 2007 16:04:12 -0500 (EST) Subject: [cxml-cvs] CVS cxml/doc Message-ID: <20070304210412.88D274E018@common-lisp.net> Update of /project/cxml/cvsroot/cxml/doc In directory clnet:/tmp/cvs-serv2817/doc Modified Files: html.xsl index.xml klacks.xml sax.xml Log Message: xml:base --- /project/cxml/cvsroot/cxml/doc/html.xsl 2007/02/18 16:46:32 1.3 +++ /project/cxml/cvsroot/cxml/doc/html.xsl 2007/03/04 21:04:11 1.4 @@ -60,6 +60,7 @@
  • Parsing incrementally
  • Convenience functions
  • Bridging Klacks and SAX
  • +
  • Location information
  • Examples
  • --- /project/cxml/cvsroot/cxml/doc/index.xml 2007/03/04 18:30:41 1.3 +++ /project/cxml/cvsroot/cxml/doc/index.xml 2007/03/04 21:04:11 1.4 @@ -52,6 +52,9 @@

    Recent Changes

    rel-2007-xx-yy