Vim as XML Editor: About
... this howto.
The HTML pages should be pretty accessible, as listed on www.pinkjuice.com/check/.
Access Keys
-
n -
next page
-
p -
previous page
-
i -
index page
[alt-n]
to go to the next page,
and
[alt-p]
to come back.
In other browsers such as
IE6,
the access keys just give focus to the associated link,
so the sequence becomes
[alt-n] [enter].
Most importantly, you should be familiar with Vim. If that's not the case, check out the next section and come back in a few days.
-
First you should make sure that you have the latest version of Vim. Vim is available for many OSs, check www.vim.org/download.php. I recommend to use GVim, the GUI version of Vim, unless you're in a remote shell session.
-
Vim comes with a tutorial. After firing up Vim, enter :help tutor. One way to start with it is to read it into the buffer
optionally delete the first line via:read $VIMRUNTIME/tutor/tutor, then write it to some fileggdd:writedel/vim_tutorial.txt -
Vim comes with lots of documentation which you can consult while working with Vim. Simply enter :help.
-
More documentation including the FAQ is listed on www.vim.org/docs.php.
-
There's a book about Vim titled "Vi IMproved - Vim" (New Riders Publishing, Author: Steve Oualline, ISBN: 0735710015). You can buy it through the book page on iccf-holland.org. A list of errata is listed on the publisher's page (search www.newriders.com/ for "vim") and the creator of Vim Bram Moolenaar also maintains a list of errata.
All instructions are just examples,
TMTOWTDI.
For example:
To move the cursor upwards I use
[up], others use k.
Notation
2 G [ctrl-v] [down] x.
All commands are to be entered in normal mode.
Insert mode commands start with an i,
command line ones start with a :.
Longer commands that are to be entered in Vim's command line are
written like this:
:'<,'>s/<span\_s\+class="bold">\(\_.\{-}\)<\/span>/<em>\1<\/em>/g
In key sequences like this one
each group of non-space characters stands for one key press.
If a space is to be entered it is listed as [mapleader] x i < c h a p t e r > > [up][space].
Vim commands and option names most often have a full and an abbreviated version. When using Vim I use the short versions, eg :h for :help, :w for :write, :q for :quit, etc. In the howto I sometimes use the full versions because they explain themselves better.
Mappings in Vi can be specified to start with
<Leader>,
which is a variable that can be set in the
vimrc;
see
:help
mapleader.
If you did set your mapleader to some character other than
the default (\),
use this character instead wherever
[mapleader]
is written.
I don't use the notation used in Vim scripts
because I think it's not very descriptive.
If you want to use some of the commands in your Vim scripts,
you must translate the
function keys,
eg
[enter]
to <CR>
and
[backspace]
to <BS>.
$ cd foo
The prompt character $ may indicate that the
command is Linux-specific, and a > before a
command may mean that the command is Windows-specific (to be entered
in the "MS-DOS Prompt"). If there is
no prompt character the command should work on at least both
OSs.Terminology
Vim
The Vim download page contains instructions and offers various formats.
If your distro came with sample files containing Vim settings you might want to disable them, eg by appending .bak to their name or by moving them to some backup directory. :version lists these files.
$ wget -q \
> ftp://ftp.de.vim.org/unix/vim-6.3.tar.bz2
$ tar -xjf vim-6.3.tar.bz2
$ cd vim63/
$ ./configure \
> --prefix=$HOME/bulk/run/vim/6_3 \
> --with-features=big \
> --enable-gui=gtk2 \
> --with-compiledby='tobiasreif pinkjuice com' \
> --enable-rubyinterp \
> 2>&1 | tee > config.log
$ make 2>&1 | tee > make.log
$ make test 2>&1 | tee > test.log
$ make install 2>&1 | tee > install.log
$ ed
a
#!/usr/bin/env sh
${HOME}/bulk/run/vim/6_3/bin/vim "$@"
.
w /home/tobi/data/commands/vim
56
q
$ ed
a
#!/usr/bin/env sh
${HOME}/bulk/run/vim/6_3/bin/gvim "$@"
.
w /home/tobi/data/commands/gvim
57
q
$ chmod 700 ~/data/commands/vim
$ chmod 700 ~/data/commands/gvim
$ vim --version | head -n 3
VIM - Vi IMproved 6.3 (2004 June 7, compiled Jun 10 2004 15:19:15)
Compiled by tobiasreif pinkjuice com
Big version with GTK2 GUI. Features included (+) or not (-):
$ ed ~/.bashrc
256
/EDITOR/
export EDITOR='/usr/bin/vim'
s/'.\+$/'\/home\/tobi\/data\/commands\/vim'/p
export EDITOR='/home/tobi/data/commands/vim'
wq
272
$ rpm -v --test --erase gvim
$ rpm -v --test --erase kvim
$ su root
Password:
# rpm -v --erase gvim
# rpm -v --erase kvim
# rpm -v --test --erase vim
# rpm -v --erase vim
# SuSEconfig
# exit
$ ed ~/.bashrc
272
a
MANPATH=$HOME/bulk/run/vim/6_3/man:$MANPATH
export MANPATH
.
wq
332
$ source ~/.bashrc
$ man vim
Reformatting vim(1), please wait...
Then I made vim available to root:
$ su -
Password:
# vim
-bash: vim: command not found
# ed .bashrc
16
a
alias vim='/home/tobi/bulk/run/vim/6_3/bin/vim'
.
wq
66
# vim
-bash: vim: command not found
# source .bashrc
# vim
# exit
logout
$
TMTOWTDI.
Tools
-
Ask your package manager, try it on the command line: Is the tool already installed? Is it up to date?
-
Otherwise check if there's a sufficiently recent package (eg .deb or .rpm) supplied by your distro project or vendor...
-
... or by the project itself ...
-
... or by a third party, if you trust it. In this and the former case it makes sense to check if there's a package specifically for your distro and -version.
-
Otherwise you could get the source from the project web site then compile and install via some variation of the common ./configure;make;make install command sequence . If you don't want to risk conflicts caused by systemwide installation you can install the tool as user somewhere under your home directory, by omitting make install or by overriding the default installation directory.
Or the project might provide a binary for your platform.
Here are the DBX sources and the pics.
Note
This howto deals with XML editing thus does not deal with setting up a DocBook publishing environment. DBX documents and schemas are used as examples representing XML languages in general. Explaining how to get (X)HTML or PDF from DBX is outside the scope of this howto. Getting started is simple, but typically there's a lot more to it. For example if you use the docbook.sf.net XSLTs check out Bob Stayton's DocBook XSL: The Complete Guide.
DBX to XHTML
- purely structural
-
no presentational markup
- used appropriately
-
regarding semantics and structure (no tables except for tabular data, etc)
- valid XHTML 1.0 Strict
-
not so difficult, since I only use a subset of DocBook
- accessible
-
implementing many but not all WAI guidelines (WCAG 1.0)
- very incomplete,
- not general or flexible enough,
- and quirky to set up and run,
The XSLTs are under the GPL. A rewrite of the DocBook to XHTML XSLT set will be at www.pinkjuice.com/joocs/.
Note
If you're looking for XSLTs that you can use to transform any DocBook document to various formats, you might want to check out the docbook.sf.net XSLTs. They are very complete and have various customization hooks. The project provides packaged releases, and most importantly, it provides support.
Joocs might become an alternative to existing packages in the future, but it will be a while before Joocs supports all of DBX. It only supports XHTML output and will only be interesting for a subset of scenarios.
DBX to XSLFO to PDF
I use the docbook.sf.net XSLTs to get XSLFO from DBX. Here is the customization layer and here are the XSLFO and PDF files. FOP was used to get PDF from the XSLFO.






