Big Data 12. Querying

Size: px
Start display at page:

Download "Big Data 12. Querying"

Transcription

1 Ghislain Fourny Big Data 12. Querying pinkyone / 123RF Stock Photo

2 Declarative Languages What vs. How 2

3 Functional Languages for let order by if + any else = then every while where return exit with Expression 3

4 Ever played Lego? 4

5 Ever played Lego? if( ) then else 5

6 Ever played Lego? if( ) my:func( ) then else 6

7 Ever played Lego? if( ) my:func( ) then else 7

8 Ever played Lego? if( ) my:func( ) 2 then else 8

9 Ever played Lego? if( ) my:func( ) 2 then for $x in let $y := return else 9

10 Ever played Lego? if( ) my:func( ) 2 then for $x in let $y := return else 10

11 Ever played Lego? if( ) my:func( ) 2 then for $x in let $y := return else 11

12 Language ecosystem XML JSON Navigation XPath JSONPath JSONSelect 12

13 Language ecosystem XML JSON Navigation XPath JSONPath JSONSelect Transform XSLT JSONT 13

14 Language ecosystem XML JSON Navigation XPath JSONPath JSONSelect Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq 14

15 Language ecosystem XML JSON Navigation XPath JSONPath JSONSelect Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting JSONiq 15

16 Try it out! 16

17 XML Navigation (XPath, XQuery) 17

18 The slash operator <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml")/countries/country/name 18

19 The slash operator <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">&!!!!<name>switzerland</name>! &&</country>& &&<country&code="f">&!!!!<name>france</name>! &&</country>& &&<country&code="d">&!!!!<name>germany</name>! &&</country>& &&<country&code="i">&!!!!<name>italy</name>! &&</country>& &&<country&code="a">&!!!!<name>austria</name>! &&</country>& </countries>& & doc("myfile.xml")/countries/country/name 19

20 Axis <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">&!!!!<name>switzerland</name>! &&</country>& &&<country&code="f">&!!!!<name>france</name>! &&</country>& &&<country&code="d">&!!!!<name>germany</name>! &&</country>& &&<country&code="i">&!!!!<name>italy</name>! &&</country>& &&<country&code="a">&!!!!<name>austria</name>! &&</country>& </countries>& & doc("myfile.xml") /child::countries /child::country /child::name 20

21 Axis <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">&!!!!<name>switzerland</name>! &&</country>& &&<country&code="f">&!!!!<name>france</name>! &&</country>& &&<country&code="d">&!!!!<name>germany</name>! &&</country>& &&<country&code="i">&!!!!<name>italy</name>! &&</country>& &&<country&code="a">&!!!!<name>austria</name>! &&</country>& </countries>& & doc("myfile.xml") /descendant::country /child::name 21

22 All Axes Forward Axes self:: attribute:: child:: descendant:: descendant-or-self:: following-sibling:: following:: Reverse Axes parent:: ancestor:: ancestor-or-self:: preceding-sibling:: preceding:: 22

23 Axis <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& doc("myfile.xml") /descendant::country /child::name 23

24 Axis <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& doc("myfile.xml") /descendant::country /attribute::code/data() 24

25 Attribute Abbreviation <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& doc("myfile.xml") /descendant::country 25

26 Descendant-or-self Abbreviation <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& doc("myfile.xml") //country 26

27 Filters <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] 27

28 Implicit Context Item <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] 28

29 Joker <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country)code="ch">) ))))<name>switzerland</name>) ))</country>) &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] /parent::* 29

30 Parent Abbreviation <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country)code="ch">) ))))<name>switzerland</name>) ))</country>) &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] /.. 30

31 Alternative <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country)code="ch">) ))))<name>switzerland</name>) ))</country>) &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] 31

32 Atomization <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country)code="ch">) ))))<name>switzerland</name>) ))</country>) &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] 32

33 Atomization <name>switzerland</name>0 <name>france</name>0 <name>germany</name>0 <name>italy</name>0 <name>austria</name>0 0 data( ) Switzerland, France, Germany, Italy, Austria, 33

34 Kind test <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">&!!!!<name>switzerland</name>! &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] /child::element() 34

35 All Kinds Simplest document-node() element() attribute() text() comment() processing-instruction() namespace-node() More precise document-node(element(countries)) element(countries) element(name, xs:string) schema-element(country) attribute(*, xs:integer) schema-attribute(code) processing-instruction(excel) 35

36 Kind test <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">&!!!!<name>switzerland</name>! &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] /element() 36

37 Simpler <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">&!!!!<name>switzerland</name>! &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] /name 37

38 Continued <?xml&version="1.0"&encoding="utf98"?>& <countries>& &&<country&code="ch">& &&&&<name>switzerland</name>& &&</country>& &&<country&code="f">& &&&&<name>france</name>& &&</country>& &&<country&code="d">& &&&&<name>germany</name>& &&</country>& &&<country&code="i">& &&&&<name>italy</name>& &&</country>& &&<country&code="a">& &&&&<name>austria</name>& &&</country>& </countries>& & doc("myfile.xml") /descendant::country eq "CH"] /name/data() 38

39 Construction (XPath, XQuery) 39

40 Construction: Strings "foo" 40

41 Construction: String Escaping "This is a line and this is a new line" "This is a "quote"" 41

42 Construction: Numbers E23 42

43 Construction: Booleans true() false() 43

44 Construction: Other Simple Types date(" ") datetime(" t05:00:00z") long(" ") 44

45 Construction: XML <foo attr="value"> Text <bar/> <!-- comment --> <?target pi?> </foo> 45

46 XQuery: Basic Operations 46

47 Basic Operations: Sequences concatenation 1, true(), "foo", <bar/> 47

48 Basic Operations: Sequences concatenation 1, true(), "foo", <bar/> range 1 to

49 Basic Operations: Arithmetics addition

50 Basic Operations: Arithmetics addition Two steps before the arithmetic computation is made: 50

51 Basic Operations: Arithmetics addition Two steps before the arithmetic computation is made: 1. Atomization 51

