Created
July 1, 2011 22:14
-
-
Save eedeebee/1059519 to your computer and use it in GitHub Desktop.
XQuery Coding Guidelines: Rule 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: one line if/then/else :) | |
| if ($condition) then $action else () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: flwor :) | |
| let $a := "alpha" | |
| for $i in (1 to 50) | |
| where $i mod 2 eq 1 | |
| return concat($a,$i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: flwor :) | |
| let $a := "alpha" | |
| for $i in (1 to 50) | |
| let $x := $i mod 2 | |
| where $x eq 1 | |
| return concat($a,$i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (: 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