XQuery

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Contents

[edit] XQuery Examples Collection

Welcome to the XQuery Examples Collection Wikibook! XQuery is a World Wide Web Consortium recommendation for selecting data from documents and databases.

[edit] Current Status

A new release of eXist (1.3Dev) is currently installed and under test. Please note any problems with these examples in the discussion

Recent Changes

[edit] About this Project

This is a collaborative project and we encourage everyone who is using XQuery to contribute their XQuery examples. All example programs must conform to the creative-commons-2.5 share-alike with attribution license agreement [1].

Execution of examples use an eXist demo server.

  1. Instructors: please sign our Guest Registry if you are using this book for learning or teaching XQuery
  2. Contributors: please see our Naming Conventions to ensure your examples are consistent with the textbook
  3. Learners: If you are looking for a specific example program, please feel free to use the Examples Wanted section if you are looking for specific example programs

[edit] Table of Contents

[edit] Introduction

  1. Background - A brief history and motivation for the XQuery standard.
  2. Benefits - Why use XQuery?
  3. Installing and Testing - How to install an XQuery server on your .
  4. Naming Conventions - Naming standards used throughout this book.

[edit] Example Scripts

[edit] Beginning Examples

Examples that do not assume knowledge of functions and modules.

  1. HelloWorld - A simple test to see if XQuery is installed correctly.
  2. FLWOR Expression - A basic example of how XQuery FLWOR statements work.
  3. Searching multiple collections - How to search multiple collections in a database.
  4. Getting URL Parameters - How to get parameters from the URL.
  5. Getting POST Data - How to get XML data posted to an XQuery.
  6. Checking for Required Parameters - How to check for a required parameter using if/then/else.
  7. Displaying Lists - How to take a list of values in an XML structure and return a comma separated list.
  8. Extracting data from XHTML files - How to use the doc() function to get data from XHTML pages.
  9. Displaying data in HTML Tables - How to display XML data in an HTML table.
  10. Limiting Result Sets - How to limit the number or records returned in an XQuery.
  11. Filtering Words - How to test to see if a word is on a list.
  12. Saving and Updating Data - How to have a single XQuery that saves new records or updates existing records.
  13. Quantified Expressions - Testing all the items in a sequence.

[edit] Intermediate Examples

Assumes knowledge of functions and modules.

  1. Returning the Longest String - A function to find the longest string from a list of strings
  2. Net Working Days - How to calculate the number of working days between two dates
  3. Tag Cloud - Counting and viewing the number of keywords
  4. String Analysis - Regular expression string analysis
  5. Manipulating URIs - How to get and manage URIs
  6. Parsing Query Strings - Parsing query strings using alternate delimiters.
  7. Splitting Files - Splitting a large XML files into many smaller files.
  8. Filling Portlets - How to fill regions of a web page with XQuery
  9. Filtering Nodes - How to use the identity transform to filter out nodes
  10. Higher Order Functions - Passing functions as arguments to functions
  11. Timing Fibonacci algorithms - A couple of Fibonacci algorithms and timing display
  12. Using Intermediate Documents - Analysis of a MusicXML file

[edit] Generic functions

These examples use reflection on the structure of an XML document using name() to implement generic functions for XML transformations.

  1. Table View - A generic table representation
  2. Tree View - A generic tree representation
  3. Searching,Paging and Sorting - Searching and Viewing

[edit] Graphs and Networks

  1. Topological Sort

[edit] XML Differencing

  1. Compare two XML files - using the eXist compare() function to test to see if two XML files are exactly the same
  2. XML Differences - displaying the difference between two XML files

[edit] XQuery and other languages

  1. XQuery from SQL - Using XQuery to access a classic Relational database - Employee/Department/Salary
  2. XML to SQL
  3. XQuery and XSLT
  4. XQuery and Python
  5. Excel and XML
  6. XQuery and XML Schema - Generating an XML instance document

[edit] Wikipedia interaction

  1. Wikipedia Page scraping
  2. Wikipedia Lookup
  3. Wikipedia Events RSS
  4. Wiki weapons page

[edit] Wikibook applications

  1. Wikibook index page
  2. Wikibook list of code links

[edit] Page Scraping

  1. Page scraping and Yahoo Weather
  2. UK shipping forecast
  3. Page scraping and Mashup
  4. Simple RSS reader
  5. Multiple page scraping and Voting behaviour
  6. REST interface definition

[edit] Mapping

  1. Google Geocoding
  2. /String Analysis#Location_Mapping/ Mapping Car Registrations
  3. Flickr GoogleEarth
  4. Nationalgrid and Google Maps
  5. SMS tracker

[edit] The Semantic Web

  1. DBpedia with SPARQL - Football teams
  2. DBpedia with SPARQL and Simile Timeline - Album Chronology
  3. DBpedia with SPARQL - Stadium locations
  4. The Emp-Dept case study
    1. XML to RDF
    2. SPARQL Tutorial
    3. SPARQL interface
  5. Graphing Triples
  6. SPARQLing Country Calling Codes
  7. Southampton Pubs
  8. Alphabet Poster
  9. Simile Exhibit

[edit] Interaction

  1. Adder - Creating a web service that adds two numbers.
  2. Simple XForms Examples
  3. Employee Search - an Ajax example
  4. Incremental Search of the Chemical Elements - with Ajax
  5. XMP data
  6. Slideshow

[edit] Development Tools

  1. Sitemap for Content Management System XQuery functions can easily perform many common web site content management functions
  2. Formatting Numbers - using picture formats to format numbers
  3. Uptime monitor
  4. XQuery IDE
  5. Image Library - using an XQuery to preview your images

[edit] Validation

  1. Validating a hierarchy


[edit] Visualization

  1. Graph Visualization
  2. Dataflow diagrams
  3. Sequence Diagrams
  4. Example Sequencer - Step-by-step tutorial
  5. GoogleChart example

[edit] Puzzles, Maths and Games

  1. Fizzbuzz
  2. Project Euler
  3. Sudoku

[edit] Live Applications

  1. UWE StudentsOnline

[edit] Systems that Support XQuery

Using native and hybrid XML databases that implement XQuery

  1. eXist - eXist OpenSource native XML database
  2. MarkLogic Server - MarkLogic Server commercial XML Content Server
  3. xDB (X-Hive/DB) - EMC Documentum xDB commercial native XML database
  4. Sedna - Open source native XML Database
  5. NetKernel - NetKernel
  6. IBM DB2 - XQuery using DB2 v9
  7. Microsoft SQL Server 2005 -
  8. Oracle XML DB - Oracle Server 11g includes the XML DB (XDB) feature
  9. Oracle Berkeley DB XML - Open source embedded storage management
  10. XQilla - XQilla is an open source XQuery library and command line utility
  11. Stylus Studio - Stylus Studio has XQuery mapping/editing/debugging and ships with Saxon (and SA) and DataDirect XQuery
  12. DataDirect XQuery - A high performance Java XQuery engine supporting relational, EDI, flat files and XML input and output

[edit] Appendixes

[edit] Crib Sheets

[edit] Debugging XQuery

  1. Gotchas - some pitfalls
  2. Ahhas - some ahha moments


[edit] Other sources

[edit] Function Libraries

  1. FunctX XQuery Function Library by Priscilla Walmsley

[edit] Discussion Groups

  1. XQuery General


[edit] Indexes

Key to symbols:

Wikibook Development Stages
Sparse text Image:00%.svg Developing text Image:25%.svg Maturing text Image:50%.svg Developed text Image:75%.svg Comprehensive text: Image:100%.svg


indicates an XQuery/Best practice

Personal tools
Create a book