XQuery/Google Docs
Appearance
< XQuery
Motivation
[edit | edit source]You have data stored in a Google Docs spreadsheet. Since Google docs has an RSS feed for their data you can use this service to get well-formed XML about your spreadsheet directly from XQuery.
Method
[edit | edit source]You can use the base URL of 'https://spreadsheets.google.com/feeds/list/' to list the data in a public spreadsheet.
let $base-uri := 'https://spreadsheets.google.com/feeds/list/'
let $document-id := '0AsuPP847sJrUdEdwcVdHeUZ1Sm80dEc1eWZHQkwyZlE'
let $suffix := '/od6/public/basic'
you can concat these three strings together and wrap them in an xs:anyURI type to get the document using the httpcleint:get() function.
Example Code
[edit | edit source]xquery version "1.0";
declare namespace atom="http://www.w3.org/2005/Atom";
let $http-get :=
httpclient:get(
xs:anyURI(
'https://spreadsheets.google.com/feeds/list/0AsuPP847sJrUdEdwcVdHeUZ1Sm80dEc1eWZHQkwyZlE/od6/public/basic'),
true(), ())
return
<results>
Number Entries: { count($http-get//atom:entry) }
</results>
Which returns:
<results>Number Entries: 455</results>
References
[edit | edit source]This example was posted on the eXist mailing list in April of 2014 by Dr. Andreas Wagner.