(in-package :xmlisp2)

(defclass quux (xml-serializer)
  ((moo :initform nil :type xmlisp2.types:string)
   (hem :initform nil :type xmlisp2.types:boolean)))

(defclass blech (xml-serializer)
  ((meh :initform nil :type xmlisp2.types:float)
   (hrm :initform nil :type xmlisp2.types:string)))

(defclass foo (xml-serializer)
  ((bar :initform 0 :type xmlisp2.types:non-positive-integer)
   (quux :initform nil :type quux)
   (blech* :initform nil :type list)))

(defun test-serialization ()
  (let ((*xmlns-to-package* (acons "http://unknownlamer.org/xmlisp2"
				   (find-package :xmlisp2)
				   *xmlns-to-package*)))
    (let ((test-foo
	   (parse-and-make-instance (asdf:system-relative-pathname :xmlisp "tests/test.xml")))
	  (sink (cxml:make-octet-stream-sink
		 (open (asdf:system-relative-pathname :xmlisp "tests/test-out.xml")
		       :direction :output
		       :element-type '(unsigned-byte 8)
		       :if-exists :supersede)
		 :canonical nil)))
      (sax:start-document sink)
      (serialize-xml-object test-foo sink)
      (close (sax:end-document sink))
      test-foo)))
