Skip to main content

XQuery: A Typed Functional Language for Querying XML

  • Chapter

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2638))

Abstract

XQuery is a typed, functional language for querying XML, currently being designed by the XML Query Working Group of the World-Wide Web Consortium. Here are examples of XQuery queries on a suitable XML document describing books. To list titles of all books published before 2000 you might write:

 

document(”books.xml”)/BOOKS/BOOK[@YEAR < 2000]/TITLE

To list the year and title of all books published before 2000 you might write:

for $book in document(”books.xml”)/BOOKS/BOOK

where $book/@YEAR < 2000

return <BOOK>{ $book/@YEAR, $book/TITLE }</BOOK>

And to list for each author the titles of all books by that author you might write:

let $books := document(”books.xml”)/BOOKS

for $author in distinct($books/BOOK/AUTHOR) return

   <AUTHOR NAME=”{ $author }”>{

       $books/BOOK[AUTHOR = $author]/TITLE

   }</AUTHOR>

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. XQuery 1.0: An XML Query Language. W3C Working Draft, April 30 (2002) (Next draft expected August 2002)

    Google Scholar 

  2. XQuery 1.0 Formal Semantics. W3C Working Draft, March 26 (2002) (Next draft expected August 2002)

    Google Scholar 

  3. XQuery 1.0 and XPath 2.0 Functions and Operators. W3C Working Draft, April 30 (2002) (Next draft expected August 2002)

    Google Scholar 

  4. Extensible Markup Language (XML) 1.0. W3C Recommendation, February 10 (1998)

    Google Scholar 

  5. Extensible Markup Language (XML) 1.0 (Second edition). W3C Recommendation, October 6 (2000)

    Google Scholar 

  6. Namespaces in XML. W3C Recommendation, January 14 (1999)

    Google Scholar 

  7. XML Schema Part 0: Primer, Part 1: Structures, Part 2: Datatypes. W3C Recommendation, May 2 (2001)

    Google Scholar 

  8. XSL Transformations (XSLT) Version 1.0. W3C Recommendation, November 16 (1999)

    Google Scholar 

  9. XSL Transformations (XSLT) Version 2.0. W3C Working Draft, April 30 (2002)

    Google Scholar 

  10. XML Path Language (XPath) 1.0. W3C Recommendation, November 16 (1999)

    Google Scholar 

  11. XML Path Language (XPath) 2.0. W3C Working Draft, April 30 (2002)

    Google Scholar 

  12. XML Pointer Language (XPointer) Version 1.0. W3C Candidate Recommendation, September 11 (2001)

    Google Scholar 

  13. RELAX NG Specification. Oasis Committee Specification, December 3 (2001)

    Google Scholar 

  14. RELAX NG Compact Syntax. Oasis Working Draft, June 7 (2002)

    Google Scholar 

  15. Fernández, M., Siméon, J., Wadler, P.: Introduction to the XQuery Formal Semantics. In: Katz, H. (ed.) XQuery for Experts. Addison-Wesley, Reading (to appear)

    Google Scholar 

  16. Siméon, J., Wadler, P.: The essence of XML. In: Proceedings 31st ACM Symposium on Principles of Programming Languages, New Orleans (January 2003)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2003 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Wadler, P. (2003). XQuery: A Typed Functional Language for Querying XML. In: Jeuring, J., Jones, S.L.P. (eds) Advanced Functional Programming. AFP 2002. Lecture Notes in Computer Science, vol 2638. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-44833-4_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-44833-4_7

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-40132-2

  • Online ISBN: 978-3-540-44833-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics