parse-string in parse-rod umbenannt und exportiert

This commit is contained in:
dlichteblau
2005-12-28 23:18:04 +00:00
parent b5bd89f643
commit 4df5d1d054
4 changed files with 28 additions and 27 deletions

View File

@ -67,6 +67,7 @@
<div class="def">Function CXML:PARSE-FILE (pathname handler &key ...)</div> <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-STREAM (stream handler &key ...)</div>
<div class="def">Function CXML:PARSE-OCTETS (octets 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.&nbsp; Parse an XML document.&nbsp;
Return values from this function depend on the SAX handler used.<br/> Return values from this function depend on the SAX handler used.<br/>
Arguments: Arguments:
@ -123,6 +124,11 @@
otherwise. otherwise.
</li> </li>
</ul> </ul>
<p>
Note: <tt>parse-rod</tt> assumes that the input has already been
decoded into Unicode runes and ignores the encoding
specified in the XML declaration, if any.
</p>
<p> <p>
<div class="def">Function CXML:PARSE-DTD-FILE (pathname)</div> <div class="def">Function CXML:PARSE-DTD-FILE (pathname)</div>

View File

@ -34,8 +34,7 @@
#:parse-file #:parse-file
#:parse-stream #:parse-stream
;; XXX encoding is mis-handled by parse-string, don't export it #:parse-rod
;; #:parse-string
#:parse-octets #:parse-octets
#:make-octet-vector-sink #:make-octet-vector-sink

View File

@ -1,7 +1,7 @@
(in-package :sax-tests) (in-package :sax-tests)
(defun first-start-element-event (string) (defun first-start-element-event (string)
(let ((events (xml:parse-string string (make-instance 'event-collecting-handler)))) (let ((events (cxml:parse-rod string (make-instance 'event-collecting-handler))))
(find :start-element events :key #'car))) (find :start-element events :key #'car)))
@ -17,7 +17,7 @@
(deftest attribute-uniqueness-1 (deftest attribute-uniqueness-1
(handler-case (handler-case
(xml:parse-string "<x xmlns:a='http://example.com' xmlns:b='http://example.com' a:a='1' b:a='1'/>") (cxml:parse-rod "<x xmlns:a='http://example.com' xmlns:b='http://example.com' a:a='1' b:a='1'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -26,7 +26,7 @@
(deftest attribute-uniqueness-2 (deftest attribute-uniqueness-2
(handler-case (handler-case
(xml:parse-string "<x xmlns:a='http://example.com' xmlns='http://example.com' a:a='1' a='1'/>") (cxml:parse-rod "<x xmlns:a='http://example.com' xmlns='http://example.com' a:a='1' a='1'/>")
(error () nil) (error () nil)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -36,7 +36,7 @@
(deftest attribute-uniqueness-3 (deftest attribute-uniqueness-3
(let ((sax:*namespace-processing* nil)) (let ((sax:*namespace-processing* nil))
(handler-case (handler-case
(xml:parse-string "<x xmlns:a='http://example.com' xmlns:b='http://example.com' a:a='1' b:a='1'/>") (cxml:parse-rod "<x xmlns:a='http://example.com' xmlns:b='http://example.com' a:a='1' b:a='1'/>")
(error () nil) (error () nil)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -46,7 +46,7 @@
;;; Namespace undeclaring ;;; Namespace undeclaring
(deftest undeclare-default-namespace-1 (deftest undeclare-default-namespace-1
(let* ((evts (xml:parse-string "<x xmlns='http://example.com'><y xmlns='' a='1'/></x>" (let* ((evts (cxml:parse-rod "<x xmlns='http://example.com'><y xmlns='' a='1'/></x>"
(make-instance 'event-collecting-handler))) (make-instance 'event-collecting-handler)))
(start-elt-events (remove :start-element evts :test (complement #'eql) :key #'car)) (start-elt-events (remove :start-element evts :test (complement #'eql) :key #'car))
(evt1 (first start-elt-events)) (evt1 (first start-elt-events))
@ -59,7 +59,7 @@
(deftest undeclare-other-namespace (deftest undeclare-other-namespace
(handler-case (handler-case
(xml:parse-string "<x:x xmlns:x='http://example.com'><x:y xmlns:x='' a='1'/></x:x>") (cxml:parse-rod "<x:x xmlns:x='http://example.com'><x:y xmlns:x='' a='1'/></x:x>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -71,7 +71,7 @@
(deftest pi-names-are-ncnames-when-namespace-processing-1 (deftest pi-names-are-ncnames-when-namespace-processing-1
(handler-case (handler-case
(xml:parse-string "<?a:b c?><x/>") (cxml:parse-rod "<?a:b c?><x/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -81,7 +81,7 @@
(deftest pi-names-are-ncnames-when-namespace-processing-2 (deftest pi-names-are-ncnames-when-namespace-processing-2
(let ((sax:*namespace-processing* nil)) (let ((sax:*namespace-processing* nil))
(handler-case (handler-case
(xml:parse-string "<?a:b c?><x/>") (cxml:parse-rod "<?a:b c?><x/>")
(error () nil) (error () nil)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -90,7 +90,7 @@
(deftest entity-names-are-ncnames-when-namespace-processing-1 (deftest entity-names-are-ncnames-when-namespace-processing-1
(handler-case (handler-case
(xml:parse-string "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x>&y:z;</x>") (cxml:parse-rod "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x>&y:z;</x>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -99,7 +99,7 @@
(deftest entity-names-are-ncnames-when-namespace-processing-2 (deftest entity-names-are-ncnames-when-namespace-processing-2
(handler-case (handler-case
(xml:parse-string "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x/>") (cxml:parse-rod "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -109,7 +109,7 @@
(deftest entity-names-are-ncnames-when-namespace-processing-3 (deftest entity-names-are-ncnames-when-namespace-processing-3
(let ((sax:*namespace-processing* nil)) (let ((sax:*namespace-processing* nil))
(handler-case (handler-case
(xml:parse-string "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x>&y:z;</x>") (cxml:parse-rod "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x>&y:z;</x>")
(error () nil) (error () nil)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -119,7 +119,7 @@
(deftest entity-names-are-ncnames-when-namespace-processing-4 (deftest entity-names-are-ncnames-when-namespace-processing-4
(let ((sax:*namespace-processing* nil)) (let ((sax:*namespace-processing* nil))
(handler-case (handler-case
(xml:parse-string "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x/>") (cxml:parse-rod "<!DOCTYPE x [ <!ENTITY y:z 'foo'> ]><x/>")
(error () nil) (error () nil)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -259,7 +259,7 @@
(deftest redefine-xml-namespace-1 (deftest redefine-xml-namespace-1
(handler-case (handler-case
(xml:parse-string "<x xmlns:xml='http://www.w3.org/XML/1998/namespace'/>") (cxml:parse-rod "<x xmlns:xml='http://www.w3.org/XML/1998/namespace'/>")
(error () nil) (error () nil)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -268,7 +268,7 @@
(deftest redefine-xml-namespace-2 (deftest redefine-xml-namespace-2
(handler-case (handler-case
(xml:parse-string "<x xmlns:xml='http://example.com/wrong-uri'/>") (cxml:parse-rod "<x xmlns:xml='http://example.com/wrong-uri'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -277,7 +277,7 @@
(deftest redefine-xml-namespace-3 (deftest redefine-xml-namespace-3
(handler-case (handler-case
(xml:parse-string "<x xmlns:wrong='http://www.w3.org/XML/1998/namespace'/>") (cxml:parse-rod "<x xmlns:wrong='http://www.w3.org/XML/1998/namespace'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -286,7 +286,7 @@
(deftest redefine-xml-namespace-4 (deftest redefine-xml-namespace-4
(handler-case (handler-case
(xml:parse-string "<x xmlns:wrong='http://www.w3.org/XML/1998/namespace'/>") (cxml:parse-rod "<x xmlns:wrong='http://www.w3.org/XML/1998/namespace'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -295,7 +295,7 @@
(deftest redefine-xmlns-namespace-1 (deftest redefine-xmlns-namespace-1
(handler-case (handler-case
(xml:parse-string "<x xmlns:xmlns='http://www.w3.org/2000/xmlns/'/>") (cxml:parse-rod "<x xmlns:xmlns='http://www.w3.org/2000/xmlns/'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -304,7 +304,7 @@
(deftest redefine-xmlns-namespace-2 (deftest redefine-xmlns-namespace-2
(handler-case (handler-case
(xml:parse-string "<x xmlns:xmlns='http://example.com/wrong-ns'/>") (cxml:parse-rod "<x xmlns:xmlns='http://example.com/wrong-ns'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -313,7 +313,7 @@
(deftest redefine-xmlns-namespace-3 (deftest redefine-xmlns-namespace-3
(handler-case (handler-case
(xml:parse-string "<x xmlns:wrong='http://www.w3.org/2000/xmlns/'/>") (cxml:parse-rod "<x xmlns:wrong='http://www.w3.org/2000/xmlns/'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
@ -322,11 +322,9 @@
(deftest redefine-xmlns-namespace-4 (deftest redefine-xmlns-namespace-4
(handler-case (handler-case
(xml:parse-string "<x xmlns='http://www.w3.org/2000/xmlns/'/>") (cxml:parse-rod "<x xmlns='http://www.w3.org/2000/xmlns/'/>")
(error () t) (error () t)
(:no-error (&rest junk) (:no-error (&rest junk)
(declare (ignore junk)) (declare (ignore junk))
nil)) nil))
t) t)

View File

@ -3025,12 +3025,10 @@
(p/ext-subset zstream) (p/ext-subset zstream)
(dtd *ctx*))))) (dtd *ctx*)))))
(defun parse-string (string handler) (defun parse-rod (string handler)
;; XXX this function mis-handles encoding
(parse-xstream (string->xstream string) handler)) (parse-xstream (string->xstream string) handler))
(defun string->xstream (string) (defun string->xstream (string)
;; XXX encoding is mis-handled by this kind of stream
(make-rod-xstream (string-rod string))) (make-rod-xstream (string-rod string)))
(defclass octet-input-stream (defclass octet-input-stream