[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/xml.el [emacs-unicode-2]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/xml.el [emacs-unicode-2] |
Date: |
Mon, 28 Jun 2004 04:33:49 -0400 |
Index: emacs/lisp/xml.el
diff -c emacs/lisp/xml.el:1.23.2.1 emacs/lisp/xml.el:1.23.2.2
*** emacs/lisp/xml.el:1.23.2.1 Fri Apr 16 12:50:11 2004
--- emacs/lisp/xml.el Mon Jun 28 07:28:48 2004
***************
*** 27,39 ****
;; This file contains a somewhat incomplete non-validating XML parser. It
;; parses a file, and returns a list that can be used internally by
! ;; any other lisp libraries.
;;; FILE FORMAT
;; The document type declaration may either be ignored or (optionally)
;; parsed, but currently the parsing will only accept element
! ;; declarations. The XML file is assumed to be well-formed. In case
;; of error, the parsing stops and the XML file is shown where the
;; parsing stopped.
;;
--- 27,39 ----
;; This file contains a somewhat incomplete non-validating XML parser. It
;; parses a file, and returns a list that can be used internally by
! ;; any other Lisp libraries.
;;; FILE FORMAT
;; The document type declaration may either be ignored or (optionally)
;; parsed, but currently the parsing will only accept element
! ;; declarations. The XML file is assumed to be well-formed. In case
;; of error, the parsing stops and the XML file is shown where the
;; parsing stopped.
;;
***************
*** 44,50 ****
;; <node2 attr3="name3" attr4="name4">value2</node2>
;; <node3 attr5="name5" attr6="name6">value3</node3>
;; </node1>
! ;; Of course, the name of the nodes and attributes can be anything. There can
;; be any number of attributes (or none), as well as any number of children
;; below the nodes.
;;
--- 44,50 ----
;; <node2 attr3="name3" attr4="name4">value2</node2>
;; <node3 attr5="name5" attr6="name6">value3</node3>
;; </node1>
! ;; Of course, the name of the nodes and attributes can be anything. There can
;; be any number of attributes (or none), as well as any number of children
;; below the nodes.
;;
***************
*** 86,92 ****
(defsubst xml-node-name (node)
"Return the tag associated with NODE.
! The tag is a lower-case symbol."
(car node))
(defsubst xml-node-attributes (node)
--- 86,103 ----
(defsubst xml-node-name (node)
"Return the tag associated with NODE.
! Without namespace-aware parsing, the tag is a symbol.
!
! With namespace-aware parsing, the tag is a cons of a string
! representing the uri of the namespace with the local name of the
! tag. For example,
!
! <foo>
!
! would be represented by
!
! '(\"\" . \"foo\")."
!
(car node))
(defsubst xml-node-attributes (node)
***************
*** 101,117 ****
(defun xml-get-children (node child-name)
"Return the children of NODE whose tag is CHILD-NAME.
! CHILD-NAME should be a lower case symbol."
(let ((match ()))
(dolist (child (xml-node-children node))
! (if child
! (if (equal (xml-node-name child) child-name)
! (push child match))))
(nreverse match)))
(defun xml-get-attribute-or-nil (node attribute)
"Get from NODE the value of ATTRIBUTE.
! Return `nil' if the attribute was not found.
See also `xml-get-attribute'."
(cdr (assoc attribute (xml-node-attributes node))))
--- 112,128 ----
(defun xml-get-children (node child-name)
"Return the children of NODE whose tag is CHILD-NAME.
! CHILD-NAME should match the value returned by `xml-node-name'."
(let ((match ()))
(dolist (child (xml-node-children node))
! (if (and (listp child)
! (equal (xml-node-name child) child-name))
! (push child match)))
(nreverse match)))
(defun xml-get-attribute-or-nil (node attribute)
"Get from NODE the value of ATTRIBUTE.
! Return nil if the attribute was not found.
See also `xml-get-attribute'."
(cdr (assoc attribute (xml-node-attributes node))))
***************
*** 236,242 ****
(nreverse xml)))))))
(defun xml-maybe-do-ns (name default xml-ns)
! "Perform any namespace expansion. NAME is the name to perform the
expansion on.
DEFAULT is the default namespace. XML-NS is a cons of namespace
names to uris. When namespace-aware parsing is off, then XML-NS
is nil.
--- 247,254 ----
(nreverse xml)))))))
(defun xml-maybe-do-ns (name default xml-ns)
! "Perform any namespace expansion.
! NAME is the name to perform the expansion on.
DEFAULT is the default namespace. XML-NS is a cons of namespace
names to uris. When namespace-aware parsing is off, then XML-NS
is nil.
***************
*** 325,334 ****
(push (cons (cdar attr) (intern (concat ":" (cdr attr))))
xml-ns))))
! ;; expand element names
! (setq node-name (list (xml-maybe-do-ns node-name "" xml-ns)))
- (setq children (list attrs node-name))
;; is this an empty element ?
(if (looking-at "/>")
(progn
--- 337,344 ----
(push (cons (cdar attr) (intern (concat ":" (cdr attr))))
xml-ns))))
! (setq children (list attrs (xml-maybe-do-ns node-name "" xml-ns)))
;; is this an empty element ?
(if (looking-at "/>")
(progn
***************
*** 383,390 ****
(error "XML: Invalid character")))))
(defun xml-parse-attlist (&optional xml-ns)
! "Return the attribute-list after point. Leave point at the
! first non-blank character after the tag."
(let ((attlist ())
end-pos name)
(skip-syntax-forward " ")
--- 393,400 ----
(error "XML: Invalid character")))))
(defun xml-parse-attlist (&optional xml-ns)
! "Return the attribute-list after point.
! Leave point at the first non-blank character after the tag."
(let ((attlist ())
end-pos name)
(skip-syntax-forward " ")
***************
*** 575,581 ****
;; Fixme: Take declared entities from the DTD when they're available.
(defun xml-substitute-entity (match)
! "Subroutine of xml-substitute-special."
(save-match-data
(let ((match1 (match-string 1 str)))
(cond ((string= match1 "lt") "<")
--- 585,591 ----
;; Fixme: Take declared entities from the DTD when they're available.
(defun xml-substitute-entity (match)
! "Subroutine of `xml-substitute-special'."
(save-match-data
(let ((match1 (match-string 1 str)))
(cond ((string= match1 "lt") "<")
***************
*** 612,620 ****
;;**
;;*******************************************************************
! (defun xml-debug-print (xml)
(dolist (node xml)
! (xml-debug-print-internal node "")))
(defun xml-debug-print-internal (xml indent-string)
"Outputs the XML tree in the current buffer.
--- 622,636 ----
;;**
;;*******************************************************************
! (defun xml-debug-print (xml &optional indent-string)
! "Outputs the XML in the current buffer.
! XML can be a tree or a list of nodes.
! The first line is indented with the optional INDENT-STRING."
! (setq indent-string (or indent-string ""))
(dolist (node xml)
! (xml-debug-print-internal node indent-string)))
!
! (defalias 'xml-print 'xml-debug-print)
(defun xml-debug-print-internal (xml indent-string)
"Outputs the XML tree in the current buffer.
***************
*** 629,652 ****
(insert ?\ (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\")
(setq attlist (cdr attlist)))
- (insert ?>)
-
(setq tree (xml-node-children tree))
! ;; output the children
! (dolist (node tree)
! (cond
! ((listp node)
! (insert ?\n)
! (xml-debug-print-internal node (concat indent-string " ")))
! ((stringp node) (insert node))
! (t
! (error "Invalid XML tree"))))
!
! (insert ?\n indent-string
! ?< ?/ (symbol-name (xml-node-name xml)) ?>)))
(provide 'xml)
! ;;; arch-tag: 5864b283-5a68-4b59-a20d-36a72b353b9b
;;; xml.el ends here
--- 645,672 ----
(insert ?\ (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\")
(setq attlist (cdr attlist)))
(setq tree (xml-node-children tree))
! (if (null tree)
! (insert ?/ ?>)
! (insert ?>)
!
! ;; output the children
! (dolist (node tree)
! (cond
! ((listp node)
! (insert ?\n)
! (xml-debug-print-internal node (concat indent-string " ")))
! ((stringp node) (insert node))
! (t
! (error "Invalid XML tree"))))
!
! (when (not (and (null (cdr tree))
! (stringp (car tree))))
! (insert ?\n indent-string))
! (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>))))
(provide 'xml)
! ;; arch-tag: 5864b283-5a68-4b59-a20d-36a72b353b9b
;;; xml.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/xml.el [emacs-unicode-2],
Miles Bader <=