52 Basic Operations: Arithmetics addition Two steps before the arithmetic computation is made: 1. Atomization 2. Cast 52

53 Basic Operations: Arithmetics addition Two steps before the arithmetic computation is made: 1. Atomization 2. Cast double("1.42") 53

54 Basic Operations: Arithmetics addition substraction multiplication <a>6</a> * 7 division 42.3 div 7.2 integer division 42 idiv 9 module 42 mod 9 54

55 Basic Operations: Strings concatenation "foo" "bar" concat("foo", "bar") string-join( ("foo", "bar", "foobar"), "-" ) sub-string substr("foobar", 4, 3) length string-length("foobar") 55

56 Basic Operations: Value Comparison equality eq 2 inequality 6 * 7 ne 21 * 2 greater than 234 gt ge 123 less than 42.3 lt le

57 Basic Operations: Value Comparison 1. Zero or one item for each operand 1 eq 2 1 eq () () eq "foo" 57

58 Basic Operations: Value Comparison 1. Zero or one item for each operand (1, 2) eq 2 58

59 Basic Operations: Value Comparison 1. Zero or one item for each operand (1, 2) eq 2 error! 59

60 Basic Operations: Value Comparison 1. Zero or one item for each operand (1, 2) eq 2 error! 2. Types must be compatible 60

61 Basic Operations: Value Comparison 1. Zero or one item for each operand (1, 2) eq 2 error! 2. Types must be compatible 1 eq "foo" 61

62 Basic Operations: Value Comparison 1. Zero or one item for each operand (1, 2) eq 2 error! 2. Types must be compatible 1 eq "foo" error! 62

63 Basic Operations: General Comparison $doc//country/name = "Switzerland" 63

64 Basic Operations: General Comparison $doc//country/name = "Switzerland" =!= < > <= <= 64

65 Basic Operations: General Comparison $doc//country/name = "Switzerland" At least one =!= < > <= <= 65

66 Basic Operations: Logics conjunction 1+1 eq 2 and 2+2 eq 4 disjunction 1+1 eq 2 or 2+2 eq 4 not not(100 mod 5 eq 0) 66

67 Basic Operations: Logics conjunction 1+1 eq 2 and 2+2 eq 4 disjunction 1+1 eq 2 or 2+2 eq 4 not not(100 mod 5 eq 0) universal quantifier existential quantifier every $i in (1 to 10) satisfies $i gt 0 some $i in (1 to 10) satisfies $i eq 3*3 67

68 Basic Operations: Logics 1. It's two-valued logics 68

69 Basic Operations: Logics 1. It's two-valued logics 2. Non-booleans get converted not("foo") 69

70 Basic Operations: Effective Boolean Value Sequence "" Effective Boolean Value (EBV) 70

71 Basic Operations: Effective Boolean Value Sequence "" false Effective Boolean Value (EBV) 71

72 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) 72

73 Basic Operations: Effective Boolean Value Sequence "" false Effective Boolean Value (EBV) "foo" true 73

74 Basic Operations: Effective Boolean Value Sequence "" false Effective Boolean Value (EBV) "foo" 0 true 74

75 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 75

76 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 42 76

77 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 42 true 77

78 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 42 true (<foo/>, <bar/>, 1, "foo") 78

79 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 42 true (<foo/>, <bar/>, 1, "foo") true 79

80 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 42 true (<foo/>, <bar/>, 1, "foo") () true 80

81 Basic Operations: Effective Boolean Value Sequence "" false "foo" Effective Boolean Value (EBV) true 0 false 42 true (<foo/>, <bar/>, 1, "foo") true () false 81

82 Composability 82

83 Rule of Thumb Any Expression can be the operand of any other expression. 83

84 Precedence Precedence (low first) Comma 84

85 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) 85

86 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic 86

87 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison 87

88 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation 88

89 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation Range 89

90 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation Range Arithmetic 90

91 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation Range Arithmetic Path expressions 91

92 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation Range Arithmetic Path expressions Filter predicates, dynamic function calls 92

93 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation Range Arithmetic Path expressions Filter predicates, dynamic function calls Literals, constructors and variables Function calls, named function references, inline functions 93

94 Precedence Precedence (low first) Comma Data Flow (FLWOR, if-then-else, switch...) Logic Comparison String concatenation Range Arithmetic Path expressions Filter predicates, dynamic function calls Literals, constructors and variables Function calls, named function references, inline functions Use parentheses to override or when in doubt! 94

95 XML Construction reloaded <foo attr="{string-length("foobar")}"> { string-join( for $i in 1 to 10 return string($i), "-" ) } </foo> 95

96 XML Construction reloaded <foo attr="{string-length("foobar")}"> { string-join( for $i in 1 to 10 return string($i), "-" ) } </foo> <foo attr="6"> </foo> 96

97 Data Flow (XQuery) 97

