diff options
Diffstat (limited to 'lisp/xml.el')
| -rw-r--r-- | lisp/xml.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lisp/xml.el b/lisp/xml.el index a6159554b3f..dbd991f5583 100644 --- a/lisp/xml.el +++ b/lisp/xml.el | |||
| @@ -104,15 +104,22 @@ CHILD-NAME should be a lower case symbol." | |||
| 104 | (push child match)))) | 104 | (push child match)))) |
| 105 | (nreverse match))) | 105 | (nreverse match))) |
| 106 | 106 | ||
| 107 | (defun xml-get-attribute (node attribute) | 107 | (defun xml-get-attribute-or-nil (node attribute) |
| 108 | "Get from NODE the value of ATTRIBUTE. | 108 | "Get from NODE the value of ATTRIBUTE. |
| 109 | An empty string is returned if the attribute was not found." | 109 | Return `nil' if the attribute was not found. |
| 110 | (if (xml-node-attributes node) | 110 | |
| 111 | (let ((value (assoc attribute (xml-node-attributes node)))) | 111 | See also `xml-get-attribute'." |
| 112 | (if value | 112 | (when (xml-node-attributes node) |
| 113 | (cdr value) | 113 | (let ((value (assoc attribute (xml-node-attributes node)))) |
| 114 | "")) | 114 | (when value |
| 115 | "")) | 115 | (cdr value))))) |
| 116 | |||
| 117 | (defsubst xml-get-attribute (node attribute) | ||
| 118 | "Get from NODE the value of ATTRIBUTE. | ||
| 119 | An empty string is returned if the attribute was not found. | ||
| 120 | |||
| 121 | See also `xml-get-attribute-or-nil'." | ||
| 122 | (or (xml-get-attribute-or-nil node attribute) "")) | ||
| 116 | 123 | ||
| 117 | ;;******************************************************************* | 124 | ;;******************************************************************* |
| 118 | ;;** | 125 | ;;** |
| @@ -286,7 +293,6 @@ If PARSE-NS is non-nil, then QNAMES are expanded." | |||
| 286 | attr-list) | 293 | attr-list) |
| 287 | attr-list) | 294 | attr-list) |
| 288 | 295 | ||
| 289 | |||
| 290 | (defun xml-intern-attrlist (attr-list) | 296 | (defun xml-intern-attrlist (attr-list) |
| 291 | "Convert attribute names to symbols for backward compatibility." | 297 | "Convert attribute names to symbols for backward compatibility." |
| 292 | (mapcar (lambda (attr) | 298 | (mapcar (lambda (attr) |
| @@ -349,12 +355,12 @@ Returns one of: | |||
| 349 | (let* ((node-name (match-string 1)) | 355 | (let* ((node-name (match-string 1)) |
| 350 | (attr-list (xml-parse-attlist)) | 356 | (attr-list (xml-parse-attlist)) |
| 351 | (children (if (consp xml-ns) ;; take care of namespace parsing | 357 | (children (if (consp xml-ns) ;; take care of namespace parsing |
| 352 | (progn | 358 | (progn |
| 353 | (setq xml-ns (xml-ns-parse-ns-attrs | 359 | (setq xml-ns (xml-ns-parse-ns-attrs |
| 354 | attr-list xml-ns)) | 360 | attr-list xml-ns)) |
| 355 | (list (xml-ns-expand-attr | 361 | (list (xml-ns-expand-attr |
| 356 | attr-list xml-ns) | 362 | attr-list xml-ns) |
| 357 | (xml-ns-expand-el | 363 | (xml-ns-expand-el |
| 358 | node-name xml-ns))) | 364 | node-name xml-ns))) |
| 359 | (list (xml-intern-attrlist attr-list) | 365 | (list (xml-intern-attrlist attr-list) |
| 360 | (intern node-name)))) | 366 | (intern node-name)))) |