all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: mah@everybody.org (Mark A. Hershberger)
Cc: bug-gnu-emacs@gnu.org
Subject: Re: xml.el produces incorrect sexp for empty element.
Date: Fri, 30 May 2003 15:38:57 -0500	[thread overview]
Message-ID: <87vfvsp3tq.fsf@batman.everybody.org> (raw)
In-Reply-To: <jk7k886zil.fsf@glug.org> (Thien-Thi Nguyen's message of "30 May 2003 14:49:22 -0400")

Thien-Thi Nguyen <ttn@glug.org> writes:

> mah@everybody.org (Mark A. Hershberger) writes:
>
>    * xml.el (xml-parse-tag): Fixed incorrect handling of empty elements.
>
> because i'm not an xml expert i don't understand what was incorrect
> before.  could you reword this in the sense of:
>
>   * xml.el (xml-parse-tag): Handle empty elements [IN CORRECT WAY].
>
> w/ a touch more detail on the correction made?

I did this with my previous patches, but since I made a mistake in
that last patch, thank you for the opportunity to fix my mistake.

    The old xml-parse-region parses the following two bits of XML into
    different sexps.

        "<xml/>" is parsed to ((xml nil ("")))

    while

        "<xml></xml>" is parsed to ((xml nil))

    <URL: http://www.w3.org/TR/2000/REC-xml-20001006#sec-starttags>
    states that "An element with no content is said to be empty.] The
    representation of an empty element is either a start-tag
    immediately followed by an end-tag, or an empty-element tag."

    So, "<xml/>" is equivilent to "<xml></xml>", but they don't parse
    the same in xml.el.
    
The following patch and changelog fix the problem.

mah@everybody.org (Mark A. Hershberger) writes:                         
                                                                         
   * xml.el (xml-parse-tag): Fixed handling of empty elements so that
     "<x/>" parses the same as "<x></x>".

*** xml.el.~1.18.~	Thu Mar 20 12:01:04 2003
--- xml.el	Fri May 30 15:37:12 2003
***************
*** 221,228 ****
        ;; is this an empty element ?
        (if (looking-at "/[ \t\n\r]*>")
  	  (progn
! 	    (forward-char 2)
! 	    (nreverse (cons '("") children)))
  
  	;; is this a valid start tag ?
  	(if (eq (char-after) ?>)
--- 221,228 ----
        ;; is this an empty element ?
        (if (looking-at "/[ \t\n\r]*>")
  	  (progn
! 	    (goto-char (match-end 0))
! 	    (nreverse children))
  
  	;; is this a valid start tag ?
  	(if (eq (char-after) ?>)



-- 
As long as you have mystery you have health; when you destroy mystery
you create morbidity.			     -- G.K. Chesterson

  reply	other threads:[~2003-05-30 20:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-30 10:12 xml.el produces incorrect sexp for empty element Mark A. Hershberger
2003-05-30 18:49 ` Thien-Thi Nguyen
2003-05-30 20:38   ` Mark A. Hershberger [this message]
2003-05-30 22:09     ` Thien-Thi Nguyen

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=87vfvsp3tq.fsf@batman.everybody.org \
    --to=mah@everybody.org \
    --cc=bug-gnu-emacs@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.