Here is how I'd go about it. First, I'd use a simple xml-parsing script to print out the paths. Here's one I came up with (you can easily write one of your own using perl, or just use this one):
# xml_paths.py
import sys
from xml import sax
class PathHandler(sax.handler.ContentHandler):
def __init__(self):
self.path = []
def startElement(self, name, attrs):
if name == 'key':
self.path.append(attrs['name'])
print '/'.join(self.path)
def endElement(self, name):
if name == 'key':
self.path.pop()
sax.parse(sys.argv[1], PathHandler())
Finally, complete
it (you should use absolute paths to the script and the xml file):
% complete A 'p#*#`python xml_paths.py a.xml`#'
% A <TAB>
c1 c2 c3 c3/c3-b2 c3/c3-b2/c3-xdr
% A c3/<TAB>
c3/c3-b2 c3/c3-b2/c3-xdr
% A c3/c3-b2
For clarity, this is the output of the xml-parsing script:
% python xml_paths.py a.xml
c1
c2
c3
c3/c3-b2
c3/c3-b2/c3-xdr