Loading ...
Sorry, an error occurred while loading the content.

Re: Automatic Insertion of Required Elements and Attributes

Expand Messages
  • garbage_goal
    Alright, I wanted to make sure I didn t go reinventing any wheels. Appreciate your response - thanks!
    Message 1 of 11 , Jul 24 9:30 PM
    • 0 Attachment
      Alright, I wanted to make sure I didn't go reinventing any wheels. Appreciate your response - thanks!

      --- In emacs-nxml-mode@yahoogroups.com, Dave Pawson <dave.pawson@...> wrote:
      >
      > On 20 July 2012 00:57, garbage_goal <clockyg@...> 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
      >
    • Peter Flynn
      On 20/07/12 05:30, Dave Pawson wrote: [...] ... This is only one of a dozen or more missing facilities in nxml-mode. I m sure nxml-mode must be useful to some
      Message 2 of 11 , Aug 5, 2012
      • 0 Attachment
        On 20/07/12 05:30, Dave Pawson wrote:
        [...]
        > 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.

        This is only one of a dozen or more missing facilities in nxml-mode.
        I'm sure nxml-mode must be useful to some people, but that does not
        include anyone who actually wants to write or edit a text document.

        Whoever set the current distributions to default to nxml-mode for
        xml-mode broke a useful functionality, and the sooner it is either
        undone, or someone writes proper editing controls for nxml-mode, the better.

        In the meantime, the simple solution for authors and editors is to open
        a document, use M-x sgml-mode RET and then M-x xml-mode RET. This
        overwrites the nxml-mode setting and allows documents to be edited with
        proper control.

        nxml-node is possibly useful for data documents, but it is not a usable
        tool for editing XML text documents.

        ///Peter
      • Dave Pawson
        ... Wrong list? Try the emacs mailing list Peter? They can change it. ... I use it. Daily. Output? A book, and another 400Kword document. I ll disagree with
        Message 3 of 11 , Aug 5, 2012
        • 0 Attachment
          On 5 August 2012 16:57, Peter Flynn <peter@...> wrote:

          > Whoever set the current distributions to default to nxml-mode for
          > xml-mode broke a useful functionality, and the sooner it is either
          > undone, or someone writes proper editing controls for nxml-mode, the better.

          Wrong list? Try the emacs mailing list Peter? They can change it.

          >
          > In the meantime, the simple solution for authors and editors is to open
          > a document, use M-x sgml-mode RET and then M-x xml-mode RET. This
          > overwrites the nxml-mode setting and allows documents to be edited with
          > proper control.
          >
          > nxml-node is possibly useful for data documents, but it is not a usable
          > tool for editing XML text documents.

          I use it. Daily.
          Output? A book, and another 400Kword document.
          I'll disagree with that last statement.
          It does the job.

          regards


          --
          Dave Pawson
          XSLT XSL-FO FAQ.
          Docbook FAQ.
          http://www.dpawson.co.uk
        • Peter Flynn
          ... Yes, sorry for the rant :-) I did post a message, but no reply. ... I m actually slightly amazed. How do you deal with the absence of C-c C-e, C-c C-r,
          Message 4 of 11 , Aug 6, 2012
          • 0 Attachment
            On 06/08/12 07:48, Dave Pawson wrote:
            > On 5 August 2012 16:57, Peter Flynn <peter@...> wrote:
            >
            >> Whoever set the current distributions to default to nxml-mode for
            >> xml-mode broke a useful functionality, and the sooner it is either
            >> undone, or someone writes proper editing controls for nxml-mode, the better.
            >
            > Wrong list? Try the emacs mailing list Peter? They can change it.

            Yes, sorry for the rant :-) I did post a message, but no reply.

            > I use it. Daily.
            > Output? A book, and another 400Kword document.
            > I'll disagree with that last statement.
            > It does the job.

            I'm actually slightly amazed. How do you deal with the absence of C-c
            C-e, C-c C-r, C-RET, M-C-k, and all the other editing functions? Is
            there a shim that implements these somewhere?

            ///Peter
          • John W. Shipman
            +-- ... +-- I used to use sgml-mode but now I do everything in nxml-mode. I forget what all those keybindings meant, but I can address your need for insertion
            Message 5 of 11 , Aug 6, 2012
            • 0 Attachment
              +--
              | I'm actually slightly amazed. How do you deal with the absence of C-c
              | C-e, C-c C-r, C-RET, M-C-k, and all the other editing functions? Is
              | there a shim that implements these somewhere?
              +--

              I used to use sgml-mode but now I do everything in nxml-mode. I
              forget what all those keybindings meant, but I can address your
              need for insertion of required child elements. Back in 2007 one
              Stefano Sabatini asked a similar question. Here's my reply.

              +-- Mr. Sabatini:
              | And what about the insertion of complex skeletons, like that of a
              | variablelist? There is already some way to add them with some
              | shortcuts or is needed to hook into nxml-mode-hook all the various
              | docbook specific skeleton insertion functions required?
              +--

              My solution to this is to put together a collection of little
              template files and insert them using "C-x i". For example,
              if I'm building a variablelist, I have two template files named
              "varlist" containing the variablelist element, and a file "vle"
              containing the skeleton of a varlistentry element. Here's the
              "varlist" file:

              ================================================================
              <variablelist>
              <!--\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\-->
              </variablelist>
              ----------------------------------------------------------------

              The comment line is there to remind me to fill in the body.
              As I add each child element, I keep that comment line just
              below the element just added, so I can quickly find the
              spot where the next child element will go in. Once the
              list is complete, I'll delete the comment line.

              Here's my template file "vle" for a varlistentry:

              ================================================================
              <varlistentry>
              <term>
              <code >
              </code >
              </term>
              <listitem>
              <para>

              </para>
              </listitem>
              </varlistentry>
              ----------------------------------------------------------------

              This assumes that the terms I'm defining are in code. I have the
              </code> closing tag unindented because it's inline markup: I'll
              add the term's text after the <code> start tag, then use C-d to
              pull the </code> end tag up just after it.

              Not elegant, but I've been using it for a long time now, and
              it speeds up document creation a lot.

              There's a more detailed discussion in my locally-written nxml
              documentation:

              http://www.nmt.edu/tcc/help/pubs/nxml/

              Scroll down to the section entitled "Toward faster work".

              Best regards,
              John Shipman (john@...), Applications Specialist, NM Tech Computer Center,
              Speare 119, Socorro, NM 87801, (505) 835-5950, http://www.nmt.edu/~john
              ``Let's go outside and commiserate with nature.'' --Dave Farber
            • Dave Pawson
              ... C-e and C-a are both satisfied using
              Message 6 of 11 , Aug 6, 2012
              • 0 Attachment
                On 6 August 2012 20:24, Peter Flynn <peter@...> wrote:
                >
                >> I use it. Daily.
                >> Output? A book, and another 400Kword document.
                >> I'll disagree with that last statement.
                >> It does the job.
                >
                > I'm actually slightly amazed. How do you deal with the absence of C-c
                > C-e, C-c C-r, C-RET, M-C-k, and all the other editing functions? Is
                > there a shim that implements these somewhere?
                C-e and C-a are both satisfied using
                < for element
                and space bar for attributes.
                C-RET does split an element.
                M-C-k ? Not heard of it so I don't miss it?
                Have you read the notes James put out with the distro?
                regards




                --
                Dave Pawson
                XSLT XSL-FO FAQ.
                Docbook FAQ.
                http://www.dpawson.co.uk
              • Carsten Bormann
                ... No, that is C-c RET. Oh, and M-C-k (kill-sexp) just works for me. I make my life a little easier this way: https://gist.github.com/3282903 (Why is is that
                Message 7 of 11 , Aug 7, 2012
                • 0 Attachment
                  On Aug 7, 2012, at 08:51, Dave Pawson <dave.pawson@...> wrote:

                  > C-RET does split an element.

                  No, that is C-c RET.

                  Oh, and M-C-k (kill-sexp) just works for me.

                  I make my life a little easier this way:

                  https://gist.github.com/3282903

                  (Why is is that C-RET went away in (a recent?) Emacs 24?
                  Can't type M-TAB easily on a Mac.)

                  Grüße, Carsten
                • Steinar Bang
                  ... [snip!] ... IMO you re completely wrong here. The nxml mode is quite good for editing text type documents (I ve done docbook and DITA in it). You just
                  Message 8 of 11 , Aug 13, 2012
                  • 0 Attachment
                    >>>>> Peter Flynn <peter@...>:

                    > This is only one of a dozen or more missing facilities in nxml-mode.
                    > I'm sure nxml-mode must be useful to some people, but that does not
                    > include anyone who actually wants to write or edit a text document.

                    [snip!]
                    > nxml-node is possibly useful for data documents, but it is not a
                    > usable tool for editing XML text documents.

                    IMO you're completely wrong here. The nxml mode is quite good for
                    editing text type documents (I've done docbook and DITA in it). You
                    just have to unlearn psgml behaviour and embrace nxml behaviour.

                    But it isn't very good for data documents. For those you'd be better
                    off with some kind of tree view based editor.

                    Heh... but of course, if you won't accept that nxml can be a good text
                    document editor, then I guess the conclusion is that it is useless...;-)

                    It isn't useless to me, though.
                  • Steinar Bang
                    ... I also posted this message as a response to one of Peter s earlier attempts at nxml: http://permalink.gmane.org/gmane.emacs.nxml.general/1955 The message
                    Message 9 of 11 , Aug 13, 2012
                    • 0 Attachment
                      >>>>> "John W. Shipman" <JOHN@...>:

                      >> I'm actually slightly amazed. How do you deal with the absence of C-c
                      >> C-e, C-c C-r, C-RET, M-C-k, and all the other editing functions? Is
                      >> there a shim that implements these somewhere?

                      > I used to use sgml-mode but now I do everything in nxml-mode. I
                      > forget what all those keybindings meant,

                      I also posted this message as a response to one of Peter's earlier
                      attempts at nxml:
                      http://permalink.gmane.org/gmane.emacs.nxml.general/1955

                      The message attempts to show how you would start creating a docbook
                      document from scratch.
                    Your message has been successfully submitted and would be delivered to recipients shortly.