all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: xml-get-attribute returns "" if not found
       [not found] <E1AK8re-0002cu-Qj@fencepost.gnu.org>
@ 2003-11-13 18:11 ` Mark A. Hershberger
  2003-11-14  9:32   ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: Mark A. Hershberger @ 2003-11-13 18:11 UTC (permalink / raw)
  Cc: rms, Emacs-devel

Magnus Henoch <mange@freemail.hu> writes:

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

I totally agree.  I thought I had included this change before, but I
see now that it hasn't been applied.  I recommend that the patch be
applied.

Mark.

--- 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) ""))
 
 ;;*******************************************************************
 ;;**

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

* Re: xml-get-attribute returns "" if not found
  2003-11-13 18:11 ` xml-get-attribute returns "" if not found Mark A. Hershberger
@ 2003-11-14  9:32   ` Andreas Schwab
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2003-11-14  9:32 UTC (permalink / raw)
  Cc: Magnus Henoch, rms, Emacs-devel

mah@everybody.org (Mark A. Hershberger) writes:

> -(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.

"Return nil if ...."

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

end of thread, other threads:[~2003-11-14  9:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1AK8re-0002cu-Qj@fencepost.gnu.org>
2003-11-13 18:11 ` xml-get-attribute returns "" if not found Mark A. Hershberger
2003-11-14  9:32   ` Andreas Schwab

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.