Greetings from Zorba Labs!
Users are often using Zorba from different host languages. We usually see the C++ and Java APIs being used to integrate XQuery with core components. That’s the case of the 28msec platform for instance. The PHP, Python, and Ruby APIs are fairly popular for integrating Zorba into web applications. In the Zorba team, our favorite programming language is XQuery and we use XQuery as an host language for XQuery as much as possible ;-)
In the 2.5 release, we worked on several improvements to these APIs. The most important one is probably the addition of the XQJ API. XQJ is the de facto standard API for using XQuery from Java and it enables Zorba to be integrated into many components that are already using XQJ. The Ruby, Python, and Java API are also containing several enhancements in 2.5. If you want to know how to install these bindings, you can look directly in our documentation for the different languages availables.
If you take a look to the documentation, you will have a clear perspective of which are your possibilities with Zorba, but we have to say that the most remarkable changes that we included in this release come with the ItemFactory class and XmlDataManager class. TheItemFactory now is able to produce most of the data types supported by XQuery. And with the inclusion of the XmlDataManager, we added the ability to manage collections and documents. Here is an small example in Python using the collection manager:
import sys
sys.path.insert(0, 'C:\..path_to_zorba_python_lib')
import zorba_api
store = zorba_api.InMemoryStore_getInstance()
zorba = zorba_api.Zorba_getInstance(store)
xmlManager = zorba.getXmlDataManager()
collectionManager = xmlManager.getCollectionManager()
itemFactory = zorba.getItemFactory()
name = itemFactory.createQName("http://www.zorba-xquery.com/", "aaa")
collectionManager.createCollection(name)
isAdded = collectionManager.isAvailableCollection(name)
if isAdded :
collection = collectionManager.getCollection(name);
data = xmlManager.parseXMLtoItem("<books>Book 1Book 2");
itemSequence = zorba_api.ItemSequence(data)
collection.insertNodesLast(itemSequence)
zorba.shutdown()
zorba_api.InMemoryStore_shutdown(store)
Same example in Ruby:
require 'C:\..path_to_zorba_ruby.so'
store = Zorba_api::InMemoryStore.getInstance()
zorba = Zorba_api::Zorba.getInstance(store)
xmlManager = zorba.getXmlDataManager()
collectionManager = xmlManager.getCollectionManager()
itemFactory = zorba.getItemFactory()
name = itemFactory.createQName("http://www.zorba-xquery.com/", "aaa")
collectionManager.createCollection(name)
isAdded = collectionManager.isAvailableCollection(name)
if isAdded :
collection = collectionManager.getCollection(name)
data = xmlManager.parseXMLtoItem("<books>Book 1Book 2")
itemSequence = Zorba_api::ItemSequence.new(data)
collection.insertNodesLast(itemSequence)
end
zorba.shutdown()
Zorba_api::InMemoryStore.shutdown(store)
The documentation covers this in more detail, so take a look and please tell us about your experience with these new features. All comments and suggestions are very welcome! Let us know if you have a suggestion for any other language.
Cheers!