Showing posts with label relax-ng. Show all posts
Showing posts with label relax-ng. Show all posts

Wednesday, August 10, 2011

nXML mode – James Clark's page (i.e. the author's)

nXML mode

nXML mode : use describe-mode within emacs

That's the nicest and briefest description, that I know.
What a pity, that I haven't been able to find it online so far.

But here it is:


nXML mode:
Major mode for editing XML.

Syntax highlighting is performed unless the variable `nxml-syntax-highlight-flag' is nil.

C-c C-f finishes the current element by inserting an end-tag.
C-c C-i closes a start-tag with `>' and then inserts a balancing end-tag leaving point between the start-tag and end-tag.
C-c C-b is similar but for block rather than inline elements: the start-tag, point, and end-tag are all left on separate lines.
If `nxml-slash-auto-complete-flag' is non-nil, then inserting a `

<C-return> performs completion on the symbol preceding point.

C-c C-d uses the contents of the current buffer to choose a tag to put around the word preceding point.

Sections of the document can be displayed in outline form.  The variable `nxml-section-element-name-regexp' controls when an element is recognized as a section.  The same key sequences that change visibility in outline mode are used except that they start with C-c C-o instead of C-c.

Validation is provided by the related minor-mode `rng-validate-mode'. This also makes completion schema- and context- sensitive.  Element names, attribute names, attribute values and namespace URIs can all be
completed. By default, `rng-validate-mode' is automatically enabled by `rng-nxml-mode-init' which is normally added to `nxml-mode-hook'. You can toggle it using C-c C-v.

TAB indents the current line appropriately. This can be customized using the variable `nxml-child-indent' and the variable `nxml-attribute-indent'.

C-c C-u inserts a character reference using the character's name (by default, the Unicode name). C-u C-c C-u inserts the character directly.

The Emacs commands that normally operate on balanced expressions will operate on XML markup items.  Thus C-M-f will move forward across one markup item; C-M-b will move backward across one markup item; C-M-k will kill the following markup item; C-M-@ will mark the following markup item.  By default, each tag each treated as a single markup item; to make the complete element be treated as a single markup item, set the variable `nxml-sexp-element-flag' to t.  For more details, see the function `nxml-forward-balanced-item'.

C-M-u and C-M-d move up and down the element structure.

Many aspects this mode can be customized using M-x customize-group nxml RET.

EmacsWiki: Nxml Mode Schemas

EmacsWiki: Nxml Mode Schemas

Thursday, December 9, 2010

editing JRXML in emacs using nxml-mode

Just created an RELAG-NG ("compact") grammar for editing JRXML files.

I used trang for that, and the "input module" was a sample JRXML file. Yes, that means: occasionally some JRXML file will have tags or attributes, that my jasperreport.rnc does not know yet. But then re-running trang on an additional sample file is not really a big job.

I really love editing XML.

I re-ordered and "grouped" the XML pieces for the elements in my sample reports. That helps to clean up some things, that got a little messy over the time. In the end you recognize, how much duplicate code you have.

You may want to fight the redundancy problems through JRXML subreports.
I actually made my JRXML a "here document" for a shell script. A couple of hours later I knew, that a perl script is the better approach. Another couple of hours later there were plenty little parameterized "here documents". I have solved my redundancy problem here through "looping over lists of configurations".

Monday, July 26, 2010

mind mapping using Free Mind and emacs and its nXML-mode

I got my quick introduction to Free Mind by son#1 (13yrs) today. Of course I am a stressful student. Of course he is not an advanced user. But we are doing well together.

We didn't manage to get a cloud removed other then by undo. And of course you don't want to make use of undo, if the doing happing an eternity ago.

As expected Free Mind's file format is XML in its very own dialect.

So removing the cloud within the XML was an obvious option. Trang helped me to derive a RELAX-NG grammar from the example. The  compact version of that grammar for use with nXML-mode is not perfect, but improving it doesn't look difficult.

The first thing to do in emacs was obviously tidying the indentation. It was then, that the grammar showed, how imperfect it is. But easy to fix. And it was trival to remove the cloud.

Saturday, July 10, 2010

editing XML documents in emacs using nxml-mode

One good reason for not not authoring in XML is not having a suitable editor or IDE. I personally use and recommend emacs and James Clark's nxml-modeI create and modify all sorts of XML documents this way. If you supply nxml-mode with the right schema for your document, nxml-mode can even help you with tag completion and document validation. nxml-mode makes use of schemas in RELAX-NG, co-created by James Clark. RELAX-NG schemas are rather easily created, if not yet just available, as for DocBook, DocBook Website, DocBook Slides, and many, many other XMLs.

"Trang" is your tool for creating a RELAX-NG schema:
  • if you want to convert a DTD into a RELAX-NG schema,
  • if you want to derive a RELAX-NG schema from a couple of XML files of a specific kind,
I have done that a dozen times, it does work.

Here you find nxml-mode's manual page.

Your mileage may vary …

Sunday, June 27, 2010

bulk upload of events in XML at XING

At this link XING tells us, that they accept XML files in a certain format for uploading events to their site. They supply us with some nice but rather informal documentation in PDF, but there is no schema. Now that made me a little curious today, I downloaded their template file, created a few variants of the sample entry, and running trang I created a RELAX-NG schema file (anybody interested?). trang seems to not recognise date-time values of tags, so that always needs a little manual post-processing.
O, yes, I proudly uploaded one such event that way. (Actually on the first attempt I got the year wrong, that was quite embarrassing.)

Friday, January 18, 2008

my favourite RSS reader: SAGE within Firefox

I remember, I haven't told you yet, how I read my RSS subscriptions. I am using SAGE.
It has an XML based exchange format called OPML, which is actually just a format for listing outlines of books, articles, whatever, and apart from the SAGE aspect: I love to edit OPML in emacs's nxml mode. Let me know, if you are interested in the RELAX NG grammar, that I created for that purpose.
The major advantage of being integrated into a web browser is, that the RSS subscriptions come as a standard live bookmark tree and URLs are opened nicely in web browser tabs. Of course, all the articles you already visited are displayed no longer in bold, so you won't revisit them unknowingly.