emacs-devel
[Top][All Lists]
Advanced

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

Re: Recent documents: Emacs and GNOME integration


From: Stuart D. Herring
Subject: Re: Recent documents: Emacs and GNOME integration
Date: Wed, 17 May 2006 11:50:33 -0700 (PDT)
User-agent: SquirrelMail/1.4.3a-11.EL3

> That would be sensible, however, we'd need an emacs package for xml
> manipulation.  As far as I can see, xml.el is only a parser (can't
> modify an existing xml tree).

xml.el contains the function `xml-debug-print' which inserts the XML
represented by the internal list form into a buffer.  It's not very robust
(for instance, it doesn't attempt to substitute "&" back in for "&"),
but it seems to me that as long as retaining original formatting is
unnecessary, it could be made into a reasonable "Lisp (form of the data)
to XML" converter.  Then you'd just use the standard Lisp capacities for
modifying/creating lists and you'd have XML modification capacity.

I'm not an expert on XML, but I could probably manage this if no one else
is any better.  For starters, here's a trivial patch to print namespaced
tags instead of dying on them.

Hoping that the patch doesn't reveal that I shouldn't be touching this at
all,
Davis

*** xml.el.~1.53.~      2006-02-06 07:33:36.000000000 -0700
--- xml.el      2006-05-17 12:48:39.000000000 -0600
***************
*** 118,123 ****
--- 118,129 ----

    (car node))

+ (defsubst xml-node-name-as-string (node)
+   "Return the tag associated with NODE as a string."
+   (setq node (xml-node-name node))
+   (if (symbolp node) (symbol-name node)
+     (concat (car node) (cdr node))))
+
  (defsubst xml-node-attributes (node)
    "Return the list of attributes of NODE.
  The list can be nil."
***************
*** 848,854 ****
  The first line is indented with INDENT-STRING."
    (let ((tree xml)
        attlist)
!     (insert indent-string ?< (symbol-name (xml-node-name tree)))

      ;;  output the attribute list
      (setq attlist (xml-node-attributes tree))
--- 854,860 ----
  The first line is indented with INDENT-STRING."
    (let ((tree xml)
        attlist)
!     (insert indent-string ?< (symbol-name (xml-node-name-as-string tree)))

      ;;  output the attribute list
      (setq attlist (xml-node-attributes tree))
***************
*** 875,881 ****
        (when (not (and (null (cdr tree))
                      (stringp (car tree))))
        (insert ?\n indent-string))
!       (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>))))

  (provide 'xml)

--- 881,887 ----
        (when (not (and (null (cdr tree))
                      (stringp (car tree))))
        (insert ?\n indent-string))
!       (insert ?< ?/ (symbol-name (xml-node-name-as-string xml)) ?>))))

  (provide 'xml)

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




reply via email to

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