1(: made up functions, etc just to test xquery parsing (: even embedded comments
2on multiple :)
3lines
4:)
5xquery version "1.0";
6
7module namespace xqueryexample "http://example.com/namespace";
8import module namespace importedns = "http://example.com/ns/imported" at "no/such/file.xqy";
9
10declare namespace sess = "com.example.session";
11
12declare variable $amazing := "awesome";
13declare variable $SESSIONS as element(sess:session)* := c:sessions();
14
15declare option sess:clear "false";
16
17define function whatsit($param as xs:string) as xs:string {
18	let $var1 := 1
19	let $var2 := 2
20	return (1 + 2 div ($var1 + $var2))
21
22	let $let := <x>"test"</x>
23	return (: some whitespace :) element element {
24			attribute attribute { 1 },
25				element test { 'a' },
26					attribute foo { "bar" },
27						fn:doc()[ foo/@bar eq $let ],
28                        //x/with/another/*/*:version/xpath/@attr }
29};
30
31let $bride := "Bride"
32let $test := validate lax { <some>html</some> }
33let $test := validate strict { <some>html</some> }
34let $test := validate { <some>html</some> }
35let $test := $var1/*:Article       (: comment here :) [fn:not()]
36let $test := $var1/@*:name/fn:string()
37
38let $noop := ordered { $test }
39let $noop := unordered { $test }
40
41let $noop :=
42	for $version at $i in $versions/version
43		let $row := if($i mod 2 eq 0) then "even" else "odd"
44		order by $version descending
45		return
46
47return
48<html xmlns="http://www.w3.org/1999/xhtml">
49{
50	<outer>
51	<movie>
52		<title>The Princess { fn:capitalize($bride) }</title>
53	</movie>
54	<form action="" method="post" id="session-form" call="callsomething()">
55      <input type="hidden" name="{$d:DEBUG-FIELD}" value="{$d:DEBUG}"/>
56      {
57				(: placeholder for local sessions :)
58				element div {
59					attribute id { "sessions-local" },
60					attribute class { "hidden" },
61					element h1 { "Local Sessions" },
62					element p {
63						'These sessions use storage provided by your browser.',
64						'You can also ',
65						element a {
66							attribute href { 'session-import-local.xqy' },
67							'import' },
68						' sessions from local XML files.'
69					}
70				}
71			}
72			{
73				for $i in $sessions
74				let $id := c:session-id($i)
75				let $uri := c:session-uri($i)
76				(: we only care about the lock that expires last :)
77				let $conflicting := c:conflicting-locks($uri, 1)
78				let $name as xs:string := ($i/sess:name, "(unnamed)")[1]
79				return element tr {
80					element td { $name },
81					element td { string($i/sec:user) },
82					element td { data($i/sess:created) },
83					element td { data($i/sess:last-modified) },
84					element td {
85						if (empty($conflicting)) then () else
86						text {
87							"by", $conflicting/lock:owner,
88							"until", adjust-dateTime-to-timezone(
89								x:epoch-seconds-to-dateTime(
90									$conflicting/lock:timestamp + $conflicting/lock:timeout
91								)
92							)
93						},
94						(: only show resume button if there are no conflicting locks :)
95						element input {
96							attribute type { "button" },
97							attribute title {
98								data($i/sess:query-buffers/sess:query[1]) },
99							attribute onclick {
100								concat("list.resumeSession('", $id, "')") },
101							attribute value {
102								"Resume", (' ', $id)[ $d:DEBUG ] }
103						}[ not($conflicting) ],
104						$x:NBSP,
105						(: clone button :)
106						element input {
107							attribute type { "button" },
108							attribute title { "clone this session" },
109							attribute onclick {
110								concat("list.cloneSession('", $id, "', this)") },
111							attribute value { "Clone", (' ', $id)[ $d:DEBUG ] }
112						},
113						$x:NBSP,
114						(: export button :)
115						element input {
116							attribute type { "button" },
117							attribute title { "export this session" },
118							attribute onclick {
119								concat("list.exportServerSession('", $id, "', this)") },
120							attribute value { "Export", (' ', $id)[ $d:DEBUG ] }
121						},
122						$x:NBSP,
123						(: only show delete button if there are no conflicting locks :)
124						element input {
125							attribute type { "button" },
126							attribute title { "permanently delete this session" },
127							attribute onclick {
128								concat("list.deleteSession('", $id, "', this)") },
129							attribute value { "Delete", (' ', $id)[ $d:DEBUG ] }
130						}[ not($conflicting) ]
131					}
132				}
133			}
134	</form>
135	</outer>
136}
137  <tr><td><!-- some commented things-->&nbsp;</td></tr>
138</html>
139