Is there any existing way to run XQuery under python? (not starting to build a parser yourself in other words).
I got a ton of legacy XQuery that I want to port to our new system, or rather I want to port the framework and not XQuery.
Therefore: Is there any library that allows me to run XQuery under python?
Sort of ...
Looking through the W3C implementations list for XQuery there is:
A few Python examples with Zorba, from here
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With