SlideShare uma empresa Scribd logo
1 de 73
Baixar para ler offline
28   msec
            Not Your Grandma’s XQuery
            Key Features & Perspectives
            William Candillon {candillon@28msec.com}
            XML Amsterdam 2011
“What I saw in your five-minutes talk hardly
looks at all like the XQuery I saw back then.”


                     - Daniel Weinred, Google
Not Your Grandma’s XQuery
Download the CoreSDK
Deploy in one-click
Automatic Scaling
• ........
Application Stack



    Client      JavaScript


  Middleware         Java

   Content
                    Lucene
  Management

   Database         MySQL
Application Stack



    Client      JavaScript


  Middleware         Java

   Content
                             XQuery
                    Lucene
  Management

   Database         MySQL
Application Stack



    Client              in the Browser


  Middleware               Scripting

   Content
               XQuery
                           Full-Text
  Management

                        Data Definition
   Database
                            Facility
XQuery Data Definition Facility


    • Open Specification (http://goo.gl/XzK8p)
    • Implemented by Zorba (http://goo.gl/4huso)
    • Extending XQuery with
      - Collections
      - Indexes
      - Integrity Contraints
declare collection f:forecasts as element(forecast);
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 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;
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;
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
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
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;
declare %automatic %value-range index
f:forecasts-index
  on nodes cdml:collection(xs:QName("f:forecasts"))
  by @temperature as xs:decimal;
$ 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
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)

 ...
$data//element()[. contains text {$search-term}]
let $x := <msg>breakfast of champions</msg>
return $x contains text "meal"
  using thesaurus at "http://wordnet.princeton.edu"
  relationship "narrower term"
ft:stem( "flavoring", xs:language("en") )
let $doc := doc(“doc.xml”)
for $token in ft:tokenize($doc)
return
  concat($token/@value, “ at ”,
         $token/@paragraph,
         $token/@sentence
  )
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
let $handler :=
  function($request){
    let $world := $request/http:body/text()
    return
      <h1>Hello {$world}!</h1>
  }
return mongoose:start($handler, 8080);
mongoose:cin();
while(true()) {
   variable $request := server:listen("localhost", 8080);
   variable $response := api:process($request);
   api:serialize($response)
};
if(count($result) lt count($collection)) then {
   http:set-header("x-truncated", "true");
   http:set-header("x-next", "/api?start=7b5c28c0");
} else {
 http:set-header("x-truncated", "false");
};
$result
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
<script type=”application/xquery”>
b:addEventListener(b:dom()//*:button, "onclick",
   function($ev, $obj){
     b:alert(“Clicked”)
   }
);
</script>
<script type="text/javascript">
foo = function (arg){
        return 'the text was '+ arg;
};
</script>

<script type="application/xquery">
! let $x := b:js-call('window.foo', “Foo”)
! return
     b:alert($x)
</script>
<script type="application/xquery">
b:js-eval('window.alert("eval!")')
</script>
declare variable $ui:easing := (0, 0.02, 0.08,
0.19, 0.33, 0.5, 0.67, 0.81, 0.92, 0.98, 1);

declare sequential function ui:fade() {
  declare $con     := b:dom()//*[@id = "entries"];
  declare $opacity := b:getStyle($con, "opacity");

     if($opacity lt 1) then (
       b:setStyle($con, "opacity",
                  $ui:easing[. gt $opacity][1]),
       b:timer(100, ui:fade#0)
     ) else b:setStyle($con, "opacity", 1)
};
Client                                          Server

<script type="application/xquery">
declare sequential function                        declare sequential function guestbook:add(
local:submit($loc, $evtObj)                           $author as xs:string, $entry as xs:string
{                                                  ){
                                                      let $date   := fn:current-dateTime()
     let $name    := s:id("author")/data(@value)      let $entry := <entry author="{$author}"
     let $text    := s:id("text")/text()                        datetime="{$date}">{$text}</entry>
     return                                           return
       guestbook:add($name, $text);                      xqddf:insert-nodes-last($entries, $entry);
};                                                 };

b:addEventListener(s:id("submit"),                 declare sequential function guestbook:list() {
                  "onclick",                          <entries>{
                   local:submit#2);                     xqddf:collection($entries)
                                                      }</entries>;
guestbook:list();                                  };
</script>
Client                                          Server

<script type="application/xquery">
declare sequential function                        declare sequential function guestbook:add(
local:submit($loc, $evtObj)                           $author as xs:string, $entry as xs:string
{                                                  ){
                                                      let $date   := fn:current-dateTime()
     let $name    := s:id("author")/data(@value)      let $entry := <entry author="{$author}"
     let $text    := s:id("text")/text()                        datetime="{$date}">{$text}</entry>
     return                                           return
       guestbook:add($name, $text);                      xqddf:insert-nodes-last($entries, $entry);
};                                                 };

b:addEventListener(s:id("submit"),                 declare sequential function guestbook:list(){
                  "onclick",                          <entries>{
                   local:submit#2);                     xqddf:collection($entries)
                                                      }</entries>;
guestbook:list();                                  };
</script>



         Seamless Invocations
Pubzone (2009)

                                  Model              View
                                  Controler

                           4100
    Lines of code



                    3100



                                                     1830

                                                             1210
                                    900
                                              450


                           Java                     XQuery
AWS Libraries

                                       Java               XQuery

                    8589
    Lines of code




                                          2905
                                                             2309
                                1469
                                                    572                   455


                           S3                 SimpleDB              SNS
AWS Libraries

                Java            XQuery

                 13803



                                         Lines of Codes
Lines of code




                                             - 80%
                               2496




                         AWS
AWS Libraries

                PHP            XQuery

                 6531



                                        Lines of Codes
Lines of code




                              2496
                                            - 62%

                        AWS
<html>
  <head>
    <script type='text/javascript'>
    function buy(e) {
       newElement = document.createElement("p");
       elementText = document.createTextNode
                  (e.target.getAttribute(id));
       newElement.appendChild(elementText);
       var res = document.evaluate(
         "//div[@id='shoppingcart']",
         document, null,
         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,            HTML
         null);
       res.snapshotItem(0).appendChild("newElement");}
    </script>                                               JavaScript
  </head>
  <body>
    <div>Shopping cart</div>
    <div id="shoppingcart"></div>
    <%
                                                             XPath
       // Code establishing connection
       ResultSet results =
       statement.executeQuery ("SELECT * FROM PRODUCTS");
       while (results.next()) {
         out.println("<div>");
                                                               Java
         String prodName = results.getString(1);
         out.println(prodName);
         out.println("<input type='button' value='Buy'");
         out.println("id='"+prodName+"'");                    SQL
         out.println("onclick='buy(event)'/>").
         out.println("</div>");
       }
       results.close();
       // Code closing connection
    %>
  </body>
</html>
<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>
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.”
GO



                   Mapping              Mapping
JavaScript                       Java             SQL
                      Glue               Glue




         GO
                    Seamless
                   Invocations
XQuery                                  XQuery
GO



                                           Mapping
JavaScript           Local          Java
                     Store                           SQL
                                            Glue
              Sync           Sync
GO



                                                        Mapping
JavaScript                    Local              Java
                              Store                               SQL
                                                         Glue
                   Sync                   Sync




         GO




XQuery                      Local                       XQuery
                            Store

                     Seamless Synchronisation
Demo Offline XQuery App
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
insert node attribute done { “true” }
  into xqddf:collection($todos)[@id = $id]
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=”...” />
insert node attribute done { “true” }
    into xqddf:collection($todos)[@id = $id]




           Local Store        2. Send PUL
TODOs   <todo done=”true”/>

PULs
insert node attribute done { “true” }
    into xqddf:collection($todos)[@id = $id]




           Local Store
                                     3. Apply PUL
TODOS   <todo done=”true”/>

PULs
Operators on Updates



• Aggregation
• Integration (+ detecting conflicts)
• Reconciliation of conflicts
• Reduction
• Inversion
Spacial Axis
Time Axis
avg(
           $tempA/future-or-current::*
              intersect
           $tempB/past-or-current::*
         )              Text


                                               Time
 68°       70°       65°      69°        72°

$tempA                               $tempB
28   msec
            Thank you!

Mais conteúdo relacionado

Mais procurados

Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using RoomNelson Glauber Leal
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KThomas Fuchs
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014Amazon Web Services
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015StampedeCon
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-futureyiming he
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天tblanlan
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserHoward Lewis Ship
 
Scalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDBScalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDBWilliam Candillon
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuerydeimos
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEBHoward Lewis Ship
 
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB
 
Hd insight programming
Hd insight programmingHd insight programming
Hd insight programmingCasear Chu
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 
Aplicações Assíncronas no Android com Coroutines e Jetpack
Aplicações Assíncronas no Android com Coroutines e JetpackAplicações Assíncronas no Android com Coroutines e Jetpack
Aplicações Assíncronas no Android com Coroutines e JetpackNelson Glauber Leal
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceAmazon Web Services
 
SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템HyeonSeok Choi
 
History of jQuery
History of jQueryHistory of jQuery
History of jQueryjeresig
 

Mais procurados (20)

Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
 
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
 
Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015Cassandra 3.0 - JSON at scale - StampedeCon 2015
Cassandra 3.0 - JSON at scale - StampedeCon 2015
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
 
Scalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDBScalable XQuery Processing with Zorba on top of MongoDB
Scalable XQuery Processing with Zorba on top of MongoDB
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuery
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDBMongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
 
Hd insight programming
Hd insight programmingHd insight programming
Hd insight programming
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
jQuery
jQueryjQuery
jQuery
 
Fatc
FatcFatc
Fatc
 
Aplicações Assíncronas no Android com Coroutines e Jetpack
Aplicações Assíncronas no Android com Coroutines e JetpackAplicações Assíncronas no Android com Coroutines e Jetpack
Aplicações Assíncronas no Android com Coroutines e Jetpack
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line Interface
 
SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템SICP_2.5 일반화된 연산시스템
SICP_2.5 일반화된 연산시스템
 
History of jQuery
History of jQueryHistory of jQuery
History of jQuery
 

Destaque

The Tao of Sharing: Social Media, Games, Photography
The Tao of Sharing: Social Media, Games, PhotographyThe Tao of Sharing: Social Media, Games, Photography
The Tao of Sharing: Social Media, Games, PhotographyPhillip Jeffrey
 
Amplified Events, Seminars, Conferences, ...: What? Why? How?
Amplified Events, Seminars, Conferences, ...: What? Why? How?Amplified Events, Seminars, Conferences, ...: What? Why? How?
Amplified Events, Seminars, Conferences, ...: What? Why? How?lisbk
 
Thinking The Unthinkable: Introduction
Thinking The Unthinkable: IntroductionThinking The Unthinkable: Introduction
Thinking The Unthinkable: Introductionlisbk
 
Performance and Creativity
Performance and CreativityPerformance and Creativity
Performance and CreativityPhillip Jeffrey
 
The Role of Facebook in Everyday Student Life
The Role of Facebook in Everyday Student LifeThe Role of Facebook in Everyday Student Life
The Role of Facebook in Everyday Student LifePhillip Jeffrey
 
7 pragmatic initiatives to improve your CX in 2017
7 pragmatic initiatives to improve your CX in  20177 pragmatic initiatives to improve your CX in  2017
7 pragmatic initiatives to improve your CX in 2017Stefan Kolle
 
10 things to make you think
10 things to make you think10 things to make you think
10 things to make you thinkStefan Kolle
 

Destaque (10)

The Tao of Sharing: Social Media, Games, Photography
The Tao of Sharing: Social Media, Games, PhotographyThe Tao of Sharing: Social Media, Games, Photography
The Tao of Sharing: Social Media, Games, Photography
 
Amplified Events, Seminars, Conferences, ...: What? Why? How?
Amplified Events, Seminars, Conferences, ...: What? Why? How?Amplified Events, Seminars, Conferences, ...: What? Why? How?
Amplified Events, Seminars, Conferences, ...: What? Why? How?
 
Thinking The Unthinkable: Introduction
Thinking The Unthinkable: IntroductionThinking The Unthinkable: Introduction
Thinking The Unthinkable: Introduction
 
Performance and Creativity
Performance and CreativityPerformance and Creativity
Performance and Creativity
 
The Role of Facebook in Everyday Student Life
The Role of Facebook in Everyday Student LifeThe Role of Facebook in Everyday Student Life
The Role of Facebook in Everyday Student Life
 
Facebook
FacebookFacebook
Facebook
 
My Summer of Code
My Summer of CodeMy Summer of Code
My Summer of Code
 
Extending and scripting PDT
Extending and scripting PDTExtending and scripting PDT
Extending and scripting PDT
 
7 pragmatic initiatives to improve your CX in 2017
7 pragmatic initiatives to improve your CX in  20177 pragmatic initiatives to improve your CX in  2017
7 pragmatic initiatives to improve your CX in 2017
 
10 things to make you think
10 things to make you think10 things to make you think
10 things to make you think
 

Semelhante a Not your Grandma's XQuery

G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門Tsuyoshi Yamamoto
 
Streaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & ElasticsearchStreaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & ElasticsearchKeira Zhou
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiecturesIegor Fadieiev
 
Lift 2 0
Lift 2 0Lift 2 0
Lift 2 0SO
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19confluent
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the mastersAra Pehlivanian
 
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To TailJavascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To TailCliffano Subagio
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Ben Lesh
 
Testowanie JavaScript
Testowanie JavaScriptTestowanie JavaScript
Testowanie JavaScriptTomasz Bak
 
KSQL - Stream Processing simplified!
KSQL - Stream Processing simplified!KSQL - Stream Processing simplified!
KSQL - Stream Processing simplified!Guido Schmutz
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsFrancois Zaninotto
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaAOE
 

Semelhante a Not your Grandma's XQuery (20)

G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
 
Streaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & ElasticsearchStreaming using Kafka Flink & Elasticsearch
Streaming using Kafka Flink & Elasticsearch
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiectures
 
Lift 2 0
Lift 2 0Lift 2 0
Lift 2 0
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
Javascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To TailJavascript Everywhere From Nose To Tail
Javascript Everywhere From Nose To Tail
 
Os Pruett
Os PruettOs Pruett
Os Pruett
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
Testowanie JavaScript
Testowanie JavaScriptTestowanie JavaScript
Testowanie JavaScript
 
KSQL - Stream Processing simplified!
KSQL - Stream Processing simplified!KSQL - Stream Processing simplified!
KSQL - Stream Processing simplified!
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS Lambda
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

Not your Grandma's XQuery

  • 1. 28 msec Not Your Grandma’s XQuery Key Features & Perspectives William Candillon {candillon@28msec.com} XML Amsterdam 2011
  • 2. “What I saw in your five-minutes talk hardly looks at all like the XQuery I saw back then.” - Daniel Weinred, Google
  • 7.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. Application Stack Client JavaScript Middleware Java Content Lucene Management Database MySQL
  • 23. Application Stack Client JavaScript Middleware Java Content XQuery Lucene Management Database MySQL
  • 24. Application Stack Client in the Browser Middleware Scripting Content XQuery Full-Text Management Data Definition Database Facility
  • 25. XQuery Data Definition Facility • Open Specification (http://goo.gl/XzK8p) • Implemented by Zorba (http://goo.gl/4huso) • Extending XQuery with - Collections - Indexes - Integrity Contraints
  • 26. declare collection f:forecasts as element(forecast);
  • 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();
  • 43. while(true()) { variable $request := server:listen("localhost", 8080); variable $response := api:process($request); api:serialize($response) };
  • 44. if(count($result) lt count($collection)) then { http:set-header("x-truncated", "true"); http:set-header("x-next", "/api?start=7b5c28c0"); } else { http:set-header("x-truncated", "false"); }; $result
  • 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
  • 46. <script type=”application/xquery”> b:addEventListener(b:dom()//*:button, "onclick", function($ev, $obj){ b:alert(“Clicked”) } ); </script>
  • 47. <script type="text/javascript"> foo = function (arg){ return 'the text was '+ arg; }; </script> <script type="application/xquery"> ! let $x := b:js-call('window.foo', “Foo”) ! return b:alert($x) </script>
  • 49. declare variable $ui:easing := (0, 0.02, 0.08, 0.19, 0.33, 0.5, 0.67, 0.81, 0.92, 0.98, 1); declare sequential function ui:fade() { declare $con := b:dom()//*[@id = "entries"]; declare $opacity := b:getStyle($con, "opacity"); if($opacity lt 1) then ( b:setStyle($con, "opacity", $ui:easing[. gt $opacity][1]), b:timer(100, ui:fade#0) ) else b:setStyle($con, "opacity", 1) };
  • 50. Client Server <script type="application/xquery"> declare sequential function declare sequential function guestbook:add( local:submit($loc, $evtObj) $author as xs:string, $entry as xs:string { ){ let $date := fn:current-dateTime() let $name := s:id("author")/data(@value) let $entry := <entry author="{$author}" let $text := s:id("text")/text() datetime="{$date}">{$text}</entry> return return guestbook:add($name, $text); xqddf:insert-nodes-last($entries, $entry); }; }; b:addEventListener(s:id("submit"), declare sequential function guestbook:list() { "onclick", <entries>{ local:submit#2); xqddf:collection($entries) }</entries>; guestbook:list(); }; </script>
  • 51. Client Server <script type="application/xquery"> declare sequential function declare sequential function guestbook:add( local:submit($loc, $evtObj) $author as xs:string, $entry as xs:string { ){ let $date := fn:current-dateTime() let $name := s:id("author")/data(@value) let $entry := <entry author="{$author}" let $text := s:id("text")/text() datetime="{$date}">{$text}</entry> return return guestbook:add($name, $text); xqddf:insert-nodes-last($entries, $entry); }; }; b:addEventListener(s:id("submit"), declare sequential function guestbook:list(){ "onclick", <entries>{ local:submit#2); xqddf:collection($entries) }</entries>; guestbook:list(); }; </script> Seamless Invocations
  • 52. Pubzone (2009) Model View Controler 4100 Lines of code 3100 1830 1210 900 450 Java XQuery
  • 53. AWS Libraries Java XQuery 8589 Lines of code 2905 2309 1469 572 455 S3 SimpleDB SNS
  • 54. AWS Libraries Java XQuery 13803 Lines of Codes Lines of code - 80% 2496 AWS
  • 55. AWS Libraries PHP XQuery 6531 Lines of Codes Lines of code 2496 - 62% AWS
  • 56. <html> <head> <script type='text/javascript'> function buy(e) { newElement = document.createElement("p"); elementText = document.createTextNode (e.target.getAttribute(id)); newElement.appendChild(elementText); var res = document.evaluate( "//div[@id='shoppingcart']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, HTML null); res.snapshotItem(0).appendChild("newElement");} </script> JavaScript </head> <body> <div>Shopping cart</div> <div id="shoppingcart"></div> <% XPath // Code establishing connection ResultSet results = statement.executeQuery ("SELECT * FROM PRODUCTS"); while (results.next()) { out.println("<div>"); Java String prodName = results.getString(1); out.println(prodName); out.println("<input type='button' value='Buy'"); out.println("id='"+prodName+"'"); SQL out.println("onclick='buy(event)'/>"). out.println("</div>"); } results.close(); // Code closing connection %> </body> </html>
  • 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
  • 64. insert node attribute done { “true” } into xqddf:collection($todos)[@id = $id]
  • 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
  • 71. avg( $tempA/future-or-current::* intersect $tempB/past-or-current::* ) Text Time 68° 70° 65° 69° 72° $tempA $tempB
  • 72.
  • 73. 28 msec Thank you!