unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Magnus Henoch <mange@freemail.hu>
Subject: xml.el: xml-get-attribute returns "" if not found
Date: Wed, 12 Nov 2003 22:28:19 +0100	[thread overview]
Message-ID: <20031112212819.GA24650@anastasis.stor.no-ip.org> (raw)

Hi,

In lisp/xml.el, the function xml-get-attribute returns "" if the requested
attribute does not exist.  To me it seems that returning nil would make
more sense in that case.  Backwards compatibilty could be achieved with
something like this:

--- xml.el.old	Mon Nov  3 22:52:15 2003
+++ xml.el	Tue Nov  4 16:53:36 2003
@@ -104,15 +104,24 @@
 	      (push child match))))
     (nreverse match)))
 
-(defun xml-get-attribute (node attribute)
+(defun xml-get-attribute-or-nil (node attribute)
   "Get from NODE the value of ATTRIBUTE.
-An empty string is returned if the attribute was not found."
+nil is returned if the attribute was not found.
+
+See also `xml-get-attribute'."
   (if (xml-node-attributes node)
       (let ((value (assoc attribute (xml-node-attributes node))))
 	(if value
 	    (cdr value)
-	  ""))
-    ""))
+	  nil))
+    nil))
+
+(defsubst xml-get-attribute (node attribute)
+  "Get from NODE the value of ATTRIBUTE.
+An empty string is returned if the attribute was not found.
+
+See also `xml-get-attribute-or-nil'."
+  (or (xml-get-attribute-or-nil node attribute) ""))
 
 ;;*******************************************************************
 ;;**

What do you think about it?

Regards,
Magnus Henoch

             reply	other threads:[~2003-11-12 21:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-12 21:28 Magnus Henoch [this message]
2003-11-24  7:59 ` xml.el: xml-get-attribute returns "" if not found Juri Linkov
2003-11-24 13:29   ` Magnus Henoch
2003-11-24 15:40   ` Mark A. Hershberger
2003-11-24 18:09     ` Magnus Henoch

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=20031112212819.GA24650@anastasis.stor.no-ip.org \
    --to=mange@freemail.hu \
    /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).