skip to main content
research-article

XQuery and static typing: tackling the problem of backward axes

Authors Info & Claims
Published:29 August 2015Publication History
Skip Abstract Section

Abstract

XQuery is a functional language dedicated to XML data querying and manipulation. As opposed to other W3C-standardized languages for XML (e.g. XSLT), it has been intended to feature strong static typing. Currently, however, some expressions of the language cannot be statically typed with any precision. We argue that this is due to a discrepancy between the semantics of the language and its type algebra: namely, the values of the language are (possibly inner) tree nodes, which may have siblings and ancestors in the data. The types on the other hand are regular tree types, as usual in the XML world: they describe sets of trees. The type associated to a node then corresponds to the subtree whose root is that node and contains no information about the rest of the data. This makes navigation expressions using `backward axes,' which return e.g. the siblings of a node, impossible to type. We discuss how to handle this discrepancy by improving the type system. We describe a logic-based language of extended types able to represent inner tree nodes and show how it can dramatically increase the precision of typing for navigation expressions. We describe how inclusion between these extended types and the classical regular tree types can be decided, allowing a hybrid system combining both type languages. The result is a net increase in precision of typing.

References

  1. M. Benedikt and J. Cheney. Semantics, types and effects for XML updates. In DBPL’09, pages 1–17, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. doi: 10.1007/ 978-3-642-03793-1_1.Google ScholarGoogle Scholar
  3. M. Benedikt and J. Cheney. Destabilizers and independence of XML updates. Proc. VLDB Endow., 3(1-2):906–917, Sept. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. doi: 10.14778/1920841.1920956.Google ScholarGoogle Scholar
  5. M. Benedikt and H. Vu. Higher-order functions and structured datatypes. In WebDB’12, pages 43–48, 2012. URL http://db.disi. unitn.eu/pages/WebDB2012/papers/p13.pdf.Google ScholarGoogle Scholar
  6. V. Benzaken, G. Castagna, and A. Frisch. CDuce: an XML-centric general-purpose language. In ICFP’03, pages 51–63, 2003. doi: 10.1145/944705.944711. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. V. Benzaken, G. Castagna, H. Hosoya, B. C. Pierce, and S. Vansummeren. XML typechecking. In Encyclopedia of Database Systems, pages 3646–3650. Springer, 2009.Google ScholarGoogle Scholar
  8. S. Boag, D. Chamberlin, M. Fernández, D. Florescu, J. Robie, and J. Siméon. XQuery 1.0: An XML Query Language (2nd ed.). W3C Recommendation, 2010. http://www.w3.org/TR/xquery/.Google ScholarGoogle Scholar
  9. A. Brüggemann-Klein and D. Wood. One-unambiguous regular languages. Information and Computation, 140(2):229 – 253, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. doi: 10.1006/inco.1997.2688.Google ScholarGoogle Scholar
  11. C. Calcagno, P. Gardner, and U. Zarfaty. Context logic and tree update. In POPL’05, pages 271–282, 2005. doi: 10.1145/1040305. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 1040328.Google ScholarGoogle Scholar
  13. C. Calcagno, P. Gardner, and U. Zarfaty. Context logic as modal logic: Completeness and parametric inexpressivity. In POPL’07, pages 123–134, 2007. doi: 10.1145/1190216.1190236. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. G. Castagna, H. Im, K. Nguy˜ ˆ en, and V. Benzaken. A core calculus for XQuery 3.0. In ESOP ’15, pages 232–256, 2015. doi: 10.1007/ 978-3-662-46669-8_10.Google ScholarGoogle Scholar
  15. D. Chamberlin, D. Florescu, and J. Robie. XQuery Update Facility. W3C WD, http://www.w3.org/TR/xqupdate/, 2006.Google ScholarGoogle Scholar
  16. J. Cheney and C. Urban. Mechanizing the metatheory of mini-XQuery. In CPP’11, pages 280–295, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. doi: 10.1007/ 978-3-642-25379-9_21.Google ScholarGoogle Scholar
  18. J. Clark and M. Murata. RELAX NG home page. http://relaxng. org/, 2014.Google ScholarGoogle Scholar
  19. I. Cognetic Systems. XQuantum XML database server, 2014. http: //www.cogneticsystems.com/xquery/xquery.html.Google ScholarGoogle Scholar
  20. D. Colazzo and C. Sartiani. Precision and complexity of XQuery type inference. In PPDP’11, pages 89–100, 2011. doi: 10.1145/2003476. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 2003490.Google ScholarGoogle Scholar
  22. D. Colazzo, G. Ghelli, P. Manghi, and C. Sartiani. Types for path correctness of XML queries. In ICFP’04, pages 126–137, 2004. doi: 10.1145/1016850.1016869. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Draper, M. Dyck, P. Fankhauser, M. Fernández, A. Malhotra, K. Rose, M. Rys, J. Siméon, and P. Wadler. XQuery 1.0 and XPath 2.0 formal semantics, W3C recommendation, December 2010. http: //www.w3.org/TR/xquery-semantics/.Google ScholarGoogle Scholar
  24. P. Fankhauser, M. Fernández, A. Malhotra, M. Rys, J. Siméon, and P. Wadler. The XML query algebra, W3C working draft, December 2000. http://www.w3.org/TR/2000/ WD-query-algebra-20001204/.Google ScholarGoogle Scholar
  25. M. F. Fernández, J. Siméon, and P. Wadler. A semi-monad for semistructured data. In ICDT’01, pages 263–300, 2001. doi: 10.1007/ 3-540-44503-X_18.Google ScholarGoogle Scholar
  26. P. A. Gardner, G. D. Smith, M. J. Wheelhouse, and U. D. Zarfaty. Local Hoare reasoning about DOM. In PODS’08, 2008. doi: 10. 1145/1376916.1376953. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. P. Genevès, N. Layaïda, and A. Schmitt. Efficient static analysis of XML paths and types. In PLDI’07, pages 342–351, 2007. doi: 10.1145/1250734.1250773. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. P. Genevès, N. Layaïda, A. Schmitt, and N. Gesbert. Efficiently deciding µ-calculus with converse over finite trees. ACM Transactions on Computational Logic, 16(2):16:1–16:41, 2015. doi: 10.1145/ 2724712. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. H. Hosoya and B. C. Pierce. XDuce: A statically typed XML processing language. ACM Trans. Internet Technol., 3(2):117–148, 2003. doi: 10.1145/767193.767195. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. H. Hosoya, J. Vouillon, and B. C. Pierce. Regular expression types for XML. ACM Trans. Program. Lang. Syst., 27(1):46–90, 2005. doi: 10.1145/1053468.1053470. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. D. Hovland. The inclusion problem for regular expressions. Journal of Computer and System Sciences, 78(6):1795 – 1813, 2012. doi: 10.1016/j.jcss.2011.12.003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. G. P. Huet. The zipper. J. Funct. Program., 7(5):549–554, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. ISO/IEC. Document schema definition language – schematron. http: //www.schematron.com, 2012.Google ScholarGoogle Scholar
  34. C. Kirkegaard, A. Møller, and M. I. Schwartzbach. Static analysis of XML transformations in Java. IEEE Transactions on Software Engineering, 30(3):181–192, March 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. C. Koch. On the complexity of nonrecursive XQuery and functional query languages on complex values. ACM Trans. Database Syst., 31 (4):1215–1256, Dec. 2006. doi: 10.1145/1189769.1189771. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. S. Maneth, A. Berlea, T. Perst, and H. Seidl. XML type checking with macro tree transducers. In PODS’05, pages 283–294, 2005. doi: 10.1145/1065167.1065203. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. S. Maneth, T. Perst, and H. Seidl. Exact XML type checking in polynomial time. In ICDT’07, pages 254–268, 2007. doi: 10.1007/ 11965893_18. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. T. Milo, D. Suciu, and V. Vianu. Typechecking for XML transformers. J. Comput. Syst. Sci., 66(1):66–97, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. J. Robie, D. Chamberlin, M. Dyck, D. Florescu, J. Melton, and J. Siméon. XQuery update facility 1.0, W3C recommendation, March 2011. http://www.w3.org/TR/xquery-update-10/.Google ScholarGoogle Scholar
  40. J. Robie, D. Chamberlin, M. Dyck, and J. Snelson. XQuery 3.0: An XML Query Language. W3C Last Call Working, July 2013. http://www.w3.org/TR/xquery-30/.Google ScholarGoogle Scholar
  41. J. Siméon, M. Fernández, et al. Implementation of xquery 1.0, 2008. http://galax.sourceforge.net/.Google ScholarGoogle Scholar
  42. W3C. Document object model (DOM), W3C recommendation, 2004. http://www.w3.org/DOM/.Google ScholarGoogle Scholar
  43. W3C. Xml query (xquery) implementations, 2014. http://www.w3. org/XML/Query/#implementations.Google ScholarGoogle Scholar
  44. P. Wadler. XQuery: A typed functional language for querying XML. In Advanced Functional Programming, pages 188–212, 2002.Google ScholarGoogle Scholar

Index Terms

  1. XQuery and static typing: tackling the problem of backward axes

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 50, Issue 9
          ICFP '15
          September 2015
          436 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2858949
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
          • cover image ACM Conferences
            ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
            August 2015
            436 pages
            ISBN:9781450336697
            DOI:10.1145/2784731

          Copyright © 2015 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 29 August 2015

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!