From: mah@everybody.org (Mark A. Hershberger)
Subject: Saner behavior for xml-get-attribute
Date: Mon, 01 Mar 2004 09:26:44 -0600 [thread overview]
Message-ID: <87wu63ew6t.fsf@weblog.localhost> (raw)
Some months ago, this patch was submitted. It didn't get applied
because, I suspect, Savannah was having trouble at the time.
This patch creates a saner alternative to the current
xml-get-attribute. Currently, if an attribute doesn't exist,
xml-get-attribute returns "" -- making it impossible to tell the
difference between a non-existent attribute and an empty attribute.
*** xml.el 14 Jul 2003 20:41:12 -0000 1.23
--- xml.el 1 Mar 2004 15:19:02 -0000
***************
*** 104,118 ****
(push child match))))
(nreverse match)))
! (defun xml-get-attribute (node attribute)
! "Get from NODE the value of ATTRIBUTE.
! An empty string is returned if the attribute was not found."
! (if (xml-node-attributes node)
(let ((value (assoc attribute (xml-node-attributes node))))
! (if value
! (cdr value)
! ""))
! ""))
;;*******************************************************************
;;**
--- 109,130 ----
(push child match))))
(nreverse match)))
! (defun xml-get-attribute-or-nil (node attribute)
! "Get the value of ATTRIBUTE from NODE.
! Returns nil if the attribute is not found.
!
! See also `xml-get-attribute'"
! (when (xml-node-attributes node)
(let ((value (assoc attribute (xml-node-attributes node))))
! (when value
! (cdr value)))))
!
! (defsubst xml-get-attribute (node attribute)
! "Get the the value of ATTRIBUTE from NODE.
! Returns an empty string if the attribute is not found.
!
! See also `xml-get-attribute-or-nil'"
! (or (xml-get-attribute-or-nil node attribute) ""))
;;*******************************************************************
;;**
--
Peace is only better than war if peace isn't hell, too.
-- Walker Percy, "The Second Coming"
next reply other threads:[~2004-03-01 15:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-01 15:26 Mark A. Hershberger [this message]
2004-03-02 21:47 ` Saner behavior for xml-get-attribute Stefan Monnier
2004-03-03 6:10 ` Mark A. Hershberger
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wu63ew6t.fsf@weblog.localhost \
--to=mah@everybody.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).