27. declare %automatic %value-equality %non-unique index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @site-id as xs:string;
28. Index Properties
declare %automatic %value-equality %non-unique index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @site-id as xs:string;
29. Index Name
declare %automatic %value-equality %non-unique index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @site-id as xs:string;
30. declare %automatic %value-equality %non-unique index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @site-id as xs:string;
Domain Expression
31. declare %automatic %value-equality %non-unique index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @site-id as xs:string;
Index Key
32. declare %automatic %value-equality %non-unique index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @site-id as xs:string, @city as xs:string;
33. declare %automatic %value-range index
f:forecasts-index
on nodes cdml:collection(xs:QName("f:forecasts"))
by @temperature as xs:decimal;
34.
35. $ sausalito backup data
Backup data for project at: /Users/test/forecast
Project URI: http://www.example.com/
Starting backup for collection data ... OK
Backup successful
$ sausalito restore data -f forecast.tar.gz
Restored data
36. Full-Text
• XQuery and XPath Full Text 1.0
• Thesaurus
• Stemming
• Complete access to the full text internals
ft:tokenize($node, $lang)
ft:tokenizer-properties()
ft:thesaurus-lookup($uri, $phrase)
ft:stem($work)
...
38. let $x := <msg>breakfast of champions</msg>
return $x contains text "meal"
using thesaurus at "http://wordnet.princeton.edu"
relationship "narrower term"
40. let $doc := doc(“doc.xml”)
for $token in ft:tokenize($doc)
return
concat($token/@value, “ at ”,
$token/@paragraph,
$token/@sentence
)
41. Scripting
• Open Specification
• Implemented by Zorba
• Friendly syntax for imperative programming
• Semantic for side-effects
• Specification at http://goo.gl/kTYuf
• Tutorial at http://goo.gl/F23je
42. let $handler :=
function($request){
let $world := $request/http:body/text()
return
<h1>Hello {$world}!</h1>
}
return mongoose:start($handler, 8080);
mongoose:cin();
45. in the Browser
• Open Source Project from ETH
• http://xqib.org
• XQuery in the browser without a plug-in
• Processor compiled to JavaScript
• DOM as the processor store
57. <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type='application/xquery'>
declare updating function local:buy($evt, $obj) {
insert node <p>{$obj/@id}</p> as first
into //div[@id="shoppingcart"]
};
b:addEventListener(b:dom()//input,
"onclick",
xs:Qname("local:buy"));
</script>
</head>
<body>
<div>Shopping cart</div>
<div id="shoppingcart">{
XQuery Everywhere
for $p in doc("products.xml")//*:product
return
<div>
{$p/*:name}
<input type='button'
value='Buy'
id='{$p/*:name}'/>
</div>
}</div>
</body>
</html>
58. Wadler's theorem of language adoption
“A programming language will be adopted
if and only if
it permits its users to
do something that cannot be done in any
other way.”
59. GO
Mapping Mapping
JavaScript Java SQL
Glue Glue
GO
Seamless
Invocations
XQuery XQuery
60. GO
Mapping
JavaScript Local Java
Store SQL
Glue
Sync Sync
61. GO
Mapping
JavaScript Local Java
Store SQL
Glue
Sync Sync
GO
XQuery Local XQuery
Store
Seamless Synchronisation
63. XQuery in Mobile Apps
• 2 XQuery Stores
- DOM
- HTML5 Local Storage
• When Offline
- Each update is applied to local store
- Pending Update Lists are stored in the local store
• When Online
- PULs are aggregated and sent to the Cloud
- PULs are applied to the Cloud
65. insert node attribute done { “true” }
into xqddf:collection($todos)[@id = $id]
1. Apply PUL
Store PUL
Local Store
TODOs <todo done=”true”/>
<insert src=”...”
PULs target=”...” />
66. insert node attribute done { “true” }
into xqddf:collection($todos)[@id = $id]
Local Store 2. Send PUL
TODOs <todo done=”true”/>
PULs
67. insert node attribute done { “true” }
into xqddf:collection($todos)[@id = $id]
Local Store
3. Apply PUL
TODOS <todo done=”true”/>
PULs
68. Operators on Updates
• Aggregation
• Integration (+ detecting conflicts)
• Reconciliation of conflicts
• Reduction
• Inversion