Monday, January 24, 2011

Re: XML validation

On 1/23/2011 9:12 AM, Florian Weimer wrote:
Are their VIM extensions which enable editing XML files with validation, schema-driven auto-completion, and so on? 

I use xmlint (but my requirements maybe less than yours).

I placed the following in this file:
    vimfiles\after\ftplugin\xml.vim
    .vim\after\ftplugin\xml.vim


" XML/XSL formatting
setlocal shiftwidth=2

" Use the open source tool to veryify XML/XSL
compiler xmllint

" Use the open source tool to reformat the document
" Double quote the filename if on windows
if has('win32')
    vnoremap <buffer> <Leader>xf :!xmllint --format "-"<CR>
    nnoremap <buffer> <Leader>xf :.,.!xmllint --format "-"<CR>
else
    vnoremap <buffer> <Leader>xf :!xmllint --format -<CR>
    nnoremap <buffer> <Leader>xf :.,.!xmllint --format -<CR>
endif




Then I made sure xmllint is in my path somewhere (which Vim can reach).

You can download xmllint from http://xmlsoft.org/downloads.html with the libxml2 software package.
I use it on Windows, though most of the stuff you see if for *nix.


HTH,
Dave


No comments: