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.pretest.bugs,gmane.emacs.devel Subject: Saner behavior for xml-get-attribute Date: Mon, 01 Mar 2004 09:26:44 -0600 Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Message-ID: <87wu63ew6t.fsf@weblog.localhost> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1078214325 24395 80.91.224.253 (2 Mar 2004 07:58:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 Mar 2004 07:58:45 +0000 (UTC) Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Tue Mar 02 08:58:37 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ay4nV-0004GS-00 for ; Tue, 02 Mar 2004 08:58:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1Ay4Pa-0007gr-88 for gebp-emacs-pretest-bug@gmane.org; Tue, 02 Mar 2004 02:33:54 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1Ay15F-0001Og-Es for emacs-pretest-bug@gnu.org; Mon, 01 Mar 2004 23:00:41 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1Ay14g-000192-V3 for emacs-pretest-bug@gnu.org; Mon, 01 Mar 2004 23:00:38 -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.30) id 1Ay148-0000vG-UM; Mon, 01 Mar 2004 22:59:33 -0500 Original-Received: from [68.92.76.68] (helo=weblog.localhost.everybody.org) by superman.everybody.org with asmtp (Exim 3.35 #1 (Debian)) id 1AxvSl-0007UK-00; Mon, 01 Mar 2004 16:00:35 -0600 Original-To: emacs-pretest-bug@gnu.org, emacs-devel@gnu.org X-URL: http://mah.everybody.org/weblog/ User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/22.0.0 (gnu/linux) X-BeenThere: emacs-pretest-bug@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.pretest.bugs:2292 gmane.emacs.devel:20224 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20224 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"