[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saner behavior for xml-get-attribute

From: Mark A. Hershberger
Subject: Saner behavior for xml-get-attribute
Date: Mon, 01 Mar 2004 09:26:44 -0600
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/22.0.0 (gnu/linux)

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"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]