emacs-devel
[Top][All Lists]
Advanced

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

XML editing wishlist (was: Saving markup formats)


From: Drew Adams
Subject: XML editing wishlist (was: Saving markup formats)
Date: Sun, 17 Jun 2007 17:30:40 -0700

Some thoughts on Emacs support for editing XML...

I use nxml mode now when I edit XML with Emacs 22. I use SGML mode for that
when I use Emacs 20 (which is still most of the time ;-)). I'm not very
familiar with either mode, sad to say. So please ignore or forgive (and
correct) any misconceptions about them that I might demonstrate.

I edit XML code quite often, in spite of not having taken the time to check
out nxml mode well. Sometimes the XML I edit is within SQL or PL/SQL code,
as an argument to a SQL function. Similarly, I use XQuery and XPath
expressions quite often - likewise, within calls to SQL functions such as
XMLQuery and XMLTable. I really should try a multi-mode approach such as mmm
or mumamo, no doubt, but I haven't had time to do that yet either - I just
use SQL mode.

I know that there is an XQuery Emacs mode that exists. I downloaded it, but
I haven't yet tried it. I see zero commentary in the file and I haven't
found any Info file for it.

I often use XML Schema - that is, most of the XML I use is XML Schema-based.
I do not use any other type of schema for XML, except sometimes DTDs. In
particular, I don't use Relax NG. In the database world, it's all about XML
Schema and XQuery - and becoming more so (no flames, please).

I would love to see a really handy XML editing mode. I don't claim it
doesn't exist, but I haven't yet noticed some things I'd like to see. `C-h
m' in nXML mode gives only a cursory description, the XML menu-bar menu
seems quite sparse, there are no contextual pop-up menus (that I have
noticed), and the nXML Info manual (which I have only skimmed) seems also
quite skimpy. In short, where's the beef? ;-)

XML is huge. It is an ugly cousin of Lisp, in some ways. We really should
have something more to offer the _many_ different kinds of XML users, IMO.
Again, maybe we do, and I'm just unaware of it.

FWIW, I also use Framemaker, for work, and it is a surprisingly good WYSIWYG
round-trip editor for XML documents. It has great search and replace for XML
elements and attributes, and good visualization and manipulation of XML
structure (it's easy to change the structure interactively and not get lost
in what you're doing). It also has a good validation interface, but it is
limited to DTDs (or to simple XML Schemas that are limited to what DTDs can
do).

Some things I'd like to see in Emacs for XML (they might be there, but I
haven't noticed):

1. Double-click the mouse  on `<' or `>' to pick up a complete sexp, just as
in Lisp. Or, better, double-click to pick up a complete tag and triple-click
to pick up the complete element. Currently, as soon as there is any
whitespace (e.g. there is an attribute), the complete tag is not selected.
Double-click, then right-click to extend to the next element boundary (or
something more significant than just a word). Other mouse selection
possibilities could also be useful. The mouse now seems almost useless for
XML.

2. XPath navigation.

3. XQuery navigation.

4. XML Schema support.

5. XML-specific search capabilities, even unrelated to XPath and XQuery:
search (and replace) for elements with certain attribute values etc. - at
least as good as what Framemaker has.

You can imagine different things for #2 and #3, from adding, deleting, and
selecting nodes to constructing more XML data using XQuery. Really, the
possibilities are limitless. I'd like the editor to let me use XQuery and
XPath to edit XML. I'd also like editor support for XQuery code itself; that
is, for editing XQuery and XPath expressions. Neither is XML (unlike XSLT).

XPath and XQuery (which includes XPath) are the natural matching languages
for XML. Regular expressions are completely general; they cannot take
advantage of anything defined in the XML language.

I've thought about adding something for #2 and #3 to Icicles, and I might
yet do so when I get some time. The idea would be to type an XPath or XQuery
expression as minibuffer input and have all of the matching nodes become
completion candidates (yes, whole nodes). More precisely, the result of an
XQuery expression is a sequence of items, which can be atoms or nodes. The
sequence would be used as the completion candidates set.

Different commands would do different things with those candidates. I would
use an Icicles search command to navigate among them. I would use another
command to select one or more, or transform one or more. And so on. IOW, use
XML-aware matching instead of regexp matching.

For that, I would add a different kind of completion to Icicles, in addition
to prefix completion and apropos (regexp) completion. But I would need
something to parse the XML and come up with the set of matching candidates
for the current input. I have no time to work on that parsing code myself -
perhaps such code exists and I could tap into it; I don't know.

I've had this project in the back of my head almost since I started working
on Icicles. Put it this way - soon after I had the idea of adding regexp
completion, I thought of adding XPath or XQuery completion. After all, the
basic infrastructure of Icicles can use any kind of matching. The hard part
(now) is doing the XQuery/XPath matching.

Anyway, just throwing this out as food for thought, in case someone finds it
interesting. I've kept it to myself long enough, without yet finding the
time to do anything about it. Actually, I did mention it on some XML lists
long ago, asking for some info about existing Emacs packages, but I never
got any reply.

IIUC, the current limited form of Emacs XML support is both a pain and an
opportunity to do something better.









reply via email to

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