@@ -112,7 +112,7 @@ the line number.")
112
112
ns
113
113
attrs
114
114
children)
115
-
115
+
116
116
(defun make-node (&key name ns attrs child children)
117
117
" Convenience function for creating a new xml node."
118
118
(when (and child children)
@@ -154,7 +154,7 @@ fixed."
154
154
(node-name node))
155
155
(node-attrs node)
156
156
(mapcar ' node->nodelist (node-children node))))))
157
-
157
+
158
158
159
159
; ;;-----------------------------------------------------------------------------
160
160
@@ -355,7 +355,7 @@ character translation."
355
355
(when (char= char #\newline )
356
356
(decf *parser-line-number* ))
357
357
(common-lisp :unread-char char stream ))
358
-
358
+
359
359
; ;;END shadowing--------------------------------------------------------------
360
360
361
361
(define-symbol-macro next-char (peek-stream (state-stream s)))
@@ -551,12 +551,12 @@ character translation."
551
551
(match #\' ))))
552
552
t )
553
553
(if (string= " xmlns" name)
554
- (list ' nsdecl suffix val)
555
- ; ; If SUFFIX is true, then NAME is Prefix and SUFFIX is
556
- ; ; LocalPart.
557
- (if suffix
558
- (list ' attr suffix val :attr-ns name)
559
- (list ' attr name val))))))
554
+ (list ' nsdecl suffix val)
555
+ ; ; If SUFFIX is true, then NAME is Prefix and SUFFIX is
556
+ ; ; LocalPart.
557
+ (if suffix
558
+ (list ' attr suffix val :attr-ns name)
559
+ (list ' attr name val))))))
560
560
561
561
(defrule ws ()
562
562
(and (match+ ws-char)
@@ -797,7 +797,7 @@ character translation."
797
797
((and (eql (element-type c) ' pi)
798
798
(not *discard-processing-instructions* ))
799
799
(return (setf elem c))))))
800
-
800
+
801
801
(and elem (element-val elem))))
802
802
803
803
; ;;-----------------------------------------------------------------------------
@@ -827,7 +827,14 @@ character translation."
827
827
(write-xml e s :indent indent)))
828
828
829
829
(defun parse (s &key (compress-whitespace t ) (quash-errors t ))
830
- " Parses the supplied stream or string into a lisp node tree."
830
+ " Parses the supplied stream or string into a lisp node tree.
831
+
832
+ :QUASH-ERRORS, if true, will cause this function to return NIL
833
+ instead of raising an error if it encounters an XML parsing
834
+ error. Other errors may not be quashed.
835
+
836
+ Note: This function accepts empty XML documents as input, and returns
837
+ NIL in that case."
831
838
(let* ((*compress-whitespace* compress-whitespace)
832
839
(*discard-processing-instructions* t )
833
840
(stream
@@ -844,7 +851,14 @@ character translation."
844
851
(document (make-state :stream stream )))))
845
852
846
853
(defun parse-to-list (&rest args)
847
- (node->nodelist (apply #' parse args)))
854
+ " Parses the supplied stream or string into the legacy XMLS
855
+ s-expression format.
856
+
857
+ Note: This function accepts empty XML documents as input, and returns
858
+ NIL in that case."
859
+ (let ((parsed (apply #' parse args)))
860
+ (when parsed
861
+ (node->nodelist parsed))))
848
862
849
863
(defparameter *test-files*
850
864
(mapcar #' (lambda (x) (asdf :system-relative-pathname " xmls" (format nil " tests/~a " x)))
@@ -884,7 +898,7 @@ character translation."
884
898
" xml-rpc/methodResponse.xml"
885
899
" xml-rpc/struct.xml" )))
886
900
887
- #+ (or sbcl cmu allegro abcl ccl clisp ecl)
901
+ #+ (or sbcl cmu allegro abcl ccl clisp ecl)
888
902
(defun test (&key interactive (test-files *test-files* ))
889
903
" Run the test suite. If it fails, either return NIL \( if INTERACTIVE\) ,
890
904
otherwise exit with an error exit status."
0 commit comments