all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ulf Jasper <ulf.jasper@web.de>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Drop toplevel XML-comments in libxml-parse-(xml|html)-region?
Date: Tue, 28 Oct 2014 21:36:39 +0100	[thread overview]
Message-ID: <8761f4gcdk.fsf@web.de> (raw)

[-- 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".


             reply	other threads:[~2014-10-28 20:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 20:36 Ulf Jasper [this message]
2014-11-11 16:28 ` Drop toplevel XML-comments in libxml-parse-(xml|html)-region? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8761f4gcdk.fsf@web.de \
    --to=ulf.jasper@web.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.