all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Drop toplevel XML-comments in libxml-parse-(xml|html)-region?
@ 2014-10-28 20:36 Ulf Jasper
  2014-11-11 16:28 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Ulf Jasper @ 2014-10-28 20:36 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 787 bytes --]

Hi,

parse_region from xml.c, which is called by `libxml-parse-xml-region'
and `libxml-parse-html-region', makes some effort to retain top-level
comments in xml documents.  If necessary it adds an artificial node at
the top of the parse tree.  As a consequence one has to check whether
the result contains the "top" node or not (see below for an example).
This behaviour is different from that of `xml-parse-region' (from
xml.el), which just discards the toplevel comments.

Can we make `libxml-parse-(xml|html)-region' consistent with
`xml-parse-region', i.e. can we drop the toplevel xml comments (and
simply call xmlDocGetRootElement)?

Ulf

----------------------------------------------------------------------
Example: Calling (libxml-parse-xml-region (point-min) (point-max)) on


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/xml, Size: 71 bytes --]

<?xml version="1.0" encoding="UTF-8"?>
<foo>bar</foo>
<!--ignore me-->

[-- Attachment #3: Type: text/plain, Size: 85 bytes --]

    
results in

    (top nil (foo nil "bar") (comment nil "ignore me"))

while for


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Type: text/xml, Size: 54 bytes --]

<?xml version="1.0" encoding="UTF-8"?>
<foo>bar</foo>

[-- Attachment #5: Type: text/plain, Size: 72 bytes --]

    
one gets

    (foo nil "bar")

without the artificial node "top".


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-11-21 15:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28 20:36 Drop toplevel XML-comments in libxml-parse-(xml|html)-region? Ulf Jasper
2014-11-11 16:28 ` Lars Magne Ingebrigtsen
     [not found]   ` <87tx25o8pu.fsf@web.de>
2014-11-11 19:13     ` Lars Magne Ingebrigtsen
2014-11-11 19:29     ` Ulf Jasper
2014-11-11 21:40   ` Stefan Monnier
2014-11-11 21:48     ` Lars Magne Ingebrigtsen
2014-11-11 21:52       ` Lars Magne Ingebrigtsen
2014-11-12 20:24         ` Ulf Jasper
2014-11-21 15:49           ` Ulf Jasper

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.