LEESA: Embedding Strategic and XPath-Like Object Structure Traversals in C++

  • Sumant Tambe
  • Aniruddha Gokhale
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5658)


Traversals of heterogeneous object structures are the most common operations in schema-first applications where the three key issues are (1) separation of traversal specifications from type-specific actions, (2) expressiveness and reusability of traversal specifications, and (3) supporting structure-shy traversal specifications that require minimal adaptation in the face of schema evolution. This paper presents Language for Embedded quEry and traverSAl (LEESA), which provides a generative programming approach to address the above issues. LEESA is an object structure traversal language embedded in C++. Using C++ templates, LEESA combines the expressiveness of XPath’s axes-oriented traversal notation with the genericity and programmability of Strategic Programming. LEESA uses the object structure meta-information to statically optimize the traversals and check their compatibility against the schema. Moreover, a key usability issue of domain-specific error reporting in embedded DSL languages has been addressed in LEESA through a novel application of Concepts, which is an upcoming C++ standard (C++0x) feature. We present a quantitative evaluation of LEESA illustrating how it can significantly reduce the development efforts of schema-first applications.


Object Constraint Language Object Structure Time Object Adaptive Programming Class Template 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Thompson, H.S., Beech, D., Maloney, M., Mendelsohn, N., et al.: XML Schema Part 1: Structures. W3C Recommendation (2001)Google Scholar
  2. 2.
    Sztipanovits, J., Karsai, G.: Model-Integrated Computing. IEEE Computer 30(4), 110–112 (1997)CrossRefGoogle Scholar
  3. 3.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading (1995)zbMATHGoogle Scholar
  4. 4.
    Lämmel, R., Visser, E., Visser, J.: The Essence of Strategic Programming, p. 18 (October 15, 2002),
  5. 5.
    Ovlinger, J., Wand, M.: A Language for Specifying Recursive Traversals of Object Structures. SIGPLAN Not. 34(10), 70–81 (1999)CrossRefGoogle Scholar
  6. 6.
    Gray, J., Karsai, G.: An Examination of DSLs for Concisely Representing Model Traversals and Transformations. In: 36th Hawaiian International Conference on System Sciences (HICSS), pp. 325–334 (2003)Google Scholar
  7. 7.
    Mernik, M., Heering, J., Sloane, A.M.: When and How to Develop Domain-specific Languages. ACM Computing Surveys 37(4), 316–344 (2005)CrossRefGoogle Scholar
  8. 8.
    Czarnecki, K., O’Donnell, J., Striegnitz, J., Taha, W.: DSL Implementation in MetaOCaml, Template Haskell, and C++. In: Domain Specific Program Generation 2004, pp. 51–72 (2004)Google Scholar
  9. 9.
    Seefried, S., Chakravarty, M., Keller, G.: Optimising Embedded DSLs using Template Haskell (2003)Google Scholar
  10. 10.
    Balland, E., Brauner, P., Kopetz, R., Moreau, P.E., Reilles, A.: Tom: Piggybacking Rewriting on Java. In: Baader, F. (ed.) RTA 2007. LNCS, vol. 4533, pp. 36–47. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  11. 11.
    Visser, J.: Visitor Combination and Traversal Control. In: OOPSLA 2001: Proceedings of the 16th ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications, pp. 270–282 (2001)Google Scholar
  12. 12.
    Lämmel, R., Visser, J.: Typed Combinators for Generic Traversal. In: Krishnamurthi, S., Ramakrishnan, C.R. (eds.) PADL 2002. LNCS, vol. 2257, pp. 137–154. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  13. 13.
    Lieberherr, K.J.: Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns. PWS Publishing Company (1996)Google Scholar
  14. 14.
    Lieberherr, K., Patt-shamir, B.: Traversals of Object Structures: Specification and Efficient Implementation. ACM Trans. Program. Lang. Syst., 370–412 (1997)Google Scholar
  15. 15.
    Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools, and Applications. Addison-Wesley, Reading (2000)Google Scholar
  16. 16.
    World Wide Web Consontium (W3C): XML Path Language (XPath), Version 2.0, W3C Recommendation (January 2007),
  17. 17.
    Visser, E., Benaissa, Z., Tolmach, A.: Building Program Optimizers with Rewriting Strategies. In: Proceedings of the International Conference on Functional Programming (ICFP 1998), pp. 13–26. ACM Press, New York (1998)Google Scholar
  18. 18.
    Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series). Addison-Wesley Professional, Reading (2004)Google Scholar
  19. 19.
    Gregor, D., Järvi, J., Siek, J., Stroustrup, B., Reis, G.D., Lumsdaine, A.: Concepts: Linguistic Support for Generic Programming in C++. In: Proceedings of the Object Oriented Programming, Systems, Languages, and Applications (OOPSLA), pp. 291–310 (2006)Google Scholar
  20. 20.
    Siek, J.G., Lumsdaine, A.: C++ Concept Checking. Dr. Dobb’s J. 26(6), 64–70 (2001)Google Scholar
  21. 21.
    Portland Pattern Repository WikiWikiWeb: Hierarchical Visitor Pattern (2005),
  22. 22.
    Simeoni, F., Lievens, D., Connor, R., Manghi, P.: Language Bindings to XML. IEEE Internet Computing, 19–27 (2003)Google Scholar
  23. 23.
    Magyari, E., Bakay, A., Lang, A., Paka, T., Vizhanyo, A., Agrawal, A., Karsai, G.: UDM: An Infrastructure for Implementing Domain-Specific Modeling Languages. In: The 3rd OOPSLA Workshop on Domain-Specific Modeling (October 2003)Google Scholar
  24. 24.
    Veldhuizen, T.: Expression Templates. C++ Report 7(5), 26–31 (1995)Google Scholar
  25. 25.
    Tambe, S., Gokhale, A.: An Embedded Declarative Language for Hierarchical Object Structure Traversal. In: 2nd International Workshop on Domain-Specific Program Development (DSPD) (October 2008)Google Scholar
  26. 26.
    Becker, P.: Standard for Programming Language C++. Working Draft, N2798=08-0308, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++ (October 2008)Google Scholar
  27. 27.
    Gregor, D.: ConceptGCC: Concept Extensions for C++ (August 2008),
  28. 28.
    Lédeczi, Á., Bakay, Á., Maróti, M., Völgyesi, P., Nordstrom, G., Sprinkle, J., Karsai, G.: Composing Domain-Specific Design Environments. Computer 34(11), 44–51 (2001)CrossRefGoogle Scholar
  29. 29.
    Balasubramanian, K., Balasubramanian, J., Parsons, J., Gokhale, A., Schmidt, D.C.: A Platform-Independent Component Modeling Language for Distributed Real-Time and Embedded Systems. In: RTAS 2005, pp. 190–199 (2005)Google Scholar
  30. 30.
    Munkby, G., Priesnitz, A., Schupp, S., Zalewski, M.: Scrap++: Scrap Your Boilerplate in C++. In: WGP 2006: Proceedings of the 2006 ACM SIGPLAN workshop on Generic programming, pp. 66–75 (2006)Google Scholar
  31. 31.
    Lämmel, R., Visser, E., Visser, J.: Strategic programming meets adaptive programming. In: Proc. Aspect-Oriented Software Development (AOSD), pp. 168–177 (2003)Google Scholar
  32. 32.
    Alcino, C., Joost, V.: Transformation of Structure-Shy Programs: Applied to XPath Queries and Strategic Functions. In: PEPM 2007: Proceedings of the 2007 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, pp. 11–20 (2007)Google Scholar
  33. 33.
    Lämmel, R.: Scrap Your Boilerplate with XPath-like Combinators. In: POPL 2007: Proceedings of the 34th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 137–142 (2007)Google Scholar
  34. 34.
    Hejlsberg, A., et al.: Language Integrated Query (LINQ),
  35. 35.
    Object Management Group: Unified Modeling Language: OCL version 2.0 Final Adopted Specification. OMG Document ptc/03-10-14 edn. (October 2003)Google Scholar

Copyright information

© IFIP International Federation for Information Processing 2009

Authors and Affiliations

  • Sumant Tambe
    • 1
  • Aniruddha Gokhale
    • 1
  1. 1.Electrical Engineering and Computer Science DepartmentVanderbilt UniversityNashvilleUSA

Personalised recommendations