notes from the mousepad - user help, free and open source

Duck, Duck, Gnu: Mallard and DocBook 5 support in Emacs

I’ve been doing some documentation work with Mallard and DocBook 5 recently, and have been looking for software that supports them well.  The trick is that both Mallard and DocBook 5 are based on RelaxNG schemas, and while there are many XML tools out there, there are few that are open source, and fewer still that support RelaxNG.

http://www.flickr.com/photos/tsmall/4226883729/sizes/s/

From flickr user tsmall. Attribution-ShareAlike 2.0 Generic license

After perusing my options, I decided to try Emacs with nXML-mode.  Emacs’ nXML-mode provides real-time validation for RelaxNG-based documents, something which no other open source authoring tool provides. But while nXML-mode can validate XML documents on-the-fly, the default installation is not set up to validate against the recently-developed Mallard and DocBook 5 schemas.

Thus, to take full advantage of the latest in duck-based documentation technologies, I needed to modify my .emacs file and the nxml-mode files themselves.  What follows is an overview of exactly what I did in the hopes that others can make use of the same changes, too.

An nXML-mode foundation

Before we get started, though, you should know that much of what follows is derived from information on this website.  I encourage you to visit the site, as it provides an introduction to how nXML-mode is configured, and enough of an introduction to using nXML-mode to make you at least modestly productive right away.

Part One: Setting up your .emacs file

The first step in setting up nXML-mode for Mallard and DocBook 5 is to make a few changes to your .emacs file.  If you are new to Emacs, your .emacs file sits in your home directory, and serves as a personalized Emacs configuration file.  You may need to create the .emacs file if it doesn’t already exist.

;; /usr/share/emacs/site-lisp/tcc-nxml-emacs:  Add these lines
;;      to your .emacs to use nxml-mode.  For documentation of
;;      this mode, see http://www.nmt.edu/tcc/help/pubs/nxml/
;;--
;; Add the nxml files to emacs's search path for loading:
;;--
(setq load-path
      (append load-path
              '("/usr/share/emacs/site-lisp/nxml/")))
;;--
;; Make sure nxml-mode can autoload
;;--
(load "/usr/share/emacs/site-lisp/nxml/rng-auto.el")

;;--
;; Load nxml-mode for files ending in .xml, .xsl, .rng, .xhtml .page
;;--
(setq auto-mode-alist
      (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\|page\\)\\'" . nxml-mode)
            auto-mode-alist))

The above .emacs configuration tells Emacs where to look for detailed XML processing instructions, and also causes Emacs to automatically use nXML-mode for XML-related files.  (Did I tell you that Emacs might have a bit of a learning curve?  Yeah, that’s true.)

Part Two: Modifying the nXML-mode configuration files

The second step is to modify the nXML-mode configuration files themselves. This will add the appropriate nXML-mode secret sauce to handle Mallard and DocBook 5 documents.

Fortunately for you, I grabbed the latest nXML-mode source files from the nXML-mode website, and made the appropriate modifications myself.  You can download my customized nXML-mode files from this archive.

Here’s what I changed from the default setup:

  • I added the docbookxi.rnc and mallard-1.0.rnc schemas to the schemas directory
  • I modified the schemas.xml file, thus including the docbookxi.rnc and mallard-1.0.rnc schemas as part of the XML-validation process.

Note that I have used the DocBook 5 “docbookxi.rnc” schema which allows for xinclude functionality.  If you want to use the schema that does not allow for use of xinclude features, you’ll need to adjust the files accordingly.  The current DocBook 5 schemas are available here.

Part Three: Copy your nXML-mode files to the proper location
The final step is to copy the nXML-mode files to the proper location on your file system.  As indicated in our .emacs file, that location is:  /usr/share/emacs/site-lisp/nxml/.  Thus, you should copy all of the files in the downloaded “nxml” folder into that directory.  You will need administrative privileges (using root or sudo) to do this.

Wrapping up

That’s it, though.  You should now have a functioning nXML-mode environment that will allow you to fire-up Emacs and start writing Relax-NG-based documents, getting all of the real-time-validation features that Emacs provides. If you can think of any ways in which I could improve my approach, please let me know.  Otherwise, I encourage you to head-on over to the nXML-mode website, and view some of the nXML-mode information and resources that are available as you get started.

Upcoming FLOSS-related Events in the Midwest

Here’s a quick rundown of some upcoming Free and Open-Source software events in the Chicagoland / greater-midwest area. Saturday and Sunday, August 21 and 22, 2010: Barcamp Chicago Running all day and night this Saturday and Sunday 215 E. Ohio Street in downtown Chicago Numerous presentations, and a “BarCompany” startup hackathon Sunday, August 29: Ubuntu [...]

Read all »

Thanks, Debian!

Today is Debian’s 17th birthday*, and with that comes Debian Appreciation day!  Do you want to give them some thanks for the super work that they do?  Just head over to thank.debian.net, and leave them a few words to express your gratitude. You can even search for your favorite package, team, or packaging team, and [...]

Read all »

Updating the Ubuntu Packaging Guide

We’d like to get your input on where to focus documentation efforts on the Ubuntu Packaging Guide. There are all kinds of topics that need to be written, updated, or improved — so where should we start? What do you need most? Give your input via the this Google Docs Survey. I’ve provided some direction [...]

Read all »

Dear Yahoo!

Dear Yahoo! Welcome to Ubuntu! As a regular contributor to the Ubuntu project, I think it’s great that you are partnering with Canonical.  Because of the agreement you signed, Canonical will be able to hire more people to work on Free software.  Also, your contributions will help Ubuntu continue offering their OS at no cost [...]

Read all »

Thunar 1.1.0 – Native support for remote filesystems

Congratulations to Jannis Pohlmann on the release of Thunar 1.1.0!  For those who don’t know, Thunar is the Xfce file manager, and this release marks a major milestone for Thunar and for the Xfce project.  Why is this release so noteworthy?  With this new version of Thunar, users will be able to access networked file [...]

Read all »

Xubuntu team meeting – Sunday, January 10 at 20:00 UTC

The Xubuntu team will be holding a meeting this Sunday, January 10th, at 20:00 UTC, and all are welcome to attend. The primary focus of this meeting will be on team governance, as Cody Somerville is transitioning out of his role as primary project leader.  With that, we’ll be discussing changes to the Xubuntu Strategy [...]

Read all »

Writing a good dent (or tweet) while at a conference

The next Ubuntu Developer Summit will be starting up tomorrow, and although not everyone can attend the event, there are a number of ways to participate remotely. Among other things, I like to follow the ‘dents (from Identi.ca) and tweets (from Twitter) from the event.  Typically, people will use Identi.ca and Twitter to share snippets [...]

Read all »

Call for Testing – Xubuntu 9.10 Release Candidate

Ara Pulido sent this message out to the Xubuntu-Users mailing list the other day, and I thought it was worth passing along to the greater Ubuntu community.  Testing for the Xubuntu 9.10 release candidate is going on now, so please read the email below and help out if you can.  Thanks!

Read all »

Top 50 technical writers on the web + Xfce and Xubuntu doc updates

This site lists who they’ve identified as the top 50 technical writers on the web, which I stumbled upon via a link from Scott Nesbitt’s blog.  While this list will certainly provide me with additional documentation resources, I notice a dearth of open-source documentation names in that list.  No Shaun McCance, no Emma Jane Hogbin, [...]

Read all »

Site Archive

Browse