Re: Automatic Insertion of Required Elements and Attributes

Dave Pawson <[email protected]>
Newsgroups gmane.emacs.nxml.general
Message-ID <CAEncD4e4=KRSqTK6bCDMfyCks3CkVae26aRN_HO+Hsg1amTHLA@mail.gmail.com>
On 20 July 2012 00:57, garbage_goal <[email protected]> wrote:

>
>
> Hi there,
>
> I hope I am not posting a previously asked question, but I am not having
> much luck searching on this topic.
>
> I've been a psgml user but want to switch to nxml since psgml broke with
> Emacs 24. One thing psgml does is automatically add required elements and
> attributes as you go along.
>
> For example, if I were to insert a tag <compact-disc> which requires a
> "name" attribute and at least one "track" element, psgml would generate and
> insert the following fragment, placing my cursor between the quotes for the
> "name" element:
>
> <compact-disc name="">
>     <track></track>
> </compact-disc>
>
> Is there any way to make nxml behave similarly? I've found nxml will at
> least warn me if I am missing a required child element/attribute, but then
> I have to remember myself which child elements/attributes are required and
> begin typing them before I can take advantage of auto completion.
>
> I'd appreciate it if anyone can point me in the right direction. Is there
> an existing feature I haven't found yet, a minor mode, perhaps some code I
> could find on the internet, do I have to write this myself?
>
>
>
http://dpawson.co.uk/relaxng/nxml/nxml-mode.html is an html version of the
help file that comes
with nxml-mode.

Look for schema locating files.
1. Convert your schema to relax NG, rnc format.
2. Add it to the schema list using one of the methods stated,
or use the commands to specify the schema for your file.
3. Then use (not dissimilar to psgml-mode)
<

and nxml-mode will show the list of elements valid at that point.
It will not automatically insert required elements.
If you want that, it's up to you.

HTH



-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.