Skip to content

Instantly share code, notes, and snippets.

@eedeebee
Created July 1, 2011 22:14
Show Gist options
  • Select an option

  • Save eedeebee/1059519 to your computer and use it in GitHub Desktop.

Select an option

Save eedeebee/1059519 to your computer and use it in GitHub Desktop.
XQuery Coding Guidelines: Rule 4
(: one line if/then/else :)
if ($condition) then $action else ()
(: multiple line if/then/else :)
if ($condition)
then xdmp:log("If we kept this on one line, it would be unreadable")
else xdmp:log("This is a very long action, don't want it to scroll")
(: chained if/then/else :)
if ($condition)
then xdmp:log("If we kept this on one line, it would be unreadable")
else
if ($condition2)
then xdmp:log("This is a very long action, don't want it to scroll")
else
for $i in (1,2,3)
return concat("line ",$i)
(: flwor :)
let $a := "alpha"
for $i in (1 to 50)
where $i mod 2 eq 1
return concat($a,$i)
(: flwor :)
let $a := "alpha"
for $i in (1 to 50)
let $x := $i mod 2
where $x eq 1
return concat($a,$i)
(: flowr with subordinate flwor :)
let $a := "alpha"
let $x :=
for $i in (1 to 50)
where $i mod 2 eq 1
return concat($a,$i)
return $x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment