A Core Calculus for XQuery 3.0

Combining Navigational and Pattern Matching Approaches
  • Giuseppe Castagna
  • Hyeonseung Im
  • Kim Nguyễn
  • Véronique Benzaken
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9032)


XML processing languages can be classified according to whether they extract XML data by paths or patterns. The strengths of one category correspond to the weaknesses of the other. In this work, we propose to bridge the gap between these two classes by considering two languages, one in each class: XQuery (for path-based extraction) and \(\mathbb{C}\textrm{Duce}\) (for pattern-based extraction). To this end, we extend \(\mathbb{C}\textrm{Duce}\) so as it can be seen as a succinct core λ-calculus that captures XQuery 3.0. The extensions we consider essentially allow \(\mathbb{C}\textrm{Duce}\) to implement XPath-like navigational expressions by pattern matching and precisely type them. The elaboration of XQuery 3.0 into the extended \(\mathbb{C}\textrm{Duce}\) provides a formal semantics and a sound static type system for XQuery 3.0 programs.


Pattern Match Operational Semantic Typing Rule XPath Expression Type Algebra 
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.
    Alon, N., Milo, T., Neven, F., Suciu, D., Vianu, V.: XML with data values: Typechecking revisited. In: PODS, pp. 138–149. ACM (2001)Google Scholar
  2. 2.
    Amadio, R.M., Cardelli, L.: Subtyping recursive types. ACM Trans. Program. Lang. Syst. 15(4), 575–631 (1993)CrossRefGoogle Scholar
  3. 3.
    Benedikt, M., Vu, H.: Higher-order functions and structured datatypes. In: WebDB, pp. 43–48 (2012)Google Scholar
  4. 4.
    Benzaken, V., Castagna, G., Frisch, A.: CDuce: An XML-centric general-purpose language. In: ICFP, pp. 51–63 (2003)Google Scholar
  5. 5.
    Castagna, G., Nguy\(\widetilde{\widehat{\rm e}}\), K., Xu, Z., Abate, P.: Polymorphic functions with set-theoretic types. Part 2: Local type inference and type reconstruction. In: POPL, pp. 289–302 (2015)Google Scholar
  6. 6.
    Castagna, G., Nguy\(\widetilde{\widehat{\rm e}}\), K., Xu, Z., Im, H., Lenglet, S., Padovani, L.: Polymorphic functions with set-theoretic types. Part 1: Syntax, semantics, and evaluation. In: POPL, pp. 5–17 (2014)Google Scholar
  7. 7.
    Castagna, G., Xu, Z.: Set-theoretic foundation of parametric polymorphism and subtyping. In: ICFP, pp. 94–106 (2011)Google Scholar
  8. 8.
    Engelfriet, J., Vogler, H.: Macro tree transducers. J. Comput. Syst. Sci. 31(1), 71–146 (1985)CrossRefzbMATHMathSciNetGoogle Scholar
  9. 9.
    Frisch, A.: Théorie, conception et réalisation d’un langage adapté à XML. PhD thesis, Université Paris 7 Denis Diderot (2004)Google Scholar
  10. 10.
    Frisch, A., Castagna, G., Benzaken, V.: Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM 55(4), 1–64 (2008)CrossRefMathSciNetGoogle Scholar
  11. 11.
    Gapeyev, V., Garillot, F., Pierce, B.C.: Statically typed document transformation: An Xtatic experience. In: PLAN-X (2006)Google Scholar
  12. 12.
    Gapeyev, V., Pierce, B.C.: Paths into patterns. Technical Report MS-CIS-04-25, University of Pennsylvania (October 2004)Google Scholar
  13. 13.
    Genevès, P., Gesbert, N., Layaïda, N.: Xquery and static typing: Tackling the problem of backward axes (July 2014),
  14. 14.
    Genevès, P., Layaïda, N.: Eliminating dead-code from XQuery programs. In: ICSE (2010)Google Scholar
  15. 15.
    Genevès, P., Layaïda, N., Schmitt, A.: Efficient static analysis of XML paths and types. In: PLDI (2007)Google Scholar
  16. 16.
    Hosoya, H., Pierce, B.C.: Regular expression pattern matching for XML. J. Funct. Program. 13(6), 961–1004 (2003)CrossRefzbMATHMathSciNetGoogle Scholar
  17. 17.
    Hosoya, H., Pierce, B.C.: XDuce: A statically typed XML processing language. ACM Trans. Internet Technol. 3(2), 117–148 (2003)CrossRefGoogle Scholar
  18. 18.
    Huet, G.: The Zipper. J. Funct. Program. 7(5), 549–554 (1997)CrossRefzbMATHMathSciNetGoogle Scholar
  19. 19.
    Lämmel, R.: Scrap your boilerplate with XPath-like combinators. In: POPL (2007)Google Scholar
  20. 20.
    Maneth, S., Berlea, A., Perst, T., Seidl, H.: XML type checking with macro tree transducers. In: PODS (2005)Google Scholar
  21. 21.
    W3C: XPath 1.0 (1999),,
  22. 22.
    W3C: XPath 2.0 (2010),,
  23. 23.
    W3C: XML Query (2010),,
  24. 24.
    XQuery 1.0 and XPath 2.0 Formal Semantics, 2nd edn (2010),
  25. 25.
    W3C: XQuery 3.0 (2014),
  26. 26.
    W3C: XML Schema (2009),

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  • Giuseppe Castagna
    • 1
  • Hyeonseung Im
    • 2
  • Kim Nguyễn
    • 3
  • Véronique Benzaken
    • 3
  1. 1.CNRS, PPS, Univ. Paris DiderotSorbonne Paris CitéFrance
  2. 2.Inria, LIG, Univ. Grenoble-AlpesGrenobleFrance
  3. 3.LRI, Université Paris-SudOrsayFrance

Personalised recommendations