Advertisement

XQuery in the Functional-Logic Language Toy

  • Jesus M. Almendros-Jiménez
  • Rafael Caballero
  • Yolanda García-Ruiz
  • Fernando Sáenz-Pérez
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6816)

Abstract

This paper presents an encoding of the XML query language XQuery in the functional-logic language \(\mathcal{TOY}\). The encoding is based on the definition of for-let-where-return constructors by means of \(\mathcal{TOY}\) functions, and uses the recently proposed XPath implementation for this language as a basis. XQuery expressions can be executed in \(\mathcal{TOY}\) obtaining sequences of XML elements as answers. Our setting exploits the non-deterministic nature of \(\mathcal{TOY}\) by retrieving the elements of the XML tree once at a time when necessary. We show that one of the advantages of using a rewriting-based language for implementing XQuery is that it can be used for optimizing XQuery expressions by query rewriting. With this aim, XQuery expressions are converted into higher order patterns that can be analyzed and modified by \(\mathcal{TOY}\) functions.

Keywords

Functional-Logic Programming Non-Deterministic Functions XQuery Higher-Order Patterns 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Almendros-Jiménez, J., Caballero, R., García-Ruiz, Y., Sáenz-Pérez, F.: A Declarative Embedding of XQuery in a Functional-Logic Language. Technical Report SIC-04/11, Facultad de Informática, Universidad Complutense de Madrid (2011), http://gpd.sip.ucm.es/rafa/xquery/
  2. 2.
    Almendros-Jiménez, J.M.: An Encoding of XQuery in Prolog. In: Bellahsène, Z., Hunt, E., Rys, M., Unland, R. (eds.) XSym 2009. LNCS, vol. 5679, pp. 145–155. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  3. 3.
    Almendros-Jiménez, J.M., Becerra-Terón, A., Enciso-Baños, F.J.: Querying XML documents in logic programming. Journal of Theory and Practice of Logic Programming 8(3), 323–361 (2008)MathSciNetCrossRefMATHGoogle Scholar
  4. 4.
    Atanassow, F., Clarke, D., Jeuring, J.: UUXML: A type-preserving XML schema–haskell data binding. In: Jayaraman, B. (ed.) PADL 2004. LNCS, vol. 3057, pp. 71–85. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  5. 5.
    Benzaken, V., Castagna, G., Frish, A.: CDuce: an XML-centric general-purpose language. In: Proc. of the ACM SIGPLAN International Conference on Functional Programming, pp. 51–63. ACM Press, New York (2005)Google Scholar
  6. 6.
    Benzaken, V., Castagna, G., Miachon, C.: A Full Pattern-Based Paradigm for XML Query Processing. In: Hermenegildo, M.V., Cabeza, D. (eds.) PADL 2004. LNCS, vol. 3350, pp. 235–252. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  7. 7.
    Boncz, P., Grust, T., van Keulen, M., Manegold, S., Rittinger, J., Teubner, J.: MonetDB/XQuery: a fast XQuery processor powered by a relational engine. In: Proceedings of the 2006 ACM SIGMOD International Conference on Management of Data, pp. 479–490. ACM Press, New York (2006)CrossRefGoogle Scholar
  8. 8.
    Boncz, P.A., Grust, T., van Keulen, M., Manegold, S., Rittinger, J., Teubner, J.: Pathfinder: XQuery - The Relational Way. In: Proc. of the International Conference on Very Large Databases, pp. 1322–1325. ACM Press, New York (2005)Google Scholar
  9. 9.
    Bry, F., Schaffert, S.: The XML Query Language Xcerpt: Design Principles, Examples, and Semantics. In: Chaudhri, A.B., Jeckle, M., Rahm, E., Unland, R. (eds.) NODe-WS 2002. LNCS, vol. 2593, pp. 295–310. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  10. 10.
    Caballero, R., García-Ruiz, Y., Sáenz-Pérez, F.: Integrating XPath with the Functional-Logic Language Toy. In: Rocha, R., Launchbury, J. (eds.) PADL 2011. LNCS, vol. 6539, pp. 145–159. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  11. 11.
    Caballero, R., López-Fraguas, F.: A functional-logic perspective on parsing. In: Middeldorp, A. (ed.) FLOPS 1999. LNCS, vol. 1722, pp. 85–99. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  12. 12.
    Cabeza, D., Hermenegildo, M.: Distributed WWW Programming using (Ciao-)Prolog and the PiLLoW Library. Theory and Practice of Logic Programming 1(3), 251–282 (2001)CrossRefGoogle Scholar
  13. 13.
    Coelho, J., Florido, M.: XCentric: logic programming for XML processing. In: WIDM 2007: Proceedings of the 9th Annual ACM International Workshop on Web Information and Data Management, pp. 1–8. ACM Press, New York (2007)Google Scholar
  14. 14.
    Fegaras, L.: HXQ: A Compiler from XQuery to Haskell (2010)Google Scholar
  15. 15.
    Grinev, M., Pleshachkov, P.: Rewriting-based optimization for XQuery transformational queries. In: 9th International Database Engineering and Application Symposium, IDEAS 2005, pp. 163–174. IEEE Computer Society, Los Alamitos (2005)Google Scholar
  16. 16.
    Guerra, R., Jeuring, J., Swierstra, S.D.: Generic validation in an XPath-Haskell data binding. In: Proceedings Plan-X (2005)Google Scholar
  17. 17.
    Hanus, M.: Curry: An Integrated Functional Logic Language (2003), http://www.informatik.uni-kiel.de/~mh/curry/ (version 0.8.2 March 28, 2006)
  18. 18.
    Hanus, M.: Declarative processing of semistructured web data. Technical report 1103, Christian-Albrechts-Universität Kiel (2011)Google Scholar
  19. 19.
    Hosoya, H., Pierce, B.C.: XDuce: A Statically Typed XML Processing Language. ACM Transactions on Internet Technology 3(2), 117–148 (2003)CrossRefGoogle Scholar
  20. 20.
    Hutton, G., Meijer, E.: Monadic parsing in Haskell. J. Funct. Program. 8(4), 437–444 (1998)CrossRefMATHGoogle Scholar
  21. 21.
    Koch, C.: On the role of composition in XQuery. In: Proc. WebDB (2005)Google Scholar
  22. 22.
    Fraguas, F.J.L., Hernández, J.S.: TOY: A Multiparadigm Declarative System. In: Narendran, P., Rusinowitch, M. (eds.) RTA 1999. LNCS, vol. 1631, pp. 244–247. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  23. 23.
    Marian, A., Simeon, J.: Projecting XML Documents. In: Proc. of International Conference on Very Large Databases, pp. 213–224. Morgan Kaufmann, Burlington (2003)Google Scholar
  24. 24.
    May, W.: XPath-Logic and XPathLog: A Logic-Programming Style XML Data Manipulation Language. Theory and Practice of Logic Programming 4(3), 239–287 (2004)MathSciNetCrossRefMATHGoogle Scholar
  25. 25.
    Olteanu, D., Meuss, H., Furche, T., Bry, F.: XPath: Looking forward. In: Chaudhri, A.B., Unland, R., Djeraba, C., Lindner, W. (eds.) EDBT 2002. LNCS, vol. 2490, pp. 109–127. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  26. 26.
    Ronen, R., Shmueli, O.: Evaluation of datalog extended with an XPath predicate. In: Proceedings of the 9th Annual ACM International Workshop on Web Information and Data Management, pp. 9–16. ACM, New York (2007)Google Scholar
  27. 27.
    Schaffert, S., Bry, F.: A Gentle Introduction to Xcerpt, a Rule-based Query and Transformation Language for XML. In: Proc. of International Workshop on Rule Markup Languages for Business Rules on the Semantic Web. CEUR Workshop Proceedings, vol. 60, p. 22 (2002)Google Scholar
  28. 28.
    Seibel, P.: Practical Common Lisp. Apress (2004)Google Scholar
  29. 29.
    Seipel, D.: Processing XML-Documents in Prolog. In: Procs. of the Workshop on Logic Programming 2002, p. 15. Technische Universität Dresden, Dresden (2002)Google Scholar
  30. 30.
    Sulzmann, M., Lu, K.Z.: XHaskell – adding regular expression types to haskell. In: Chitil, O., Horváth, Z., Zsók, V. (eds.) IFL 2007. LNCS, vol. 5083, pp. 75–92. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  31. 31.
    Thiemann, P.: A typed representation for HTML and XML documents in Haskell. Journal of Functional Programming 12(4&5), 435–468 (2002)MathSciNetMATHGoogle Scholar
  32. 32.
    W3C. XML Schema 1.1Google Scholar
  33. 33.
    W3C. Extensible Markup Language, XML (2007)Google Scholar
  34. 34.
    W3C. XML Path Language (XPath) 2.0 (2007)Google Scholar
  35. 35.
    W3C. XQuery 1.0: An XML Query Language (2007)Google Scholar
  36. 36.
    Wallace, M., Runciman, C.: Haskell and XML: Generic combinators or type-based translation? In: Proceedings of the International Conference on Functional Programming, pp. 148–159. ACM Press, New York (1999)Google Scholar
  37. 37.
    Walmsley, P.: XQuery. O’Reilly Media, Inc., Sebastopol (2007)Google Scholar
  38. 38.
    Wielemaker, J.: SWI-Prolog SGML/XML Parser, Version 2.0.5. Technical report, Human Computer-Studies (HCS), University of Amsterdam (March 2005)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Jesus M. Almendros-Jiménez
    • 1
  • Rafael Caballero
    • 2
  • Yolanda García-Ruiz
    • 2
  • Fernando Sáenz-Pérez
    • 3
  1. 1.Dpto. de Lenguajes y ComputaciónUniversidad de AlmeríaSpain
  2. 2.Departamento de Sistemas Informáticos y ComputaciónUniversidad Complutense de MadridSpain
  3. 3.Departamento de Ingeniería del Software e Inteligencia ArtificialUniversidad Complutense de MadridSpain

Personalised recommendations