* xml.el (xml-parse-tag): Corrrectly handle comment embedded in non-tag text.
* xml.el: Implement XML parameter entities.
(xml-parameter-entity-alist): New variable.
(xml-parse-region, xml-parse-fragment): Preserve previous values
of xml-entity-alist and xml-parameter-entity-alist, so that
repeated calls on different documents do not change them.
(xml-parse-tag): Fix doctype regexp.
(xml--entity-replacement-text): New function.
(xml-parse-dtd): Use it.  Don't handle system entities; doing that
properly requires url retrieval which is unimplemented.
(xml-escape-string): Doc fix.
xml.el: Fix last change.
Fix use of eval-and-compile in regexps in xml.el.

* xml.el (xml-*-re): Convert defvars into defconsts, and
eval-and-compile them so eval-and-compile works on derivatives.
(xml--entity-replacement-text): Use eval-and-comple.
Improve xml parameter entity parsing, and add a new ERT test.

* test/automated/xml-parse-tests.el: New file.

* lisp/xml.el (xml--parse-buffer): New function.  Move most of
xml-parse-region here.
(xml-parse-region): Copy region into a temporary buffer, since
parameter entity substitution requires changing buffer contents.
Use xml--parse-buffer.
(xml-parse-file): Use xml--parse-buffer.
(xml-parse-dtd): Make parameter entity substitution work right.
* xml.el (xml-parse-dtd): Use proper regexps for ELEMENT declarations.

* test/automated/xml-parse-tests.el: Update testcase.
* lisp/xml.el: Handle entity and character reference expansion correctly.
(xml-default-ns): New variable.
(xml-entity-alist): Use XML spec definitions for lt and amp.
(xml-parse-region): Make first two arguments optional.  Discard
text properties.
(xml-parse-tag-1): New function, spun off from xml-parse-tag.  All
callers changed.
(xml-parse-tag): Call xml-parse-tag-1.  For backward
compatibility, this function should not modify buffer contents.
(xml-parse-tag-1): Fix opening-tag regexp.
(xml-parse-string): Rewrite, handling entity and character
references properly.
(xml--entity-replacement-text): Signal an error if a parameter
entity is undefined.

* test/automated/xml-parse-tests.el (xml-parse-tests--data): More
testcases.
* xml.el: Protect parser against XML bombs.
(xml-entity-expansion-limit): New variable.
(xml-parse-string, xml-substitute-special): Use it.
(xml-parse-dtd): Avoid infloop if the DTD is not terminated.

* test/automated/xml-parse-tests.el: Update testcases.
* lisp/xml.el (xml-name-regexp): Remove, redundant.  Use xml-name-re.
Clean up syntax-table usage in xml.el

* xml.el (xml--parse-buffer): Use xml-syntax-table.
(xml-parse-tag): Likewise, and avoid changing entity tables.
(xml-syntax-table): Define from scratch, making sure not to give
x2000 and other Unicode spaces whitespace syntax, since those are
not spaces in XML.
(xml-parse-fragment): Delete unused function.
(xml-name-start-char-re, xml-name-char-re, xml-name-re)
(xml-names-re, xml-nmtoken-re, xml-nmtokens-re, xml-char-ref-re)
(xml-entity-ref, xml-pe-reference-re)
(xml-reference-re,xml-att-value-re, xml-tokenized-type-re)
(xml-notation-type-re, xml-enumeration-re, xml-enumerated-type-re)
(xml-att-type-re, xml-default-decl-re, xml-att-def-re)
(xml-entity-value-re): Use syntax references in regexps where
possible; no need to define inside a let-binding.
(xml-parse-dtd): Use xml-pe-reference-re.
(xml-entity-or-char-ref-re): New defconst.
(xml-parse-string, xml-substitute-special): Use it.
Maybe return expanded XML qnames as plain symbols (Bug#11916).

* xml.el (xml-node-name, xml-parse-file, xml-parse-region):
Explanation of new 'symbol-qnames feature in doc-strings.
(xml-maybe-do-ns): Return expanded names as plain symbols if
'symbol-qnames was provided in XML-NS argument (Bug#11916).
(xml-parse-tag-1): Deal with new definition of PARSE-NS argument.
* xml.el (xml-escape-string): Don't refer to xml-entity-alist.
Update copyright notices for 2013.
* xml.el (xml-entity-or-char-ref-re): Fix regexp.

This bug was reported by Jae-oh Kim; it was posted to bug-gnu-emacs
but didn't show up in the bug tracker for some reason.  It is a
regression against Emacs 24.2.
* xml.el (xml-parse-string): Fix typo in handling of bad character references.