Mercurial > emacs
comparison lisp/xml.el @ 58698:10ecc7ffdc5a
2004-11-30 Mark A. Hershberger <mah@everybody.org>
* xml.el (xml-substitute-special): Fix validity error messages to
actually show the unexpandable entity. Added validity error if &
isn't followed by an entity.
(xml-parse-tag): Concatnate any string following the a
<![CDATA[]]> section to the parsed CDATA.
author | Mark A. Hershberger <mah@everybody.org> |
---|---|
date | Wed, 01 Dec 2004 04:45:08 +0000 |
parents | 8f9302e4a35f |
children | ff6b2a793277 |
comparison
equal
deleted
inserted
replaced
58697:5deed09aa3c9 | 58698:10ecc7ffdc5a |
---|---|
369 ;; Character data (CDATA) sections, in which no tag should be interpreted | 369 ;; Character data (CDATA) sections, in which no tag should be interpreted |
370 ((looking-at "<!\\[CDATA\\[") | 370 ((looking-at "<!\\[CDATA\\[") |
371 (let ((pos (match-end 0))) | 371 (let ((pos (match-end 0))) |
372 (unless (search-forward "]]>" nil t) | 372 (unless (search-forward "]]>" nil t) |
373 (error "XML: (Not Well Formed) CDATA section does not end anywhere in the document")) | 373 (error "XML: (Not Well Formed) CDATA section does not end anywhere in the document")) |
374 (buffer-substring pos (match-beginning 0)))) | 374 (concat |
375 (buffer-substring pos (match-beginning 0)) | |
376 (xml-parse-string)))) | |
375 ;; DTD for the document | 377 ;; DTD for the document |
376 ((looking-at "<!DOCTYPE") | 378 ((looking-at "<!DOCTYPE") |
377 (let ((dtd (xml-parse-dtd parse-ns))) | 379 (let ((dtd (xml-parse-dtd parse-ns))) |
378 (skip-syntax-forward " ") | 380 (skip-syntax-forward " ") |
379 (if xml-validating-parser | 381 (if xml-validating-parser |
701 ;; beginning, which isn't correct, since then either "&amp;" or | 703 ;; beginning, which isn't correct, since then either "&amp;" or |
702 ;; "&amp;" won't DTRT. | 704 ;; "&amp;" won't DTRT. |
703 | 705 |
704 (let ((point 0) | 706 (let ((point 0) |
705 children end-point) | 707 children end-point) |
706 (while (string-match "&\\([^;]+\\);" string point) | 708 (while (string-match "&\\([^;]*\\);" string point) |
707 (setq end-point (match-end 0)) | 709 (setq end-point (match-end 0)) |
708 (let* ((this-part (match-string 1 string)) | 710 (let* ((this-part (match-string 1 string)) |
709 (prev-part (substring string point (match-beginning 0))) | 711 (prev-part (substring string point (match-beginning 0))) |
710 (entity (assoc this-part xml-entity-alist)) | 712 (entity (assoc this-part xml-entity-alist)) |
711 (expansion | 713 (expansion |
719 'ucs | 721 'ucs |
720 (string-to-number (match-string 1 this-part) 16)))) | 722 (string-to-number (match-string 1 this-part) 16)))) |
721 (if c (string c)))) | 723 (if c (string c)))) |
722 (entity | 724 (entity |
723 (cdr entity)) | 725 (cdr entity)) |
726 ((eq (length this-part) 0) | |
727 (error "XML: (Validity) No entity given")) | |
724 (t | 728 (t |
725 (if xml-validating-parser | 729 (if xml-validating-parser |
726 (error "XML: (Validity) Undefined entity `%s'" | 730 (error "XML: (Validity) Undefined entity `%s'" |
727 (match-string 1 this-part))))))) | 731 this-part)))))) |
728 | 732 |
729 (cond ((null children) | 733 (cond ((null children) |
730 ;; FIXME: If we have an entity that expands into XML, this won't work. | 734 ;; FIXME: If we have an entity that expands into XML, this won't work. |
731 (setq children | 735 (setq children |
732 (concat prev-part expansion))) | 736 (concat prev-part expansion))) |