def func(self, module, func, *args, **kwargs): """ Call remote xquery function. @module - exist module @func - function in module @args - function arguments - a, b, c @ns - namespace 'http://localhost/example/' at 'xmldb:exist:///db/example.xq' """ q = Query(self.proxy) ns_tmpl = "'http://localhost/%s/' at 'xmldb:exist:///db/%s.xq'" ns = kwargs.get("ns", None) or ns_tmpl % (module, module) context = { "module": module, "func": func, "args": ", ".join(q.parse_arg(i) for i in args), "ns": ns } qtext = """import module namespace %(module)s = %(ns)s; %(module)s:%(func)s(%(args)s)""" % context return q.send(qtext)
def xpath(self, qtext): if self.collection: qtext = "collection('%s')%s" % (self.collection, qtext) q = Query(self.proxy) return q.send(qtext)
def query(self, qtext): q = Query(self.proxy) return q.send(qtext)