-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshow.xqy
57 lines (48 loc) · 1.85 KB
/
show.xqy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
xquery version "1.0-ml";
(:
: Copyright (c) 2021 MarkLogic Corporation
:
: Licensed under the Apache License, Version 2.0 (the "License");
: you may not use this file except in compliance with the License.
: You may obtain a copy of the License at
:
: http://www.apache.org/licenses/LICENSE-2.0
:
: Unless required by applicable law or agreed to in writing, software
: distributed under the License is distributed on an "AS IS" BASIS,
: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
: See the License for the specific language governing permissions and
: limitations under the License.
:)
import module namespace qputils = "http://marklogic.com/optic/qputils" at "lib/qputils.xqy";
declare function local:makeHTML($out)
{
<html>
<head>
<script type="text/javascript" src="ui/lib/d3.v6.min.js"><!-- --></script>
<script type="text/javascript" src="ui/lib/d3-flextree.v2.min.js"><!-- --></script>
<script type="text/javascript" src="ui/qv.js"><!-- --></script>
<link rel="stylesheet" href="ui/css/style.css"><!-- --></link>
<script>
input = { xdmp:quote(json:to-array($out)), xdmp:log(json:to-array($out)) }
</script>
</head>
<body onload="qv_showPlan('#viewer', input);">
<div id="wrapper" class="full-height">
<div id="viewer">
<!-- -->
</div>
</div>
</body>
</html>
};
let $file := xdmp:get-request-field("filename")
let $plan := xdmp:get-request-field("plan")
let $in := if ($file) then xdmp:document-get($file)/*
else if ($plan) then xdmp:unquote (xdmp:get-request-field("plan"))/*
else fn:error(xs:QName("XDMP-ARG"), "Missing argument: filename or plan required")
return (
xdmp:set-response-content-type("text/html"),
let $out := qputils:makeGraph($in, "N")
return local:makeHTML($out)
)