Skip to content

Commit

Permalink
Changes to DTD verification
Browse files Browse the repository at this point in the history
Addded get-dtd in order to avoid direct calls to cxml:parse-dtd-file
in cases where it is not absolutely certain that there is a DTD file
associated with the class: while for XML import there needs to be a
DTD, XML export can be useful to serialise any object, even without a
DTD.
  • Loading branch information
fsmunoz authored and hanshuebner committed Aug 29, 2010
1 parent 0cab7ec commit 6a9115b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/xml-impex/xml-class.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ through the object-id-slot (either an element or an attribute)")
(xml-class-element class) (or (first element) (string-downcase (class-name class))))
(xml-class-finalize class))

(defun get-dtd (dtd)
(cond ((or (stringp dtd)
(pathnamep dtd))
(cxml:parse-dtd-file dtd))
((typep dtd 'cxml::dtd) dtd)
(t (let ((dtd (eval dtd)))
(unless (typep dtd 'cxml::dtd)
; (error "DTD ~A is not a CXML dtd." dtd))
(warn "DTD ~A is not a CXML dtd." dtd))
dtd))))

(defun get-dtd-elmdef (dtd elmdef)
"Finds an element definition in a DTD. Returns a cxml:elmdef"
(typecase elmdef
Expand Down Expand Up @@ -186,10 +197,11 @@ pairs, representing the childs and their containment definition"
(defmethod xml-class-finalize ((class xml-class))
(unless (class-finalized-p class)
(finalize-inheritance class))

(let ((slots (class-slots class))
(elmdef (get-dtd-elmdef
(cxml::parse-dtd-file (xml-class-dtd-name class)) (xml-class-element class))))

(let* ((slots (class-slots class))
(dtd (get-dtd (xml-class-dtd-name class)))
(elmdef (when dtd (get-dtd-elmdef dtd (xml-class-element class)))))

(unless elmdef
(return-from xml-class-finalize))
;;; check attributes
Expand Down

0 comments on commit 6a9115b

Please sign in to comment.