Saturday, March 21, 2009

LEESA: A new way of typed XML programming in C++

Some of my recent research work has focused on developing a highly generic and reusable library for complex object structure traversal, which is best exemplified by schema driven XML programming. I'm glad to present a research paper called LEESA: Embedding Strategic and XPath-like Object Structure Traversals in C++, which will be published in the proceedings of IFIP Working Conference on Domain Specific Languages (DSL WC), 2009 at Oxford, UK. LEESA stands for Language for Embedded quEry and traverSAl. LEESA has advanced the state-of-the-art of the typed XML programming in standard C++ to a level where many benefits of static type analysis can be maintained while enjoying a succinct syntax similar to that of XPath. Below, a quick motivating example of LEESA that sorts and prints the names of the authors in a XML book catalog is shown.

Catalog() >> Book() >> Author() >> Sort(Author(), LastNameComparator) >> ForEach(Author(), print);

The key thing to be noted here is that it is not a string encoded query. In fact, the C++ compiler checks the compatibility of this expression against the book catalog XML schema at compile-time! LEESA uses Expression templates idiom to achieve this highly intuitive, XPath-like syntax. Overall, LEESA's implementation is an exciting combination of generic programming, operator overloading, expression templates, C++ metaprogramming, Boost MPL, C++0x Concepts, and heck a lot of template hackery to make all the things work together! Interesting details are presented in the paper mentioned above.

The source code of LEESA is available. However, LEESA's current implementation is based on Universal Data Model (UDM 3.2.1) -- a full-fledged code generator for model-driven development that can be used as a XML schema compiler. Other code generators could be used provided they are extended to produce the necessary layers of abstraction described in the paper.

In the upcoming posts, I plan to document some of my experiences of developing LEESA.

14 comments:

Sudarshan said...

This is amazing. Is the source code available? It will be great if this becomes part of Boost.

Sumant said...

I would love to see that happen! However, LEESA's dependence on an external code generator might pose a limitation in its adoption as a "standard" boost library.

John Torjo said...

This looks all cool and all, but a bit of compilation times would help ;)
Usually these (compilation times) are extremely slow... And that's what bugs me...

Sudarshan said...

Could you please distribute this separately from COSMIC?

Sumant said...

The source code of LEESA is available separately. However, LEESA's current implementation is based on Universal Data Model (UDM 3.1.3) -- a full-fledged code generator for model-driven development that can be used as a XML schema compiler/code generator. Other code generators could be used provided they are extended to produce the necessary layers of abstraction described in the paper.

Sumant said...

LEESA was presented this week in the Working Conference on Domain Specific Languages 2009 in Oxford, UK. The slides are available in PPT format. The talk was followed by a great discussion and a set of very insightful questions.

C++ Code Samples said...

Thanks for the tips, can you check out my C++ Code Samples too?

Sumant said...

A new follow-up technical report on LEESA is now available: Toward Native XML Processing Using Multi-paradigm Design in C++. It reports on the compilation times and the run-time performance of LEESA.

Sumant said...

LEESA homepage contains more resources.

piperpan said...

Looks interesting. I wonder what the rationale is for using operator>> rather than operator/ - This is XPath afterall.

Sumant said...

In XPath / is just a separator but has separate "child:", "parent:", "sibling:" to identify axes. If nothing is specified "child:" is default in XPath. So you could say "child:book/author/parent:book/child:title" in XPath.

LEESA takes a different approach based on operator overloading because that's what C++ does well. In LEESA >> means XPath's "child:", << means XPath's "parent:". Moreover LEESA supports >>= and <<= for depth-first traversal. For more information see slide #24 in http://www.dre.vanderbilt.edu/~sutambe/documents/pubs/ppt/LEESA-BoostCon.pdf

However, it is not hard to imagine a C++ library which tries to mimic XPath more closely by using syntax like "child<book>()/author()/parent<book>()/child<title>()".

Ecommerce website development said...

Now a days using XML we can focus on developing a highly generic and reusable libraries through C++ programming.This definitely improves development in the external code generator.

android developers said...

Thanks for providing this good informative post and i got a good knowledge from your blog, i think most of the peoples are get good benefited from this information.

xander345 said...

if you like c++ you can compile it online here: http://codecompiler.info/

32, 64 - windows & Linux - and more programming languages