Function: xml--parse-buffer
xml--parse-buffer is a byte-compiled function defined in xml.el.gz.
Signature
(xml--parse-buffer PARSE-DTD PARSE-NS)
Source Code
;; Defined in /usr/src/emacs/lisp/xml.el.gz
;; XML [5]
;; Fixme: This needs re-writing to deal with the XML grammar properly, i.e.
;; document ::= prolog element Misc*
;; prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
(defun xml--parse-buffer (parse-dtd parse-ns)
(with-syntax-table xml-syntax-table
(let ((case-fold-search nil) ; XML is case-sensitive.
;; Prevent entity definitions from changing the defaults
(xml-entity-alist xml-entity-alist)
(xml-parameter-entity-alist xml-parameter-entity-alist)
xml result dtd)
(goto-char (point-min))
(while (not (eobp))
(if (search-forward "<" nil t)
(progn
(forward-char -1)
(setq result (xml-parse-tag-1 parse-dtd parse-ns))
(cond
((null result)
;; Not looking at an xml start tag.
(unless (eobp)
(forward-char 1)))
((and xml (not xml-sub-parser))
;; Translation of rule [1] of XML specifications
(error "XML: (Not Well-Formed) Only one root tag allowed"))
((and (listp (car result))
parse-dtd)
(setq dtd (car result))
(if (cdr result) ; possible leading comment
(push (cdr result) xml)))
(t
(push result xml))))
(goto-char (point-max))))
(if parse-dtd
(cons dtd (nreverse xml))
(nreverse xml)))))