Function: xml--entity-replacement-text
xml--entity-replacement-text is a byte-compiled function defined in
xml.el.gz.
Signature
(xml--entity-replacement-text STRING)
Documentation
Return the replacement text for the entity value STRING.
The replacement text is obtained by replacing character references and parameter-entity references.
Source Code
;; Defined in /usr/src/emacs/lisp/xml.el.gz
(defun xml--entity-replacement-text (string)
"Return the replacement text for the entity value STRING.
The replacement text is obtained by replacing character
references and parameter-entity references."
(let ((ref-re (eval-when-compile
(concat "\\(?:&#\\([0-9]+\\)\\|&#x\\([[:xdigit:]]+\\)\\|%\\("
xml-name-re "\\)\\);")))
children)
(while (string-match ref-re string)
(push (substring string 0 (match-beginning 0)) children)
(let ((remainder (substring string (match-end 0)))
ref val)
(cond ((setq ref (match-string 1 string))
;; Decimal character reference
(setq val (string-to-number ref))
(if val (push (string val) children)))
;; Hexadecimal character reference
((setq ref (match-string 2 string))
(setq val (string-to-number ref 16))
(if val (push (string val) children)))
;; Parameter entity reference
((setq ref (match-string 3 string))
(setq val (assoc ref xml-parameter-entity-alist))
(and (null val)
xml-validating-parser
(error "XML: (Validity) Undefined parameter entity `%s'" ref))
(push (or (cdr val) xml-undefined-entity) children)))
(setq string remainder)))
(mapconcat 'identity (nreverse (cons string children)) "")))