XQUERY? Just a query Language for XML? Right? NO NO - - PowerPoint PPT Presentation

xquery just a query language for xml right no no no
SMART_READER_LITE
LIVE PREVIEW

XQUERY? Just a query Language for XML? Right? NO NO - - PowerPoint PPT Presentation

XQuery vs . The World Nuno Job nunojob.com nunojob.com and @dscape dscape (twitter, github) Dynamic Languages Conference 2011 portugal, new york, toronto, san francisco, london 11


slide-1
SLIDE 1

XQuery ¡vs. ¡The ¡World ¡

Nuno Job

¡

¡ ¡ Dynamic ¡Languages ¡Conference ¡2011 ¡

nunojob.com nunojob.com and @dscape dscape (twitter, github)

slide-2
SLIDE 2

H ¡E ¡L ¡L ¡O ¡

m y ¡ n a m e ¡ i s ¡

Nuno

@dscape

past. present. portugal, new york, toronto, san francisco, london

83 08 09 10 11

stuff I like

slide-3
SLIDE 3

unstructured schema-less* easy evolution. xml or json. native search a database built

  • n a search engine?

c++ core ~ pb scale features acid, backups replication, query language (XQuery).

* they have this universal index thing. an inverted index that is structure aware

also stores: text and binaries no tables, rows, columns thinkin’ documents uris? looks like a filesystem

stop shredding your data start storing data as is

!!

slide-4
SLIDE 4

XQUERY? ¡

slide-5
SLIDE 5

Just ¡a ¡query ¡Language ¡for ¡XML? ¡ ¡ Right? ¡

slide-6
SLIDE 6

NO ¡NO ¡NO ¡ NO ¡NO ¡NO ¡ NO ¡NO ¡NO ¡

slide-7
SLIDE 7

Ok, ¡ok… ¡

YES, ¡but… ¡

slide-8
SLIDE 8

SQL ¡Like?

for $name in //json:name let $first := fn:tokenize($name, " ")[1] where $first != 'chad' return $name

slide-9
SLIDE 9

¡but… ¡

slide-10
SLIDE 10

Literals ¡

<names> { for $name in //name return <name>{$name}</name> } </names>

slide-11
SLIDE 11

FuncGons ¡

¡ declare ¡funcGon ¡local:hello($name) ¡{ ¡ ¡ ¡concat("Hello ¡", ¡$name) ¡ }; ¡ ¡ local:hello("Edinburgh!") ¡ main function

slide-12
SLIDE 12

High ¡Order ¡FuncGons ¡

declare function fold($f, $z, $l) { if(empty($l)) then $z else fold( $f, xdmp:apply($f, $z, head($l)), tail($l)) } ;

https://github.com/dscape/dxc

slide-13
SLIDE 13

Meta ¡Programming ¡

mustache:render( ‘ Hello {{name}}! 
 You have just won {{value}} usd! {{#in_ca}} Well, {{taxed_value}} usd, 
 after taxes. {{/in_ca}} ’, ‘ { "name": "Chris", "value": 10000, "taxed_value": 
 10000 - (10000 * 0.4), "in_ca": true } ’)

https://github.com/dscape/mustache.xq

slide-14
SLIDE 14

Data ¡Model ¡

xdm xdm

xquery

zero or more items item is either an atomic type (like string or integer)

  • r a tree
slide-15
SLIDE 15

Element node Attribute Node Text Node

slide-16
SLIDE 16

NavigaGon ¡language ¡(XPath) ¡

/user ¡ ¡ ¡[sex="male"] ¡ ¡ ¡ ¡ ¡//name ¡ ¡ ¡ ¡ ¡ ¡ ¡/text() ¡ similar to file paths but you can have repeated element in xml, unlike filesystems where folders are unique child axis predicate descendants node test

slide-17
SLIDE 17

Side ¡Effect ¡Free ¡

if($user) then ($user) else ()

* actually this is the same as just $user

slide-18
SLIDE 18

Great ¡for ¡querying ¡documents ¡

( for $song in /top-song let $artist := $song/artist let $recorded := $song/recorded let $london := geo:latLong ("London") where $artist = "Queen" and not($recorded=$london)

  • rder by $song/weeks/@last descending

return song:render($song) ) [1 to 10]

slide-19
SLIDE 19

JavaScript ¡is ¡to ¡JSON ¡ ¡ like ¡XQuery ¡is ¡to ¡XML ¡

and there are plenty of problems for which and there are plenty of problems for which xml is a better fit xml is a better fit

slide-20
SLIDE 20

Q U E R I E S ¡ P A R S E R S ¡ TEMPLATING ¡ ENGINES ¡ WEB ¡ APPS ¡ APIS ¡ URL ¡ REWRITERS ¡ ¡ SCRIPTS ¡ FRAMEWORKS ¡ MOBILE ¡ ¡ E N T E R P R I S E ¡ A P P S ¡ BROWSER ¡ LANGUAGES ¡

slide-21
SLIDE 21

XQuery ¡

¡

¡ A ¡fully ¡fledged ¡dynamic ¡funcEonal ¡

programming ¡language ¡

also a query language for xml…

also a query language for xml…

slide-22
SLIDE 22

STILL ¡WANT ¡YOUR ¡DOCUMENT ¡ DATABASE ¡TO ¡SUPPORT ¡SQL ¡ AND ¡ONLY ¡SQL? ¡ ¡

¡ WHY ¡OH ¡WHY? ¡

disagree? hfp://bit.ly/sqlfordocs ¡

slide-23
SLIDE 23

WHY ¡CARE? ¡

Lifle ¡know ¡facts ¡

slide-24
SLIDE 24

WELL ¡PAID ¡ HIGH ¡DEMAND, ¡LOW ¡SUPPLY ¡

in average (in the uk) there is one job posting in indeed for each two people that state they know xquery in linkedin

slide-25
SLIDE 25

WORKING ¡ON ¡PB ¡SCALE ¡DEPLOYMENTS ¡ WITH ¡ACID ¡TRANSACTIONS? ¡

that looks fun

http://writings.nunojob.com/slides/2011-bbuzz.pdf http://vimeo.com/26777627

slide-26
SLIDE 26

ANYONE ¡USING ¡IT? ¡

slide-27
SLIDE 27

Yup! ¡

go check our customer list. it’s likely you’ll be go check our customer list. it’s likely you’ll be surprised to find out you use surprised to find out you use marklogic marklogic after all after all

slide-28
SLIDE 28

DID ¡I ¡FORGOT ¡TO ¡MENTION ¡THE ¡COOL ¡ STUFF ¡WE ¡DO ¡AT ¡MARKLOGIC? ¡

free download & fair use hfp://developer.marklogic.com ¡

slide-29
SLIDE 29

XQuery ¡in ¡one ¡slide ¡

¡ ¡

W3C Open Standard Standalone programming language Data Focused Single Tier Development Rich API

Regular expressions, strings, sequences, etc…

Extensible with your own libraries Side-effect free

Great for concurrency XDM

  • AnyDB

JDBC ¡ SQL ¡

serialize ¡

XML

transmit ¡

XML

deserialize ¡ serialize ¡

XML

insert ¡

Java ¡

update ¡

XQuery ¡ update ¡

slide-30
SLIDE 30

learn ¡something ¡ new ¡every ¡day ¡

slide-31
SLIDE 31

@DSCAPE ¡

Thank ¡you! ¡QuesGons? ¡