Monday, July 17, 2006

MarkLogic XCC + IronPython = Sweet!

At work we're using MarkLogic to store and transform our XML content. You use XQuery to access the data, which has been pretty fun to learn. While looking at the release notes for MarkLogic 3.1-2, I saw that they've released the .NET version of their new XCC API for connecting with the server.

I've meant to start playing with IronPython for a while. And I've also meant to start learning C#/.NET stuff. So, I thought I'd try running the MarkLogic XCC.Net examples via IronPthon.

And, it works! Woohoo! Not that it does much yet...

import clr
clr.AddReferenceToFile("MarklogicXcc.dll")

import Marklogic.Xcc

import System

import os

doc = 'hamlet.xml'

#replace connection info and marklogic db name
contentSource = 'xcc://USER:PASSWORD@HOST:PORT/MLDBNAME'

print "Loading document ..."
Marklogic.Xcc.Examples.ContentLoader.Main(
System.Array[System.String](
[contentSource ,doc]
)
)

print "Fetching document ..."
Marklogic.Xcc.Examples.ContentFetcher.Main(
System.Array[System.String](
[contentSource,os.path.abspath(doc).replace('\\','/'),'-o','hamlet_fetched.xml']
)
)
print "Done."

Our collection of XSLT/XQuery/Java applications is a pain to deploy and do quick interactive testing against. Hopefully being able to script it with IronPython -- and maybe provide a nice interface with Windows Forms -- will allow quicker turnaround times.

No comments: