Talk:XQuery

2019 refurbishment
There is a Github project to track issues with this book and collaborate amongst eXist db folk to bring this resource up-to-date

ChrisWallace

Chris's To do list (in no particular order)

 * 1) Date handling example
 * 2) Finish and Document the DVD hire case study
 * 3) better organization and indexing of these examples using tagging to increase findability
 * 4) Document the Periodic table application - needs re-thinking to get more generic but its a small example of using update (mostly done but for editing)
 * 5) implement and document the family history case - with timelines
 * 6) new section on design patterns

Other To do items

 * 1) Explain doc function as well as poorly implemented collection function
 * 2) Show examples of querying multiple documents using string manipulation -- doc($string)-- see: http://www.advocatehope.org/tech-tidbits/xquery
 * 3) Explain how to store an xquery on the server a) in the database, b) in the filesystem

Done list

 * 1) Content-Disposition to set the filename for saving ( done in the table to csv example)
 * 2) Better Ajax example - zipcode is a bit slow (done as an Emp search)
 * 3) Page scraping as RSS feed - done with the Yahoo weather ID decoder and feed

file suffix
I stored the initial scripts with our default xql suffix but I see xq is used in these examples so I guess that's the suffix to use.

serialization
Should the exist:serialise option always be set in the example? There's a problem of compatibility between eXist versions if we rely on the defaults since the media type has changed during 1.1.2dev. Also one example (output plain text) requires a different serialization option, so I think for constancy we should include it in all scripts. - maybe not - default is xml.=I think we should only set serialize on special cases. Yes, especially if the results are not well-formed XML files

indexing
Use form of Category XQuery|subcategory to structure a better index

Default eXist module declarations
Should all exist modules be declared even though they are declared by default in eXist?

yes - declaration makes their use explicit

Functions with Type Definitions
Should all function parameters have type definitions for arguments and return - yes

Use Source Element to wrap Source Code
We can now use the for source code (rather than pre). We really need an "xquery" pretty printer.

I will fix them as I go if that is OK --Dmccreary (talk) 23:25, 19 January 2008 (UTC)

Common XQuery format
Common layout format to be agreed and documented.

Use XQuery Comment
All examples should include documentation as comments

(: Explain the next line :)

I'd prefer a literate programming approach where the code examples and the executable code are derived from a common source. I personally find that heavy commenting interferes with reading the code - with generated pages you could switch the comments in or out as required. ChrisWallace (talk) 07:02, 15 July 2008 (UTC)

declare variable / let style
I have tended to use let rather than declare variable. I believe there is a performance issue favouring let, presumably because these are local to the FLWOR context rather than global, and I am not sure that the declaration of a long list of global variables is a good idea. However the former style seems to be prefered by some programmers and I'm not sure which is the best style for these examples. One guideline might be that declare variable should be restricted to variables which are global to a module of functions, so they warn of global variables. This meaning is lost if all variables are declared.

ChrisWallace (talk) 21:40, 23 March 2008 (UTC)

Example Template
Should we move these to an example template for coding style?

Additional Ideas for XQuery
Look at XQuery as the query language for the Web (What I call the Theory of the Web as One Big Database: see http://www.advocatehope.org/tech-tidbits/theory-of-the-web-as-one-big-database ). Essentially based on ReST (or ReSTful Web services), XQuery becomes an integral part of how the web functions. Much like AJAX and JSON, there should be an acronym that encompasses the Web, XQuery, XPath and ReSTful Web Services to help convey a new way of thinking about the web. In this way, XQuery is viewed as a prerequisite for understanding how the Web works, rather than an esoteric standard which it is now often viewed.

Detailed basics
I think a lot could be elaborated on for basic cases like simple joining, grouping, sorting, and aggregating. Node positions can cause a lot of confusion, an explanation of document order, the unordered{} expression / declaration and use of the "at" keyword in a for loop may be of value.

Some more advanced topics could be the union, intersect, and except expressions.

Release 1.3dev issues
err:XPTY0004 in function 'fr:expand'. Type error: expected type: xs:string; got: xdt:untypedAtomic [at line 79, column 27] In call to function:	fr:map-to-schema(element) [27:10]
 * RDF/xml2rdf failing with

Comments
I'm surprised to see the reference to the GMane mapping for the XQuery Talk mailing list, without mentioning the authoritative source for it: http://x-query.com/mailman/listinfo/talk (and http://markmail.org/search/list:com.x-query.talk for the archives). I guess that should be changed (link to the mailing list, then add "it is available on GMane too").