From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Magnus Henoch Newsgroups: gmane.emacs.devel Subject: xml.el: xml-get-attribute returns "" if not found Date: Wed, 12 Nov 2003 22:28:19 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20031112212819.GA24650@anastasis.stor.no-ip.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068673149 16175 80.91.224.253 (12 Nov 2003 21:39:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 Nov 2003 21:39:09 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Nov 12 22:39:04 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 1AK2hc-0000MO-00 for ; Wed, 12 Nov 2003 22:39:04 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AK2hc-0005lD-00 for ; Wed, 12 Nov 2003 22:39:04 +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 1AK3Wa-0004oV-Lz for emacs-devel@quimby.gnus.org; Wed, 12 Nov 2003 17:31:44 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AK3VK-0004QQ-Et for emacs-devel@gnu.org; Wed, 12 Nov 2003 17:30:26 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AK3Uj-0003eC-Aj for emacs-devel@gnu.org; Wed, 12 Nov 2003 17:30:20 -0500 Original-Received: from [195.67.227.31] (helo=smtp14.fre.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AK3Ui-0003bQ-NM for emacs-devel@gnu.org; Wed, 12 Nov 2003 17:29:48 -0500 Original-Received: from anastasis.stor.no-ip.org (h170n1fls23o1074.bredband.comhem.se [213.67.239.170]) by smtp14.fre.skanova.net (8.12.10/8.12.10) with ESMTP id hACLSLcH002753 for ; Wed, 12 Nov 2003 22:28:21 +0100 (CET) Original-Received: from magnus by anastasis.stor.no-ip.org with local (Exim 3.36 #1) id 1AK2XD-0007hH-00 for emacs-devel@gnu.org; Wed, 12 Nov 2003 22:28:19 +0100 Original-To: emacs-devel@gnu.org Mail-Followup-To: emacs-devel@gnu.org Content-Disposition: inline User-Agent: Mutt/1.4i 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:17783 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17783 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