98 Conditional Expressions if(count(doc("file.xml")//country) gt 1000) then "Large file!" else "Small file." 98

99 Switch Expressions switch($country/code) case "CH" return ("gsw", "de", "fr", "it", "rm") case "F" return "fr" case "D" return "de" case "I" return "it" default return "en" 99

100 Try Catch Expressions try { xs:integer($country/code) } catch * { "A country code is not an integer!" } 100

101 Alexander Raths / 123RF Stock Photo FLWOR Expressions (XQuery) 101

102 Let clauses let $x := 2 return $x * $x 102

103 Let clauses let $x := 2 let $y := $x + $x let $x := $y + 3 return $x * $x 103

104 For clauses for $x in (1, 2, 4) return $x * $x 104

105 Where clauses for $x in 1 to 10 where $x - 2 gt 5 return $x * $x 105

106 For clauses for $x in 1 to 10 return <square number="{$x}">{ $x * $x }</square> 106

107 Order by clauses for $x in doc("countries.xml")//country order by $x/population return $x/name/data() 107

108 Group by clauses for $x in doc("countries.xml")//country group by $continent := return <continent code="{$continent}">{ for $country in $x return $country/name }</continent> 108

109 Tuple stream semantics for $x in 1 to 10 where $x - 2 gt 5 return $x * $x 109

110 Tuple stream semantics for $x in 1 to 10 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 where $x - 2 gt 5 return $x * $x 110

111 Tuple stream semantics for $x in 1 to 10 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 where $x - 2 gt 5 x 8 x 9 x 10 return $x * $x 111

112 Tuple stream semantics for $x in 1 to 10 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 where $x - 2 gt 5 x 8 x 9 x 10 return $x * $x (64, 81, 100) 112

113 Tuple stream semantics for $x in 1 to 5 let $y := $x - 2 return $x * $y 113

114 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 let $y := $x - 2 return $x * $y 114

115 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 let $y := $x - 2 x 1 y -1 x 2 y 0 x 3 y 1 x 4 y 2 x 5 y 3 return $x * $y 115

116 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 let $y := $x - 2 x 1 y -1 x 2 y 0 x 3 y 1 x 4 y 2 x 5 y 3 return $x * $y (-1, 0, 3, 8, 15) 116

117 Tuple stream semantics for $x in 1 to 5 group by $y := $x mod 2 return { "foo" : $y, "bar" : count($x) } 117

118 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 group by $y := $x mod 2 return { "foo" : $y, "bar" : count($x) } 118

119 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 group by $y := $x mod 2 y 0 y 1 return { "foo" : $y, "bar" : count($x) } 119

120 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 group by $y := $x mod 2 y 0 x 2 4 y 1 x return { "foo" : $y, "bar" : count($x) } 120

121 Tuple stream semantics for $x in 1 to 5 x 1 x 2 x 3 x 4 x 5 group by $y := $x mod 2 y 0 x 2 4 y 1 x return { "foo" : $y, "bar" : count($x) } { "foo" : 0, "bar" : 2 }, { "foo" : 1, "bar" : 3 } 121

122 Types 122

123 Types Simple types: by name xs:integer 123

124 Types Simple types: by name xs:integer Complex types: by kind, similar to XPath element(foo) 124

125 Cardinality xs:integer 125

126 Cardinality xs:integer xs:boolean? 126

127 Cardinality xs:integer xs:boolean? element(foo)+ 127

128 Cardinality xs:integer xs:boolean? element(foo)+ document-node()* 128

129 Type usage let $x as xs:integer := 2 return $x + $x 129

130 Type usage let $x as node() := <foo>2</foo> return $x + $x 130

131 Type usage for $x as element(foo)* in ( <foo>2</foo>, <foo>3</foo> ) return $x + $x 131

132 Type usage for $x as element(foo)* in ( <foo>2</foo>, <foo>3</foo> ) return $x + $x treat as xs:integer 132

133 Type usage for $x as element(foo)* in ( <foo>2</foo>, <foo>3</foo> ) return $x + $x cast as xs:double 133

134 Type usage for $x as element(foo)* in ( <foo>2</foo>, <foo>3</foo> ) return xs:double($x + $x) 134

135 Type usage 3.14 instance of xs:integer 135

136 Type usage 3.14 castable as xs:double 136

137 Type usage declare function local:is-big-data( $threshold as xs:integer, $doc as document-node() ) as xs:boolean { count($doc//*) gt $threshold }; 137

138 Type usage declare function local:is-big-data( $threshold as xs:integer, $doc as document-node() ) as xs:boolean { count($doc//*) gt $threshold }; local:is-big-data(1000, doc("big-file.xml") 138

139 Validation import'schema'namespace'm!=! validate!{! <m:math!xmlns:m=" </m:math>! }!! 139

140 Querying JSON (XQuery 3.1 / JSONiq) 140

141 JSON Navigation: Objects let $object := { "foo": 31, "bar" : "ETH" } return $object.foo JSONiq 141

142 JSON Navigation: Objects let $object := { "foo": 31, "bar" : "ETH" } return $object.foo let $object := map { "foo": 31, "bar" : "ETH" } return $object?foo JSONiq XQuery

143 JSON Navigation: Arrays let $object := { "foo": 31, "bar": [ "ETH", "EPF" ] } return $object.foo[[1]] JSONiq 143

144 JSON Navigation: Arrays let $object := { "foo": 31, "bar": [ "ETH", "EPF" ] } return $object.foo[[1]] let $object := map { "foo": 31, "bar": array { "ETH", "EPF" } } return $object?foo?1 JSONiq XQuery

145 JSON Navigation: Arrays let $object := { "foo": 31, "bar": [ "ETH", "EPF" ] } return $object.foo[] JSONiq 145

146 JSON Navigation: Arrays let $object := { "foo": 31, "bar": [ "ETH", "EPF" ] } return $object.foo[] let $object := map { "foo": 31, "bar": array { "ETH", "EPF" } } return $object?foo?* JSONiq XQuery

147 JSON Construction: Composability map { "Swiss people" : doc("switzerland.xml") //country/population/data() } 147

148 JSON Construction: XQuery 3.1 and arrays array { 1 to 3, (), 4 to 6 } 148

149 JSON Construction: XQuery 3.1 and arrays array { 1 to 3, (), 4 to 6 } [ 1, 2, 3, 4, 5, 6 ] 149

150 JSON Construction: XQuery 3.1 and arrays array { 1 to 3, (), 4 to 6 } [ 1, 2, 3, 4, 5, 6 ] [ 1 to 3, (), 4 to 6 ] 150

151 JSON Construction: XQuery 3.1 and arrays array { 1 to 3, (), 4 to 6 } [ 1, 2, 3, 4, 5, 6 ] [ 1 to 3, (), 4 to 6 ] [ (1, 2, 3), (), (4, 5, 6) ] 151

152 XQuery 3.1 vs. JSONiq XQuery 3.1 JSONiq Primary use case data structures (maps, arrays) document stores (JSON) 152

153 XQuery 3.1 vs. JSONiq XQuery 3.1 JSONiq Primary use case data structures (maps, arrays) document stores (JSON) Keys Any atomic types Strings only 153

154 XQuery 3.1 vs. JSONiq XQuery 3.1 JSONiq Primary use case data structures (maps, arrays) document stores (JSON) Keys Any atomic types Strings only Values Any sequences of items Single items 154

155 XQuery 3.1 vs. JSONiq XQuery 3.1 JSONiq Primary use case data structures (maps, arrays) document stores (JSON) Keys Any atomic types Strings only Values Any sequences of items Single items Constructor content Preserving identity Copied 155

156 Final examples 156

157 Example 157

158 Titles sorted by price for$$b!in$doc("bib.xml")//book! order$by$xs:float($b/price)!descending,!!!!!!!!!!$b/title!ascending! return$$b/title!! 158

159 Titles sorted by price for$$b!in$doc("bib.xml")//book!!!! 159

160 Titles sorted by price for$$b!in$doc("bib.xml")//book! order$by$xs:float($b/price)!descending,!!!!!!!!!!$b/title!ascending!!! 160

161 Titles sorted by price for$$b!in$doc("bib.xml")//book! order$by$xs:float($b/price)!descending,!!!!!!!!!!$b/title!ascending! return$$b/title!! 161

162 How many books written by Stevens? doc("bib.xml")//book+ 162

163 How many books written by Stevens? doc("bib.xml")//book[author,=,"stevens"], 163

164 How many books written by Abiteboul? 2 count(doc("bib.xml")//book[author,=,"stevens"]), 164

165 Number of books by author doc("bib.xml")** 165

166 Number of books by author doc("bib.xml")//author

167 Number of books by author for$$a!in$doc("bib.xml")//author/data()! 167

168 Number of books by author for$$a!in$distinct' values(doc("bib.xml")//author)!!!!! 168

169 Number of books by author <?xml version="1.0" encoding="utf-8"?> <res> <name>stevens</name> </res> <res> <name>abiteboul</name> </res> <res> <name>buneman</name> </res> <res> <name>suciu</name> </res> for$$a!in$distinct' values(doc("bib.xml")//author)! return$<res>!!!<name>{$a}</name>!!!<count>!!!{!!!!!count(doc("bib.xml")//book[author!=!$a])!!!}!!!</count>! </res>!!!! 169

170 Number of books by author <?xml version="1.0" encoding="utf-8"?> <res> <name>stevens</name> <count>2</count> </res> <res> <name>abiteboul</name> <count>2</count> </res> <res> <name>buneman</name> <count>1</count> </res> <res> <name>suciu</name> <count>1</count> </res> for$$a!in$distinct' values(doc("bib.xml")//author)! return$<res>!!!<name>{$a}</name>!!!<count>!!!{!!!!!count(doc("bib.xml")//book[author!=!$a])!!!}!!!</count>! </res>!!!! 170

171 Not covered Higher-order functions Computed constructors Count clause Window clause Node comparison Errors Typeswitch 171

172 There s more XQuery Updates XQuery Full-Text XQuery Scripting insert node <foo/> into $doc/bar /books/book[@number="1"]/title contains text "improve" using stemming while ($x gt 0) { $x := $x 1; } 172

Big Data 10. Querying

Big Data 10. Querying Ghislain Fourny Big Data 10. Querying pinkyone / 123RF Stock Photo 1 Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

Progress Report on XQuery

Progress Report on XQuery Progress Report on XQuery Don Chamberlin Almaden Research Center May 24, 2002 History Dec. '98: W3C sponsors workshop on XML Query Oct. '99: W3C charters XML Query working group Chair: Paul Cotton About

More information

Advanced Database Technologies XQuery

Advanced Database Technologies XQuery Advanced Database Technologies XQuery Christian Grün Database & Information Systems Group Introduction What is XQuery? query language (more than a) counterpart to SQL functional language general purpose

More information

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1 XQuery Leonidas Fegaras University of Texas at Arlington Web Databases and XML L7: XQuery 1 XQuery Influenced by SQL Based on XPath Purely functional language may access elements from documents, may construct

More information

Big Data Exercises. Fall 2016 Week 9 ETH Zurich

Big Data Exercises. Fall 2016 Week 9 ETH Zurich Big Data Exercises Fall 2016 Week 9 ETH Zurich Introduction This exercise will cover XQuery. You will be using oxygen (https://www.oxygenxml.com/xml_editor/software_archive_editor.html), AN XML/JSON development

More information

Navigating Input Documents Using Paths4

Navigating Input Documents Using Paths4 Chapter 4 CHAPTER 4 Navigating Input Documents Using Paths4 Path expressions are used to navigate input documents to select elements and attributes of interest. This chapter explains how to use path expressions

More information

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar..

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. Overview Introduction to XQuery XQuery is an XML query language. It became a World Wide Web Consortium Recommendation in January 2007,

More information

Parte IV: XPATH. Prof. Riccardo Torlone

Parte IV: XPATH. Prof. Riccardo Torlone BASI DI DATI II 2 modulo Parte IV: XPATH Prof. Riccardo Torlone Università Roma Tre Outline Location steps and paths Typical locations paths Abbreviations General expressions Riccardo Torlone: Basi di

More information

BASI DI DATI II 2 modulo

BASI DI DATI II 2 modulo BASI DI DATI II 2 modulo COMPLMNTI DI BASI DI DATI Parte IV: XPATH Prof. Riccardo Torlone Università Roma Tre Outline Location steps and paths Typical locations paths Abbreviations General expressions

More information

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p:// TDDD43

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p://  TDDD43 Theme 1.2: XML query languages Fang Wei- Kleiner h?p://www.ida.liu.se/~ Query languages for XML Xpath o Path expressions with conditions o Building block of other standards (XQuery, XSLT, XLink, XPointer,

More information

Anders Møller & Michael I. Schwartzbach 2006 Addison-Wesley

Anders Møller & Michael I. Schwartzbach 2006 Addison-Wesley Anders Møller & Michael I. Schwartzbach 2006 Addison-Wesley Location steps and paths Typical locations paths Abbreviations General expressions 2 Flexible notation for navigating around trees A basic technology

More information

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018 XPath and XQuery Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue. Oct. 23) Homework #3 due in two weeks Project milestone #1 feedback : we are a bit behind, but will definitely release

More information

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9 XML databases Jan Chomicki University at Buffalo Jan Chomicki (University at Buffalo) XML databases 1 / 9 Outline 1 XML data model 2 XPath 3 XQuery Jan Chomicki (University at Buffalo) XML databases 2

More information

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data Pre-Discussion XQuery: An XML Query Language D. Chamberlin After the presentation, we will evaluate XQuery. During the presentation, think about consequences of the design decisions on the usability of

More information

Course: The XPath Language

Course: The XPath Language 1 / 27 Course: The XPath Language Pierre Genevès CNRS University of Grenoble, 2012 2013 2 / 27 Why XPath? Search, selection and extraction of information from XML documents are essential for any kind of

More information

Seleniet XPATH Locator QuickRef

Seleniet XPATH Locator QuickRef Seleniet XPATH Locator QuickRef Author(s) Thomas Eitzenberger Version 0.2 Status Ready for review Page 1 of 11 Content Selecting Nodes...3 Predicates...3 Selecting Unknown Nodes...4 Selecting Several Paths...5

More information

XML Technologies. Doc. RNDr. Irena Holubova, Ph.D. Web pages:

XML Technologies. Doc. RNDr. Irena Holubova, Ph.D. Web pages: XML Technologies Doc. RNDr. Irena Holubova, Ph.D. holubova@ksi.mff.cuni.cz Web pages: http://www.ksi.mff.cuni.cz/~holubova/nprg036/ Outline Introduction to XML format, overview of XML technologies DTD

More information

XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau

XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau XML Query Languages Yanlei Diao UMass Amherst April 22, 2008 Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau 1 Querying XML How do you query a directed graph? a tree?

More information

Module 4. Implementation of XQuery. Part 1: Overview of Compiler, Runtime System

Module 4. Implementation of XQuery. Part 1: Overview of Compiler, Runtime System Module 4 Implementation of XQuery Part 1: Overview of Compiler, Runtime System Now let us talk XQuery Compile Time + Optimizations Operator Models Query Rewrite Runtime + Query Execution XML Data Representation

More information

Big Data 9. Data Models

Big Data 9. Data Models Ghislain Fourny Big Data 9. Data Models pinkyone / 123RF Stock Photo 1 Syntax vs. Data Models Physical view Syntax this is text. 2 Syntax vs. Data Models a Logical view

More information

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University XPath Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept. of Computer Engineering Khon Kaen University 1 Overview What is XPath? Queries The XPath Data Model Location Paths Expressions

More information

Outline of this part (I) Part IV. Querying XML Documents. Querying XML Documents. Outline of this part (II)

Outline of this part (I) Part IV. Querying XML Documents. Querying XML Documents. Outline of this part (II) Outline of this part (I) Part IV Querying XML Documents Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2007/08 164 8 XPath Navigational access to XML documents Overview Context Location steps Navigation

More information

Big Data for Engineers Spring Data Models

Big Data for Engineers Spring Data Models Ghislain Fourny Big Data for Engineers Spring 2018 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special

More information

Introduction to XQuery and XML Databases

Introduction to XQuery and XML Databases Introduction to XQuery and XML Databases TEI@Oxford July 2009 XQuery While XSLT is good for transforming XML to other formats (XML, HTML, PDF, Text, etc.) sometimes you may wish to query a large database

More information

Course: The XPath Language

Course: The XPath Language 1 / 30 Course: The XPath Language Pierre Genevès CNRS University of Grenoble Alpes, 2017 2018 2 / 30 Why XPath? Search, selection and extraction of information from XML documents are essential for any

More information

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28 XPath Lecture 36 Robb T. Koether Hampden-Sydney College Wed, Apr 16, 2014 Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, 2014 1 / 28 1 XPath 2 Executing XPath Expressions 3 XPath Expressions

More information

Part X. XQuery Querying XML Documents

Part X. XQuery Querying XML Documents Part X XQuery Querying XML Documents Torsten Grust (WSI) Database-Supported XML Processors Winter 2012/13 238 Outline of this part 1 XQuery Declarative querying over XML documents Introduction Preliminaries

More information

Part X. XQuery Querying XML Documents. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 246

Part X. XQuery Querying XML Documents. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 246 Part X XQuery Querying XML Documents Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 246 Outline of this part 1 XQuery Declarative querying over XML documents Introduction Preliminaries

More information

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while 1 One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while leaving the engine to choose the best way of fulfilling

More information

Semi-structured Data. 8 - XPath

Semi-structured Data. 8 - XPath Semi-structured Data 8 - XPath Andreas Pieris and Wolfgang Fischl, Summer Term 2016 Outline XPath Terminology XPath at First Glance Location Paths (Axis, Node Test, Predicate) Abbreviated Syntax What is

More information

The XQuery Data Model

The XQuery Data Model The XQuery Data Model 9. XQuery Data Model XQuery Type System Like for any other database query language, before we talk about the operators of the language, we have to specify exactly what it is that

More information

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model.

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model. Semi-structured data (SSD) XML Semistructured data XML, DTD, (XMLSchema) XPath, XQuery More flexible data model than the relational model. Think of an object structure, but with the type of each object

More information

Information Systems. XQuery. Nikolaj Popov

Information Systems. XQuery. Nikolaj Popov Information Systems XQuery Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at What Is XQuery The purpose of XQuery is to provide

More information

DBS2: Exkursus XQuery and XML-Databases. Jan Sievers Jens Hündling Lars Trieloff

DBS2: Exkursus XQuery and XML-Databases. Jan Sievers Jens Hündling Lars Trieloff DBS2: Exkursus XQuery and XML-Databases Jan Sievers Jens Hündling Lars Trieloff Motivation XML ubiquitous data exchange format Can be used to present Object data, relational data, semi-structured data

More information

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views 1. (4 points) Of the following statements, identify all that hold about architecture. A. DoDAF specifies a number of views to capture different aspects of a system being modeled Solution: A is true: B.

More information

Information Systems (Informationssysteme)

Information Systems (Informationssysteme) Information Systems (Informationssysteme) Jens Teubner, TU Dortmund jens.teubner@cs.tu-dortmund.de Summer 2013 c Jens Teubner Information Systems Summer 2013 1 Part IX XML Processing c Jens Teubner Information

More information

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Part VII Querying XML The XQuery Data Model Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Outline of this part 1 Querying XML Documents Overview 2 The XQuery Data Model The XQuery

More information

XQuery Expressions to AST Conversion

XQuery Expressions to AST Conversion XQuery essions to Conversion Warren Wong Chavdar Botev Feng Shao January, 2004 Copyright (C) 2003-2005 Cornell University. All Rights Reserved. Table of Contents IntegerLiteral... 4 Grammar ession... 4...

More information

Author: Irena Holubová Lecturer: Martin Svoboda

Author: Irena Holubová Lecturer: Martin Svoboda A7B36XML, AD7B36XML XML Technologies Lecture 4 XPath, SQL/XML 24. 3. 2017 Author: Irena Holubová Lecturer: Martin Svoboda http://www.ksi.mff.cuni.cz/~svoboda/courses/2016-2-a7b36xml/ Lecture Outline XPath

More information

Notes on XML and XQuery in Relational Databases

Notes on XML and XQuery in Relational Databases xquery.txt Tue Apr 04 11:29:26 2017 1 Notes on XML and XQuery in Relational Databases Owen Kaser March 22, 2016. Updated April 4, 2017 some code frags are untested! As usual, the idea is to give you a

More information

Informatics 1: Data & Analysis

Informatics 1: Data & Analysis T O Y H Informatics 1: Data & Analysis Lecture 11: Navigating XML using XPath Ian Stark School of Informatics The University of Edinburgh Tuesday 26 February 2013 Semester 2 Week 6 E H U N I V E R S I

More information

Navigation. 3.1 Introduction. 3.2 Paths

Navigation. 3.1 Introduction. 3.2 Paths 03Brundage_ch03.qxd 1/8/04 1:09 PM Page 63 C H A P T E R 3 Navigation 3.1 Introduction Once you ve constructed or loaded XML in a query, you need a way to navigate over that hierarchical data. In many

More information

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012 XPath Lecture 34 Robb T. Koether Hampden-Sydney College Wed, Apr 11, 2012 Robb T. Koether (Hampden-Sydney College) XPathLecture 34 Wed, Apr 11, 2012 1 / 20 1 XPath Functions 2 Predicates 3 Axes Robb T.

More information

Documentation for Quark xquery_model and related libraries Pet-Chean Ang and Anand Bhaskar 30 th May 2005

Documentation for Quark xquery_model and related libraries Pet-Chean Ang and Anand Bhaskar 30 th May 2005 Documentation for Quark xquery_model and related libraries Pet-Chean Ang and Anand Bhaskar 30 th May 2005 Copyright (C) 2003-2005 Cornell University. All Rights Reserved. This documentation describes the

More information

XML & Databases. Tutorial. 3. XPath Queries. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl

XML & Databases. Tutorial. 3. XPath Queries. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl XML & Databases Tutorial Christian Grün, Database & Information Systems Group University of, Winter 2007/08 XPath Introduction navigational access to XML documents sub-language in XQuery, XSLT, or XPointer

More information

A Modular modular XQuery implementation

A Modular modular XQuery implementation A Modular modular XQuery implementation Implementation Jan Vraný, Jan Jan Vraný, Jan Žák Žák Department of Computer Science and Engineering, FEE, Czech Technical University Department of Computer in Prague,

More information

Query Languages for XML

Query Languages for XML Query Languages for XML XPath XQuery 1 The XPath/XQuery Data Model Corresponding to the fundamental relation of the relational model is: sequence of items. An item is either: 1. A primitive value, e.g.,

More information

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects Table of Contents Chapter 1 - Introduction 1.1 Anatomy of an XML Document 1.2 Differences Between XML and Relational Data 1.3 Overview of DB2 purexml 1.4 Benefits of DB2 purexml over Alternative Storage

More information

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax Scheme Tutorial Introduction Scheme is an imperative language with a functional core. The functional core is based on the lambda calculus. In this chapter only the functional core and some simple I/O is

More information

Overview: XQuery 3.0

Overview: XQuery 3.0 XQuery 3.0 Overview: XQuery 3.0 Fix shortcomings of XQuery 1.0, not a radical change Better align XPath 3.0, XSLT 3.0, XQuery 3.0 (thus the version!) Properly incorporate some of the best ideas from other

More information

Big Data Fall Data Models

Big Data Fall Data Models Ghislain Fourny Big Data Fall 2018 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special Relativity"

More information

Big Data 11. Data Models

Big Data 11. Data Models Ghislain Fourny Big Data 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special Relativity" 2,Gödel,Kurt,"""Incompleteness""

More information

XQuery 1.0: An XML Query Language

XQuery 1.0: An XML Query Language XQuery 1.0: An XML Query Language W3C Recommendation 23 January 2007 This version: Latest version: http://www.w3.org/tr/2007/rec-xquery-20070123/ http://www.w3.org/tr/xquery/ Previous version: http://www.w3.org/tr/2006/pr-xquery-20061121/

More information

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath COSC 304 Introduction to Database Systems XML Querying Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Querying XML We will look at two standard query languages: XPath

More information

Control Structures. CIS 118 Intro to LINUX

Control Structures. CIS 118 Intro to LINUX Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true

More information

2006 Martin v. Löwis. Data-centric XML. XPath

2006 Martin v. Löwis. Data-centric XML. XPath Data-centric XML XPath XPath Overview Non-XML language for identifying particular parts of XML documents First person element of a document Seventh child element of third person element ID attribute of

More information

XPath Expression Syntax

XPath Expression Syntax XPath Expression Syntax SAXON home page Contents Introduction Constants Variable References Parentheses and operator precedence String Expressions Boolean Expressions Numeric Expressions NodeSet expressions

More information

XML Data Management. 5. Extracting Data from XML: XPath

XML Data Management. 5. Extracting Data from XML: XPath XML Data Management 5. Extracting Data from XML: XPath Werner Nutt based on slides by Sara Cohen, Jerusalem 1 Extracting Data from XML Data stored in an XML document must be extracted to use it with various

More information

XQuery. Announcements (March 21) XQuery. CPS 216 Advanced Database Systems

XQuery. Announcements (March 21) XQuery. CPS 216 Advanced Database Systems XQuery CPS 216 Advanced Database Systems Announcements (March 21) 2 Midterm has been graded Homework #3 will be assigned next Tuesday Reading assignment due next Wednesday XML processing in Lore (VLDB

More information

A Light but Formal Introduction to XQuery

A Light but Formal Introduction to XQuery A Light but Formal Introduction to XQuery Jan Hidders, Jan Paredaens, Roel Vercammen, and Serge Demeyer University of Antwerp, Middelheimlaan 1, BE-2020 Antwerp, Belgium {jan.hidders,jan.paredaens,roel.vercammen,serge.demeyer}@ua.ac.be

More information

Table of Contents. Preface... xvii

Table of Contents. Preface... xvii Table of Contents Preface...................................................................... xvii 1. Introduction to XQuery....................................................... 1 What Is XQuery? 1

More information

JSON & MongoDB. Introduction to Databases CompSci 316 Fall 2018

JSON & MongoDB. Introduction to Databases CompSci 316 Fall 2018 JSON & MongoDB Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue. Oct. 30) Homework #3 due next Tuesday Project milestone #2 due next Thursday See email about new requirement on weekly

More information

User s Guide for BDDs in Jython

User s Guide for BDDs in Jython User s Guide for BDDs in Jython Mark Greenstreet, January 29, 2013 1 Overview I ll add something here about downloading the package, running it on UBC CS department machines, etc. 2 Class SymBool Class

More information

YFilter: an XML Stream Filtering Engine. Weiwei SUN University of Konstanz

YFilter: an XML Stream Filtering Engine. Weiwei SUN University of Konstanz YFilter: an XML Stream Filtering Engine Weiwei SUN University of Konstanz 1 Introduction Data exchange between applications: use XML Messages processed by an XML Message Broker Examples Publish/subscribe

More information

XML Data Management. 6. XPath 1.0 Principles. Werner Nutt

XML Data Management. 6. XPath 1.0 Principles. Werner Nutt XML Data Management 6. XPath 1.0 Principles Werner Nutt 1 XPath Expressions and the XPath Document Model XPath expressions are evaluated over documents XPath operates on an abstract document structure

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that

More information

Computer Science E-259

Computer Science E-259 Computer Science E-259 XML with Java Lecture 4: XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0) 21 February 2007 David J. Malan malan@post.harvard.edu 1 Computer Science E-259 Last Time DOM Level 3 JAXP 1.3

More information

Chapter 8 XQuery. Recent Developments for Data Models

Chapter 8 XQuery. Recent Developments for Data Models Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 8 XQuery Recent Developments for Data Models Outline Overview

More information

Querying XML Documents. Organization of Presentation

Querying XML Documents. Organization of Presentation Querying XML Documents Paul Cotton, Microsoft Canada University of Waterloo Feb 1, 2002 1 Organization of Presentation XML query history XML Query WG history, goals and status XML Query working drafts

More information

XML Path Language (XPath)

XML Path Language (XPath) 2.0 W3C Recommendation 23 January 2007 This version: Latest version: http://www.w3.org/tr/2007/rec-xpath20-20070123/ http://www.w3.org/tr/xpath20/ Previous version: http://www.w3.org/tr/2006/pr-xpath20-20061121/

More information

XPath. Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 21

XPath. Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 21 1 / 21 XPath Mario Alviano University of Calabria, Italy A.Y. 2017/2018 Outline 2 / 21 1 Introduction 2 XPath expressions Path expressions Value expressions Node set expressions 3 Examples 4 Exercises

More information

XQuery Update. An Update Copyright 2008, Oracle Corp. 1

XQuery Update. An Update Copyright 2008, Oracle Corp. 1 XQuery Update An Update 2008-05-07 Copyright 2008, Oracle Corp. 1 Your Humble Presenter Editor, all part of SQL standard, > 20 years Co-Chair W3C XML Query WG [Co-]Editor of ½-dozen XQuery-related docs

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Title:[ Variables Comparison Operators If Else Statements ]

Title:[ Variables Comparison Operators If Else Statements ] [Color Codes] Environmental Variables: PATH What is path? PATH=$PATH:/MyFolder/YourStuff?Scripts ENV HOME PWD SHELL PS1 EDITOR Showing default text editor #!/bin/bash a=375 hello=$a #No space permitted

More information

Transcript of Abel Braaksma's Talk on XSLT Streaming at XML Prague 2014

Transcript of Abel Braaksma's Talk on XSLT Streaming at XML Prague 2014 Transcript of Abel Braaksma's Talk on XSLT Streaming at XML Prague 2014 The video of Abel's talk is here: http://www.youtube.com/watch?v=kaupzeew4xg&t=318m25s Abel's slides are here: http://exselt.net/portals/1/streaming%20for%20the%20masses.zip

More information

Navigating an XML Document

Navigating an XML Document University of Dublin Trinity College Navigating an XML Document Owen.Conlan@scss.tcd.ie Athanasios.Staikopoulos@scss.tcd.ie What is XPath? Language for addressing parts of an XML document Used in XSLT,

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Informatics 1: Data & Analysis

Informatics 1: Data & Analysis Informatics 1: Data & Analysis Lecture 11: Navigating XML using XPath Ian Stark School of Informatics The University of Edinburgh Tuesday 23 February 2016 Semester 2 Week 6 http://blog.inf.ed.ac.uk/da16

More information

XML Databases 6. XML Query Languages II

XML Databases 6. XML Query Languages II XML Databases 6. XML Query Languages II Silke Eckstein Andreas Kupfer Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de 6. XML Query Languages II 6.1 Introduction

More information

XML: Extensible Markup Language

XML: Extensible Markup Language XML: Extensible Markup Language CSC 375, Fall 2015 XML is a classic political compromise: it balances the needs of man and machine by being equally unreadable to both. Matthew Might Slides slightly modified

More information

Part XII. Mapping XML to Databases. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321

Part XII. Mapping XML to Databases. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321 Part XII Mapping XML to Databases Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321 Outline of this part 1 Mapping XML to Databases Introduction 2 Relational Tree Encoding Dead Ends

More information

Index-Driven XQuery Processing in the exist XML Database

Index-Driven XQuery Processing in the exist XML Database Index-Driven XQuery Processing in the exist XML Database Wolfgang Meier wolfgang@exist-db.org The exist Project XML Prague, June 17, 2006 Outline 1 Introducing exist 2 Node Identification Schemes and Indexing

More information

Chapter 1: Semistructured Data Management XML

Chapter 1: Semistructured Data Management XML Chapter 1: Semistructured Data Management XML XML - 1 The Web has generated a new class of data models, which are generally summarized under the notion semi-structured data models. The reasons for that

More information

XPath Basics. Mikael Fernandus Simalango

XPath Basics. Mikael Fernandus Simalango XPath Basics Mikael Fernandus Simalango Agenda XML Overview XPath Basics XPath Sample Project XML Overview extensible Markup Language Constituted by elements identified by tags and attributes within Elements

More information

Marker s feedback version

Marker s feedback version Two hours Special instructions: This paper will be taken on-line and this is the paper format which will be available as a back-up UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE Semi-structured Data

More information

FOXpath - an expression language for selecting files and folders

FOXpath - an expression language for selecting files and folders Link to the Balisage Proceedings Home Page at http://www.balisage.net/proceedings Link to this paper (entry page with links) at http://www.balisage.net/proceedings/vol17/html/rennau01/balisagevol17-rennau01.html

More information

BEAWebLogic. Integration. Transforming Data Using XQuery Mapper

BEAWebLogic. Integration. Transforming Data Using XQuery Mapper BEAWebLogic Integration Transforming Data Using XQuery Mapper Version: 10.2 Document Revised: March 2008 Contents Introduction Overview of XQuery Mapper.............................................. 1-1

More information

Part X. XQuery Querying XML Documents. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 248

Part X. XQuery Querying XML Documents. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 248 Part X XQuery Querying XML Documents Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 248 Outline of this part 26 XQuery Declarative querying over XML documents Introduction Preliminaries

More information

CS109A ML Notes for the Week of 1/16/96. Using ML. ML can be used as an interactive language. We. shall use a version running under UNIX, called

CS109A ML Notes for the Week of 1/16/96. Using ML. ML can be used as an interactive language. We. shall use a version running under UNIX, called CS109A ML Notes for the Week of 1/16/96 Using ML ML can be used as an interactive language. We shall use a version running under UNIX, called SML/NJ or \Standard ML of New Jersey." You can get SML/NJ by

More information

Semantic Characterizations of XPath

Semantic Characterizations of XPath Semantic Characterizations of XPath Maarten Marx Informatics Institute, University of Amsterdam, The Netherlands CWI, April, 2004 1 Overview Navigational XPath is a language to specify sets and paths in

More information

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators ARITHMATIC OPERATORS The assignment operator in IDL is the equals sign, =. IDL uses all the familiar arithmetic operators

More information

Chapter 1: Semistructured Data Management XML

Chapter 1: Semistructured Data Management XML Chapter 1: Semistructured Data Management XML 2006/7, Karl Aberer, EPFL-IC, Laboratoire de systèmes d'informations répartis XML - 1 The Web has generated a new class of data models, which are generally

More information

Language Specification 0.4 JSONiq

Language Specification 0.4 JSONiq Language Specification 0.4 JSONiq XQuery for JSON, JSON for XQuery Jonathan Robie Ghislain Fourny Matthias Brantner Daniela Florescu Till Westmann Markos Zaharioudakis JSONiq Language Specification 0.4

More information

XPath and XSLT. Overview. Context. Context The Basics of XPath. XPath and XSLT. Nodes Axes Expressions. Stylesheet templates Transformations

XPath and XSLT. Overview. Context. Context The Basics of XPath. XPath and XSLT. Nodes Axes Expressions. Stylesheet templates Transformations XPath and XSLT Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Context The Basics of XPath Nodes

More information

XML and Semantic Web Technologies. II. XML / 6. XML Query Language (XQuery)

XML and Semantic Web Technologies. II. XML / 6. XML Query Language (XQuery) XML and Semantic Web Technologies XML and Semantic Web Technologies II. XML / 6. XML Query Language (XQuery) Prof. Dr. Dr. Lars Schmidt-Thieme Information Systems and Machine Learning Lab (ISMLL) Institute

More information

Example using multiple predicates

Example using multiple predicates XPath Example using multiple predicates //performance[conductor][date] L C C C C p c s p p s o t d p p c p p Peter Wood (BBK) XML Data Management 162 / 366 XPath Further examples with predicates //performance[composer='frederic

More information

11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT

11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT Functional programming FP Foundations, Scheme (2 In Text: Chapter 15 LISP: John McCarthy 1958 MIT List Processing => Symbolic Manipulation First functional programming language Every version after the

More information

XML and Databases. Lecture 10 XPath Evaluation using RDBMS. Sebastian Maneth NICTA and UNSW

XML and Databases. Lecture 10 XPath Evaluation using RDBMS. Sebastian Maneth NICTA and UNSW XML and Databases Lecture 10 XPath Evaluation using RDBMS Sebastian Maneth NICTA and UNSW CSE@UNSW -- Semester 1, 2009 Outline 1. Recall pre / post encoding 2. XPath with //, ancestor, @, and text() 3.

More information

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

Variable Scope The Main() Function Struct Functions Overloading Functions Using Delegates Chapter 7: Debugging and Error Handling Debugging in Visual

Variable Scope The Main() Function Struct Functions Overloading Functions Using Delegates Chapter 7: Debugging and Error Handling Debugging in Visual Table of Contents Title Page Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Source Code Errata p2p.wrox.com Part I: The OOP

More information