background preloader

Teaching: XQuery

Facebook Twitter

CliffordAnderson/XQuery4Humanists: Exercises for the XQuery Workshops at XQuery at DH2017. Xquery Nodes with Elements, Attribute, Document Constructors. In the last section, we learned how to locate nodes in XML documents.

Xquery Nodes with Elements, Attribute, Document Constructors

Now we will learn how to create nodes. Elements, attributes, text nodes, processing instructions, and comments can all be created using the same syntax as XML. For instance, here is an element constructor that creates a book: <book year="1977"><title>Harold and the Purple Crayon</title><author><last>Johnson</last><first>Crockett</first></author><publisher>HarperCollins Juvenile Books</publisher><price>14.95</price></book> As we have mentioned previously, the document node does not have explicit syntax in XML, but XQuery provides an explicit document node constructor. Constructors can be combined with other XQuery expressions to generate content dynamically. Atomic Wiki. In my first screencast ever, I'd like to present a little "fun project" I've been working on secretly during the past months. eXide is a replacement for the old XQuery Sandbox in eXist, offering features you normally do not find in a web-based editor.

Atomic Wiki

Features include: fast syntax highlighting, ability to edit huge XQuery files, code completion for functions and variables, code templates, powerful navigation, on-the-fly compilation... This is the first part of my screencast. The second part will cover the application development cycle, including code generation (scaffolding), deployment and synchronization. eXide is now available in SVN trunk (). After updating, just open in your browser. 21-XQuery.pdf. Blooming FLWOR - An Introduction to the XQuery FLWOR Expression. Download the PDF By: Dr.

Blooming FLWOR - An Introduction to the XQuery FLWOR Expression

Michael Kay In the previous tutorial in this series I presented a quick 10-minute XQuery Tutorial. I started with a number of XPath expressions — because every XPath expression is a valid XQuery — and then went on to introduce FLWOR expressions, the workhorse of the XQuery language. FLWOR expressions are so powerful, and form such an important part of XQuery, that I think it's worth giving them an article in their own right: and here it is. If it's not obvious from the title of the article, FLWOR is pronounced "flower" and is often mis-spelt as "flowr". Simple FLWOR Expressions The simplest XQuery FLWOR expression is probably something like this: for $v in $doc//video return $v This simply returns all the video elements in the document $doc.

You can add a bit of substance with an XQuery where clause and a slightly more imaginative XQuery return clause: for $v in $doc//video where $v/year = 1999 return $v/title SELECT v.title FROM video v WHERE v.year = 1999 $doc//video. Functions.pdf. Saxon Running XQuery from the Command Line. A command is available to run a query contained in a file.

Saxon Running XQuery from the Command Line

The form of command on the Java platform is: java net.sf.saxon.Query [options] -q:queryfile [ params...] On the .NET platform, the command is simply: Query [options] -q:queryfile [ params...] The options must come first, then the params. The options are as follows (in any order). A param takes the form name=value, name being the name of the parameter, and value the value of the parameter. A param preceded by a leading question mark (?) A param preceded by a leading plus sign (+) is interpreted as a filename or directory.

A param preceded by a leading exclamation mark (!) Under Windows, and some other operating systems, it is possible to supply a value containing spaces by enclosing it in double quotes, for example name="John Smith". Template / XPath 2.0 / XQuery / CSS 3 Selector / JSONiq Online Tester. XQuery 3.0 - BaseX Documentation. From BaseX Documentation This article is part of the XQuery Portal.

XQuery 3.0 - BaseX Documentation

It summarizes the most interesting features of the XQuery 3.0 Recommendations. XQuery 3.0 if fully supported by BaseX. [edit] Enhanced FLWOR Expressions Most clauses of FLWOR expressions can now be specified in an arbitrary order: additional let and for clauses can be put after a where clause, and multiple where, order by and group by statements can be used.

Example: A new count clause enhances the FLWOR expression with a variable that enumerates the iterated tuples. The allowing empty provides functionality similar to outer joins in SQL: Window clauses provide a rich set of variable declarations to process sub-sequences of iterated tuples. More information on window clauses, and all other enhancements, can be found in the specification. [edit] Simple Map Operator The simple map operator !