Skip to content

Commit 5b52c19

Browse files
committed
chore: add reformatted code
1 parent 23652d2 commit 5b52c19

15 files changed

Lines changed: 1233 additions & 1467 deletions

src/content/xbow.xqm

Lines changed: 591 additions & 536 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
xquery version "3.1";
1+
xquery version '3.1';
22

3-
declare function local:add ($a, $b) { $a + $b };
3+
declare function local:add ($a, $b) {
4+
$a + $b
5+
};
46

57
declare function local:for-each-add ($s, $a) {
6-
for-each($s, local:add($a, ?))
8+
for-each($s, local:add($a, ?))
79
};
810

9-
(0 to 9)
10-
(: => (function ($a) { $a ! string(.) })():)
11-
=> string-join()
12-
=> (function ($a) { $a || "" })()
13-
=> string-to-codepoints()
14-
=> (function ($a) { $a ! (. + 1) })()
15-
=> sum()
16-
,
11+
(0 to 9)
12+
(: => (function ($a) { $a ! string(.) })() :)
13+
=> string-join()
14+
=> (function ($a) { $a || '' })()
15+
=> string-to-codepoints()
16+
=> (function ($a) { $a!(. + 1) })()
17+
=> sum(),
1718
(1 to 10)
18-
=> for-each(local:add(-1, ?))
19-
(: => for-each(string#1) :)
20-
=> string-join()
21-
=> concat("")
22-
=> string-to-codepoints()
23-
=> local:for-each-add(1)
24-
=> sum()
25-
,
19+
=> for-each(local:add(-1, ?))
20+
(: => for-each(string#1) :)
21+
=> string-join()
22+
=> concat('')
23+
=> string-to-codepoints()
24+
=> local:for-each-add(1)
25+
=> sum(),
2626
(
27-
(1 to 10)
28-
! (. - 1)
29-
(: ! string(.) :)
30-
=> string-join()
31-
=> concat("")
32-
=> string-to-codepoints()
33-
)
34-
! (. + 1)
35-
=> sum()
27+
(1 to 10)!(. - 1)
28+
(: asdfasdofas :)
29+
=> string-join()
30+
=> concat('')
31+
=> string-to-codepoints()
32+
)!(. + 1)
33+
=> sum()
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
xquery version "3.1";
1+
xquery version '3.1';
22

33
import module namespace xbow = 'http://line-o.de/xq/xbow';
44

5-
let $data :=
6-
<persons>
7-
<person posts="3" name="Berta" />
8-
<person posts="1" name="Anne" />
9-
<person posts="17" name="Jules" />
10-
<person posts="4" name="Carl" />
11-
<person posts="54" name="Maude" />
12-
<person posts="5" name="Diraj" />
13-
<person posts="6" name="Eero" />
14-
<person posts="70" name="Franka" />
15-
<person posts="8" name="Gustav" />
16-
<person posts="9" name="Horst" />
17-
<person posts="34" name="Klaus" />
18-
<person posts="9" name="Isabella" />
19-
<person posts="45" name="Laura" />
5+
let $data := <persons>
6+
<person name="Berta" posts="3" />
7+
<person name="Anne" posts="1" />
8+
<person name="Jules" posts="17" />
9+
<person name="Carl" posts="4" />
10+
<person name="Maude" posts="54" />
11+
<person name="Diraj" posts="5" />
12+
<person name="Eero" posts="6" />
13+
<person name="Franka" posts="70" />
14+
<person name="Gustav" posts="8" />
15+
<person name="Horst" posts="9" />
16+
<person name="Klaus" posts="34" />
17+
<person name="Isabella" posts="9" />
18+
<person name="Laura" posts="45" />
2019
</persons>
2120

22-
let $activity-rules := [ xbow:lt(5), xbow:lt(20), xbow:ge(20) ]
23-
let $activity-labels := [ 'inactive', 'active', 'hyperactive' ]
21+
let $activity-rules := [xbow:lt(5), xbow:lt(20), xbow:ge(20)]
22+
let $activity-labels := ['inactive', 'active', 'hyperactive']
2423
let $post-accessor := function ($i as element(person)) { xs:integer($i/@posts) }
2524

2625
return $data/person
27-
=> xbow:categorize($activity-rules, $post-accessor)
28-
=> xbow:label($activity-labels)
26+
=> xbow:categorize($activity-rules, $post-accessor)
27+
=> xbow:label($activity-labels)

src/examples/categorize.xq

Lines changed: 45 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,57 @@
1-
xquery version "3.1";
2-
1+
xquery version '3.1';
32

43
import module namespace xbow = 'http://line-o.de/xq/xbow';
54

6-
let $age-rules := [
7-
xbow:lt(10),
8-
xbow:lt(20),
9-
xbow:lt(30),
10-
xbow:lt(60),
11-
xbow:ge(60)
12-
]
5+
let $age-rules := [xbow:lt(10), xbow:lt(20), xbow:lt(30), xbow:lt(60), xbow:ge(60)]
136

14-
let $age-labels := [
15-
'minors',
16-
'youngsters',
17-
'twens',
18-
'adults',
19-
'seniors'
20-
]
7+
let $age-labels := ['minors', 'youngsters', 'twens', 'adults', 'seniors']
218

229
let $age-accessor := function ($i as map(*)) { $i?age }
2310

24-
let $activity-rules := [
25-
xbow:lt(5),
26-
xbow:lt(20),
27-
xbow:ge(20)
28-
]
11+
let $activity-rules := [xbow:lt(5), xbow:lt(20), xbow:ge(20)]
2912

30-
let $activity-labels := [
31-
'inactive',
32-
'active',
33-
'hyperactive'
34-
]
13+
let $activity-labels := ['inactive', 'active', 'hyperactive']
3514

3615
let $post-accessor := function ($i as element(person)) { xs:integer($i/@posts) }
3716

3817
return (
39-
xbow:categorize((1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 34, 45, 65), $age-rules),
40-
xbow:categorize((1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 34, 45, 65), $activity-rules),
41-
(1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 34, 45, 65)
42-
=> xbow:categorize($age-rules)
43-
=> xbow:label($age-labels)
44-
,
45-
(
46-
map { "age": 1, "name": "a" },
47-
map { "age": 3, "name": "b" },
48-
map { "age": 4, "name": "c" },
49-
map { "age": 5, "name": "d" },
50-
map { "age": 6, "name": "e" },
51-
map { "age": 7, "name": "f" },
52-
map { "age": 8, "name": "g" },
53-
map { "age": 9, "name": "h" },
54-
map { "age": 9, "name": "i" },
55-
map { "age": 17, "name": "j" },
56-
map { "age": 34, "name": "k" },
57-
map { "age": 45, "name": "l" },
58-
map { "age": 54, "name": "m" }
59-
)
60-
=> xbow:categorize($age-rules, $age-accessor)
61-
=> xbow:label($age-labels)
62-
,
63-
(
64-
<person posts="1" name="a" />,
65-
<person posts="3" name="b" />,
66-
<person posts="4" name="c" />,
67-
<person posts="5" name="d" />,
68-
<person posts="6" name="e" />,
69-
<person posts="7" name="f" />,
70-
<person posts="8" name="g" />,
71-
<person posts="9" name="h" />,
72-
<person posts="9" name="i" />,
73-
<person posts="17" name="j" />,
74-
<person posts="34" name="k" />,
75-
<person posts="45" name="l" />,
76-
<person posts="54" name="m" />
77-
)
78-
=> xbow:categorize($activity-rules, $post-accessor)
79-
=> xbow:label($activity-labels)
80-
)
18+
xbow:categorize((1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 34, 45, 65), $age-rules),
19+
xbow:categorize((1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 34, 45, 65), $activity-rules),
20+
(1, 3, 4, 5, 6, 7, 8, 9, 9, 0, 34, 45, 65)
21+
=> xbow:categorize($age-rules)
22+
=> xbow:label($age-labels),
23+
(
24+
map {'age': 1, 'name': 'a'},
25+
map {'age': 3, 'name': 'b'},
26+
map {'age': 4, 'name': 'c'},
27+
map {'age': 5, 'name': 'd'},
28+
map {'age': 6, 'name': 'e'},
29+
map {'age': 7, 'name': 'f'},
30+
map {'age': 8, 'name': 'g'},
31+
map {'age': 9, 'name': 'h'},
32+
map {'age': 9, 'name': 'i'},
33+
map {'age': 17, 'name': 'j'},
34+
map {'age': 34, 'name': 'k'},
35+
map {'age': 45, 'name': 'l'},
36+
map {'age': 54, 'name': 'm'}
37+
)
38+
=> xbow:categorize($age-rules, $age-accessor)
39+
=> xbow:label($age-labels),
40+
(
41+
<person name="a" posts="1" />,
42+
<person name="b" posts="3" />,
43+
<person name="c" posts="4" />,
44+
<person name="d" posts="5" />,
45+
<person name="e" posts="6" />,
46+
<person name="f" posts="7" />,
47+
<person name="g" posts="8" />,
48+
<person name="h" posts="9" />,
49+
<person name="i" posts="9" />,
50+
<person name="j" posts="17" />,
51+
<person name="k" posts="34" />,
52+
<person name="l" posts="45" />,
53+
<person name="m" posts="54" />
54+
)
55+
=> xbow:categorize($activity-rules, $post-accessor)
56+
=> xbow:label($activity-labels)
57+
)

src/examples/combine.xq

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
1-
xquery version "3.1";
2-
1+
xquery version '3.1';
32

43
import module namespace xbow = 'http://line-o.de/xq/xbow';
54

6-
declare
7-
function local:from-to ($from as xs:integer, $to as xs:integer) as xs:integer+ {
8-
($from to $to)
5+
declare function local:from-to ($from as xs:integer, $to as xs:integer) as xs:integer+ {
6+
($from to $to)
97
};
108

119
(
12-
xbow:combine((
13-
function ($n) { (1, $n) },
14-
local:from-to#2,
15-
sum#1,
16-
function ($n) { map { 'value': $n } }
17-
))(10),
18-
xbow:combine((
19-
local:from-to#2,
20-
sum#1,
21-
function ($n) { map { 'value': $n } }
22-
))((1, 10)),
23-
xbow:combine((
24-
sum#1,
25-
function ($n) { $n + 1 }
26-
))((2, 3)),
27-
xbow:combine((
28-
array:filter(?, function ($n) { $n > 0 }),
29-
xbow:to-sequence(?)
30-
))([1, 19, -1]),
31-
xbow:combine((
32-
sum#1,
33-
local:from-to(1, ?)
34-
))((1 to 10))
35-
)
10+
xbow:combine(
11+
(function ($n) { (1, $n) }, local:from-to#2, sum#1, function ($n) { map {'value': $n} })
12+
)(10),
13+
xbow:combine((local:from-to#2, sum#1, function ($n) { map {'value': $n} }))((1, 10)),
14+
xbow:combine((sum#1, function ($n) { $n + 1 }))((2, 3)),
15+
xbow:combine((array:filter(?, function ($n) { $n > 0 }), xbow:to-sequence(?)))([1, 19, -1]),
16+
xbow:combine((sum#1, local:from-to(1, ?)))((1 to 10))
17+
)
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
xquery version "3.1";
1+
xquery version '3.1';
22

33
declare function local:copy-collection-contents ($source, $target) {
4-
xmldb:get-child-resources($source)
5-
=> for-each(xmldb:copy-resource($source, ?, $target, ?))
6-
,
7-
xmldb:get-child-collections($source)
8-
=> for-each(concat($source, "/", ?))
9-
=> for-each(xmldb:copy-collection(?, $target))
4+
xmldb:get-child-resources($source) => for-each(xmldb:copy-resource($source, ?, $target, ?)),
5+
xmldb:get-child-collections($source)
6+
=> for-each(concat($source, '/', ?))
7+
=> for-each(xmldb:copy-collection(?, $target))
108
};
119

1210
declare function local:copy-collection-contents-and-check ($source, $target) as xs:boolean {
13-
xmldb:get-child-resources($source)
14-
=> fold-left(true(), function ($result, $next) {
15-
let $action := xmldb:copy-resource($source, $next, $target, $next)
16-
return $result and exists($action)
17-
})
18-
19-
and
20-
21-
xmldb:get-child-collections($source)
22-
=> for-each(concat($source, "/", ?))
23-
=> fold-left(true(), function ($result, $next) {
24-
let $action := xmldb:copy-collection($next, $target)
25-
return $result and exists($action)
26-
})
11+
xmldb:get-child-resources($source)
12+
=> fold-left(
13+
true(),
14+
function ($result, $next) {
15+
let $action := xmldb:copy-resource($source, $next, $target, $next)
16+
return $result and exists($action)
17+
}
18+
) and
19+
xmldb:get-child-collections($source)
20+
=> for-each(concat($source, '/', ?))
21+
=> fold-left(
22+
true(),
23+
function ($result, $next) {
24+
let $action := xmldb:copy-collection($next, $target)
25+
return $result and exists($action)
26+
}
27+
)
2728
};
2829

29-
if (local:copy-collection-contents-and-check("/db/a", "/db/b"))
30-
then "OK"
31-
else "FAIL"
32-
30+
if (local:copy-collection-contents-and-check('/db/a', '/db/b')) then
31+
'OK'
32+
else
33+
'FAIL',
3334
(: create /db/a :)
3435
(: create /db/a/a.xml :)
3536
(: create /db/a/aa :)
3637
(: create /db/a/aa/aa.xml :)
3738
(: create /db/a/ab :)
3839
(: create /db/a/ab/ab.xml :)
3940

40-
local:copy-collection-contents("/db/a", "/db/b")
41-
42-
(: check contents of b :)
41+
local:copy-collection-contents('/db/a', '/db/b')
42+
(: check contents of b :)

src/examples/dynamic-path.xq

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1-
xquery version "3.1";
2-
1+
xquery version '3.1';
32

43
import module namespace xbow = 'http://line-o.de/xq/xbow';
54

6-
7-
declare variable $xml :=
8-
<a b="c">
5+
declare variable $xml := <a b="c">
96
some
10-
<b d="3">text</b>
11-
</a>
12-
;
13-
7+
<b d="3">text</b></a>;
148

159
(
16-
$xml
17-
=> xbow:pluck('@b')
18-
=> data(),
19-
$xml
20-
=> xbow:pluck('b')
21-
=> xbow:pluck('@d')
22-
=> data(),
23-
$xml
24-
=> xbow:pluck('b/@d')
25-
=> string(),
26-
$xml
27-
=> xbow:pluck('./b/../b/@d')
28-
=> string()
29-
)
10+
$xml => xbow:pluck('@b') => data(),
11+
$xml => xbow:pluck('b') => xbow:pluck('@d') => data(),
12+
$xml => xbow:pluck('b/@d') => string(),
13+
$xml => xbow:pluck('./b/../b/@d') => string()
14+
)

0 commit comments

Comments
 (0)