Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XQuery library under Python [closed]

Tags:

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?

like image 998
Ooki Avatar asked Jan 25 '10 16:01

Ooki


1 Answers

Sort of ...

Looking through the W3C implementations list for XQuery there is:

  1. Python bindings for Zorba
  2. Sedna is a free native XML database with API for Python.

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.

like image 200
Aiden Bell Avatar answered Sep 17 '22 14:09

Aiden Bell