From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: mah@everybody.org (Mark A. Hershberger) Newsgroups: gmane.emacs.devel Subject: Re: xml-get-attribute returns "" if not found Date: Thu, 13 Nov 2003 12:11:23 -0600 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <878ymk5eb8.fsf@weblog.localhost> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068750021 7040 80.91.224.253 (13 Nov 2003 19:00:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 Nov 2003 19:00:21 +0000 (UTC) Cc: rms@gnu.org, Emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Nov 13 20:00:18 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AKMhW-00078a-00 for ; Thu, 13 Nov 2003 20:00:18 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AKMhW-0000n5-00 for ; Thu, 13 Nov 2003 20:00:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AKNbn-00045Q-Gt for emacs-devel@quimby.gnus.org; Thu, 13 Nov 2003 14:58:27 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AKNaj-0003il-Lo for emacs-devel@gnu.org; Thu, 13 Nov 2003 14:57:21 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AKNa7-0003Qh-MG for Emacs-devel@gnu.org; Thu, 13 Nov 2003 14:57:14 -0500 Original-Received: from [204.251.8.130] (helo=superman.everybody.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AKNa6-0003PU-Qf; Thu, 13 Nov 2003 14:56:42 -0500 Original-Received: from [66.76.202.249] (helo=weblog.localhost.everybody.org) by superman.everybody.org with asmtp (Exim 3.35 #1 (Debian)) id 1AKMpY-0004XQ-00; Thu, 13 Nov 2003 13:08:36 -0600 Original-To: Magnus Henoch X-URL: http://mah.everybody.org/weblog/ In-Reply-To: (Richard Stallman's message of "Wed, 12 Nov 2003 23:13:50 -0500") User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:17807 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17807 Magnus Henoch 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) "")) ;;******************************************************************* ;;**