0
AdventureswithBaseX andweb applications             Andy Bunce @apb1704                        Feb 2013
BaseX and the Web  ●   GraphXQ – RESTXQ + Graphviz  ●   ( Using a PaaS )  ●   CellarXQ – Angular.js + OAuth  ●   BaseX wit...
RESTXQ http://docs.basex.org/wiki/RESTXQ●   introduced by Adam Retter, is an API that    facilitates the use of XQuery as ...
GraphXQ – RESTXQ + Graphviz
Graphviz http://www.graphviz.org/                       ●   Open source graph                           (network) visualiz...
DOTML http://martin-loetzsch.de/DOTML/●   DotML is a XML based syntax for the input    language of the Dot graph drawing t...
Graphviz from BaseX●   Use proc:execute()●   Sadly has no pipe in so use temp file
GraphXQ
Twitter bootstraphttp://twitter.github.com/bootstrap/
Web page structure        Layout     Common menus         etc                Template                        Partial      ...
TXQ - Templatinghttp://cubeb.blogspot.com/2012/11/xquery-templating-engines-and-txq.html
Templating in use                    library.xml                         Item1.xml    Application   Default values
Using a PaaSBaseX inthe Cloud
Openshift https://openshift.redhat.com/app/
Openshift features ●    Has Java (and Node.js) pre-installed ●    Has a free option ●    Provides ssh terminal access(:~: ...
Openshift and BaseX●   Sign up, install tools●   Create a project using “DIY” cartridge●   This generates a git project wi...
CellarXQ – Angular.js + OAuthhttps://github.com/apb2006/basex-cellarBased on http://coenraets.org/blog/2012/02/sample-appl...
angular.js http://angularjs.org/●   AngularJS is an open-source JavaScript    framework from Google.●   Its goal is to aug...
Angular.js Hello world
JSON●   Angular expects to send and receive JSON●   The BaseX JSON serialization worked for meBut●   I had full control of...
The XML database
Updates●   Use db:output to mix updates and result
The user database●   Users defined at the application level.●   Data in users.xml in the database
Sign in and user session
Register new user
Permissions●   XQuery RESTXQ calls return status 404 if not    permissioned.●   Page routing and login prompt is handled a...
Application Configuration●   Stored in an XML file in WEB-INF●   Includes OAuth secrets and tokens
BaseX with Node.js + eventsAn XQuery chatbot in 50 lines...
node.js http://nodejs.org/●   is a platform built on Chromes JavaScript    runtime for easily building fast, scalable    n...
Basex-node https://github.com/apb2006/basex-node●   is a BaseX client for Node.js●   Uses the BaseX API over a socket●   A...
Basex-node sample
Socket.io http://socket.io/●   Socket.IO is a JavaScript library for realtime    web applications.●   a server-side librar...
Chat server   based on http://book.mixu.net/ch13.html
db:eventhttp://docs.basex.org/wiki/Database_Module#db:event●   Executes a $query and sends the resulting    value to all c...
Add BaseX session                                           Echo                                          Events          ...
the End  ●   http://open1-apb.rhcloud.com/restxq/graphxq  ●   http://open1-apb.rhcloud.com/cellar  ●   http://node2-apb.rh...
Upcoming SlideShare
Loading in...5
×

BaseX user-group-talk XML Prague 2013

2,246

Published on

Building Web applications using XQuery Basex and RESTXQ

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,246
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Asynchronous API
  • Complete code.
  • Create a “chat” event If we get receive it transmit data to all users
  • Transcript of "BaseX user-group-talk XML Prague 2013"

    1. 1. AdventureswithBaseX andweb applications Andy Bunce @apb1704 Feb 2013
    2. 2. BaseX and the Web ● GraphXQ – RESTXQ + Graphviz ● ( Using a PaaS ) ● CellarXQ – Angular.js + OAuth ● BaseX with Node.js + events
    3. 3. RESTXQ http://docs.basex.org/wiki/RESTXQ● introduced by Adam Retter, is an API that facilitates the use of XQuery as a Server Side processing language for the Web.● inspired by Java’s JAX-RS API.● a set of XQuery 3.0 annotations for mapping HTTP requests to XQuery functions.● the XQuery functions generate and return HTTP responses.
    4. 4. GraphXQ – RESTXQ + Graphviz
    5. 5. Graphviz http://www.graphviz.org/ ● Open source graph (network) visualization project from AT&T Research. ● directed and undirected graph layout ● i/p is string (dot syntax) ● o/p is SVG
    6. 6. DOTML http://martin-loetzsch.de/DOTML/● DotML is a XML based syntax for the input language of the Dot graph drawing tool
    7. 7. Graphviz from BaseX● Use proc:execute()● Sadly has no pipe in so use temp file
    8. 8. GraphXQ
    9. 9. Twitter bootstraphttp://twitter.github.com/bootstrap/
    10. 10. Web page structure Layout Common menus etc Template Partial Repeating items
    11. 11. TXQ - Templatinghttp://cubeb.blogspot.com/2012/11/xquery-templating-engines-and-txq.html
    12. 12. Templating in use library.xml Item1.xml Application Default values
    13. 13. Using a PaaSBaseX inthe Cloud
    14. 14. Openshift https://openshift.redhat.com/app/
    15. 15. Openshift features ● Has Java (and Node.js) pre-installed ● Has a free option ● Provides ssh terminal access(:~: There are other similar services: E.g. https://www.appfog.com/:)
    16. 16. Openshift and BaseX● Sign up, install tools● Create a project using “DIY” cartridge● This generates a git project with script stubs● Add your code and deploy using git push● Restrictions on usable ports# start basexcd ${OPENSHIFT_DATA_DIR}basexnohup bin/basexhttp -X-Dorg.basex.SERVERHOST=$OPENSHIFT_INTERNAL_IP -X -Dorg.basex.SERVERPORT=$OPENSHIFT_INTERNAL_PORT -p 15005 -e 15006 -s 15007 -U admin -P admin &
    17. 17. CellarXQ – Angular.js + OAuthhttps://github.com/apb2006/basex-cellarBased on http://coenraets.org/blog/2012/02/sample-application-with-angular-js/
    18. 18. angular.js http://angularjs.org/● AngularJS is an open-source JavaScript framework from Google.● Its goal is to augment browser-based applications with Model–View–Controller (MVC) capability.● Declarative data binding● Same space as XFORMS
    19. 19. Angular.js Hello world
    20. 20. JSON● Angular expects to send and receive JSON● The BaseX JSON serialization worked for meBut● I had full control of the XML● No namespaces etc...
    21. 21. The XML database
    22. 22. Updates● Use db:output to mix updates and result
    23. 23. The user database● Users defined at the application level.● Data in users.xml in the database
    24. 24. Sign in and user session
    25. 25. Register new user
    26. 26. Permissions● XQuery RESTXQ calls return status 404 if not permissioned.● Page routing and login prompt is handled at the Angular level.
    27. 27. Application Configuration● Stored in an XML file in WEB-INF● Includes OAuth secrets and tokens
    28. 28. BaseX with Node.js + eventsAn XQuery chatbot in 50 lines...
    29. 29. node.js http://nodejs.org/● is a platform built on Chromes JavaScript runtime for easily building fast, scalable network applications.● uses an event-driven, non-blocking I/O model that makes it lightweight and efficient● perfect for data-intensive real-time applications that run across distributed devices.
    30. 30. Basex-node https://github.com/apb2006/basex-node● is a BaseX client for Node.js● Uses the BaseX API over a socket● Available on npm
    31. 31. Basex-node sample
    32. 32. Socket.io http://socket.io/● Socket.IO is a JavaScript library for realtime web applications.● a server-side library for node.js● a client-side library that runs in the browser● uses the WebSocket protocol, but can fall-back on other methods, such as Adobe Flash sockets, JSONP polling, and AJAX long polling
    33. 33. Chat server based on http://book.mixu.net/ch13.html
    34. 34. db:eventhttp://docs.basex.org/wiki/Database_Module#db:event● Executes a $query and sends the resulting value to all clients watching the Event with the specified $name. The query may also perform updates; no event will be sent to the client that fired the event.● db:event($name as xs:string, $query as item()) as empty-sequence()
    35. 35. Add BaseX session Echo Events received Pass messages Starting “xquery “ for executionCode @ https://gist.github.com/4707605
    36. 36. the End ● http://open1-apb.rhcloud.com/restxq/graphxq ● http://open1-apb.rhcloud.com/cellar ● http://node2-apb.rhcloud.com/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×