Steinar Bang | 16 May 18:48 2011
Picon
Picon

Re: Disabling nxml-mode

>>>>> Peter Flynn <peter <at> silmaril.ie>:

> DTD parsing (I'm sure nxml has this, I just haven't seen it at work).

As others have said: no it doesn't.
But creating a RNG schema from a DTD using trang, is really easy.

And you can persist the association between your DOCTYPE declaration and
the RNG schema you have created.

> C-c C-e element insertion with TAB completion according to the DTD;
> the population of such inserted elements which have required element
> content, and the prompting for required attributes.

nxml did go a different route here.  You start typing, and then you
press C-RET (Control+RET) to get the stuff that expansion can offer.

As an example, here's how to create a DocBook document on a nxml on a
debian system (standard setup on debian).

Open the file /tmp/silly.xml

Select Menu XML->Set Schema->For Document Type->DocBook

When prompted, tell it to write this association to schemas.xml (or not,
but at least this will give you a look at at schemas file).

Then start typing:
 < C-RET b o o C-RET > C-c C-f

(`C-c C-f' is "insert an end-tag for the current tag")

Will give you a document that looks like this:
<book>
</book>

If you would like to add some attributes to the top level element, add a
space after "book" in the start element (ie. "<book >") and place the
cursor on the ">" and press C-RET.  This will give you the list of all
available attributes.

Typing the following with the cursor placed so
 C-c C-x C-RET r e v SPC f RET C-RET a SPC RET
gives
<?xml version="1.0" encoding="utf-8"?>
<book revisionflag="added">
</book>

(just to give an example of expansion for an attribute containing an
enumeration).

Elements are inserted similarily.  Put the cursor after the ">" on the
first line and press C-j.  Then type
 < C-RET c h SPC RET SPC C-RET i SPC RET f i r s t _ c h a p t e r " > C-c C-f

What you have then, is this:

<?xml version="1.0" encoding="utf-8"?>
<book revisionflag="added">
 <chapter id="first_chapter">
 </chapter>
</book>

The "</" in "</chapter>" is higlighted in red.  So select the menu
 XML->First Error

Then the cursor is moved in front of the red "</" and the minibuffer
says: 
 Missing element "title"

So you type
 < t SPC RET > C-c C-f C-j
and you have

<?xml version="1.0" encoding="utf-8"?>
<book revisionflag="added">
 <chapter id="first_chapter">
  <title></title>
 </chapter>
</book>

The "</" in "</chapter>" is still marked red, and First Error
unhelpfully says
 Required child elements missing

But I know that this is because a chapter needs to have some sort of
content, so I do (with the cursor befor "</chapter>"
 C-p C-e C-j < C-RET p a SPC RET > b l a h C-c C-f
to get:

<?xml version="1.0" encoding="utf-8"?>
<book revisionflag="added">
 <chapter id="first_chapter">
  <title></title>
  <para>blah</para>
 </chapter>
</book>

That's as far as I take this little tutorial.  I hope that gave some
impression of how it works.  Only a few commands: usual SPC and TAB for
completion, RET to end minibuffer prompts, and the new commands C-RET,
and C-c C-f.  But the prompting feels natural and the document is quite
quick to write and tag.

> C-c C-r tag-region,

No.  But 
 C-w < C-RET tag-prompt SPC RET C-y C-c C-f
should work.

> C-c - remove-tag,

No.

> and C-c = change-tag;

No.

> C-c C-k cut-element;

That one I really missed from psgml, so I created one myself a long time
ago.  It has been posted to this list, I think...?  Maybe in the
archieves? 

> in fact almost all the markup-management commands,

Probably not.

> point movement commands,

If you mean navigate the tree, similar to what you do in outline mode:
up tag, down tag, forward tag etc., you have those, with the expected
bindings.

> and fold/unfold.

Those you have.

> The highlighting and indentation (I also use xxml-mode); I have no
> doubt nxml-mode can do something similar, as the highlighting is just
> Emacs fontification, and the indentation is a fairly standard
> requirement.

Indentation and highlighting you have.

> C-c C-q Rewrapping elements: psgml correctly rewraps and indents 
> start-tags in element content to reveal the hierarchy (although it won't 
> add newlines if you have got a start-tag following and end-tag on the 
> same line *in element content*, which is a pity; and it rewraps mixed 
> content to indent under the start-tag of the closest ancestor which is 
> in element content (that is also influenced by xxml-mode).

Hm... I will add some text and try.

If I have
<?xml version="1.0" encoding="utf-8"?>
<book revisionflag="added">
 <chapter id="first_chapter">
  <title></title>
  <para>blah blah blah blah blah blah blah blah blah blah blah blah blah  blah blah blah blah blah</para>
 </chapter>
</book>

and do, `M-q' in the <para>, I get:

<?xml version="1.0" encoding="utf-8"?>
<book revisionflag="added">
 <chapter id="first_chapter">
  <title></title>
  <para>blah blah blah blah blah blah blah blah blah blah blah blah
  blah blah blah blah blah blah</para>
 </chapter>
</book>

acceptable?

> C-c C-a The attribute management panel (split screen)

No, that one you don't have.  But I find the C-RET works quite well, and
is actually faster than navigating in the split screen with the
attributes.

> C-c C-w Location-ladder identity

I don't know what that is, so probably not.

> SGML conformance (I still have half a dozen clients using SGML).

No, this is pure XML.  No SGML conformance attempted.

> As I said, I'm sure nxml-mode provides some, if not many or even all,
> of these, but I can't yet find any comprehensive documentation,

My debian nxml has an info manual in emacs, so someone has put together
a texinfo file at some point in time.

> user conversion guide,

No, sorry.

> or examples of usage.

See the first part of my response. :-)

> It seems to be aimed at the data-xml user, not the document-xml user:

Quite the opposite.  I would say that it is so oriented at expanding
tags as you type, that it is far better for typing something like a
DocBook file, than a data-xml style format.  For the latter, some kind
of tree oriented editor would be best.

> I actually write whole text documents in XML, and I must have a
> comprehensive set of facilities for doing so (refer to the table of
> features in my paper at Balisage in 2006). I may simply have missed
> something in nxml-mode, though...

I haven't looked at that paper and the list there, but FWIW I have felt
that nxml-mode have been quite good at creating and editing DITA and
DocBook documents.

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/emacs-nxml-mode/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/emacs-nxml-mode/join
    (Yahoo! ID required)

<*> To change settings via email:
    emacs-nxml-mode-digest <at> yahoogroups.com 
    emacs-nxml-mode-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    emacs-nxml-mode-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/


Gmane