本文介绍了Python的下的XQuery库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿嘿
是否有任何现有的方式下运行的python的XQuery? (未开始建立换句话说解析器自己)。

HeyIs there any existing way to run XQuery under python? (not starting to build a parser yourself in other words).

我有一吨遗留的XQuery的,我想移植到我们的新系统,或者更确切地说,我想
端口框架,而不是XQuery的。

I got a ton of legacy XQuery that I want to port to our new system, or rather I want toport the framework and not XQuery.

因此​​:有没有可以让我的python下运行的XQuery库

Therefore: Is there any library that allows me to run XQuery under python?

推荐答案

排序... ...

翻翻有:



  1. ,但可能不是你后

  1. Python bindings for Zorba
  2. Sendna, but might not be what you're after

几个Python示例与左巴,从这里 p>

import sys
import zorba_api

def example1(zorba):
  xquery = zorba.compileQuery("1+2")
  print xquery.printPlanAsXML()
  print xquery.execute()
  return

def example2(zorba):
  xquery = zorba.compileQuery("(1,2,3,4,5)")
  iter = xquery.iterator()
  iter.open()
  item = zorba_api.Item_createEmptyItem()
  while iter.next(item):
    print item.getStringValue()
  iter.close()
  iter.destroy()
  return

def example3(zorba):
  try:
    xquery = zorba.compileQuery("1 div 0")
    print xquery.execute()
  except RuntimeError, e:
    print e
  return

有可以是其中可以很容易地结合到Python的C实现。希望这可以帮助,我有点惊讶地看到这么几个实现。虽然XQuery是不是最期望的XML工具,我想。

There may be C implementation in that list which can easily be bound to Python. Hope this helps, I was somewhat surprised to see so few implementations. Although, XQuery isn't the most desired of the XML tools I suppose.

这篇关于Python的下的XQuery库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 17:09