Hi,
Using ruby script to parse xml, I'd like to make an XPATH's like command , completelist from currentnode in xml.
This works fine and I can choose one of childnodes.
Then I call helper#XpathNavNode( to update currentnode but it fails : g:currentnode does not exists anymore.
Can you see why ?
Thank you
command! -nargs=1 -bang -complete=customlist,helper#XpathList
\ XPATH call helper#XpathNavNode("<bang>", <f-args>)
fun! helper#XpathList(A,L,P) "{{{
au CmdlineLeave * unlet! g:currentnode
if !exists('g:currentnode')
let g:currentnode=''
endif
let g:currentnode.='/'.a:A
ruby << EOF
require 'ox'
require 'open-uri'
# 0. on one xml file
xmlpath = ENV['tmp']+"/localConf.xml"
doc = Ox.parse(open(xmlpath).read)
# 1. retrieve all sorted child possible elements'name
arr = doc.root.locate('*' + Vim::evaluate('g:currentnode'))
arr_out = {}
arr.each { |a|
a.each {|key, value|
arr_out[key.value]=""
}
}
# 2.Proposal Array/Vim'List returned
Vim::command("return " + arr_out.keys().to_s )
EOF
endfunction "}}}
fun! helper#XpathNavNode(...) "{{{
" update currentnode from user's choice.
let g:currentnode=a000[1]
call feedkeys(':XPATH '.g:currentnode,'n')
endfunction "}}}
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Saturday, February 17, 2018
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment