Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify XQuery and XQuery modules format and indentation #349

Merged
merged 114 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 111 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
8efd7e0
Update search.xql
DennisFriedl May 31, 2023
9251f51
Update getZone.xql
DennisFriedl May 31, 2023
e15cfbe
Update getXml.xql
DennisFriedl May 31, 2023
3adb97a
fix syntax: getReducedDocument.xql
bwbohl Nov 8, 2023
2ba2451
fix position of variable declarations
bwbohl Nov 8, 2023
0004924
format and indent xql-files
bwbohl Nov 8, 2023
ee5ead6
add POSIX compliant file ending newline
bwbohl Nov 8, 2023
ad46d6a
format and indent
bwbohl Nov 8, 2023
373296d
Update checkTextGridLogin.xql
bwbohl Nov 9, 2023
2090f8e
Update edirom_printPreview.xql
bwbohl Nov 9, 2023
8a1157e
Update getAnnotation.xql
bwbohl Nov 9, 2023
5958a20
Update getAnnotation.xql
bwbohl Nov 9, 2023
9031dc7
Update getAnnotationInfos.xql
bwbohl Nov 9, 2023
006f9c6
Update CONTRIBUTING.md
bwbohl Jan 11, 2024
c211204
Update getAnnotationMeta.xql
bwbohl Jan 11, 2024
b2965ed
add structuring comments
bwbohl Jan 11, 2024
161003f
update Copyright comment
bwbohl Jan 11, 2024
a2ba68e
add structuring comments
bwbohl Jan 11, 2024
f863877
Update getAnnotationOpenAllUris.xql
bwbohl Jan 16, 2024
1a4be36
Update getAnnotationParticipants.xql
bwbohl Jan 16, 2024
6223f3a
Update getAnnotationPreviews.xql
bwbohl Feb 1, 2024
ad14a72
format and indent
bwbohl Feb 1, 2024
f1107b6
Update getAnnotationPreviews.xql
bwbohl Feb 2, 2024
c486044
Update getAnnotationPreviews.xql
bwbohl Feb 2, 2024
9faeada
Update getAnnotations.xql
bwbohl Feb 2, 2024
22053e5
Update getAnnotationsInRendering.xql
bwbohl Feb 2, 2024
63a844d
Update getAnnotationsInText.xql
bwbohl Feb 2, 2024
e84433b
Update getAnnotationsOnPage.xql
bwbohl Feb 2, 2024
662dc52
Update getAnnotationText.xql
bwbohl Feb 2, 2024
535346c
Update getAudioPlayer.xql
bwbohl Feb 2, 2024
612c0c6
Update CONTRIBUTING.md
bwbohl Feb 2, 2024
f69f710
Update getChapters.xql
bwbohl Feb 2, 2024
1713294
Update getConcordances.xql
bwbohl Feb 2, 2024
4bb96b3
Update getConcordances.xql
bwbohl Feb 2, 2024
7276be6
Update getEdition.xql
bwbohl Feb 2, 2024
434607a
Update getEditionURI.xql
bwbohl Feb 2, 2024
d73e8c5
Update getExtendedStaff.xql
bwbohl Feb 2, 2024
2229284
Update CONTRIBUTING.md
bwbohl Feb 2, 2024
12fd00b
Update getHeader.xql
bwbohl Feb 2, 2024
7d18339
Update getHeader.xql
bwbohl Feb 2, 2024
3ea9303
Update getHelp.xql
bwbohl Feb 2, 2024
58617d7
Update getiFrameURL.xql
bwbohl Feb 2, 2024
2b15ac5
Update getInternalIdType.xql
bwbohl Feb 2, 2024
64bac05
Update getLanguageFile.xql
bwbohl Feb 2, 2024
42f0c9e
Update getLinkTarget.xql
bwbohl Feb 2, 2024
7a1c4b8
Update getMeasure.xql
bwbohl Feb 4, 2024
1ea13e3
Update getMeasurePage.xql
bwbohl Feb 4, 2024
5504eb6
Update getMeasures.xql
bwbohl Feb 4, 2024
cc25dfe
Update getMeasuresOnPage.xql
bwbohl Feb 4, 2024
d3c3c5b
Update getMovements.xql
bwbohl Feb 4, 2024
eddb478
Update getMovementsFirstPage.xql
bwbohl Feb 4, 2024
94d34de
Update getMusicInMdiv.xql
bwbohl Feb 4, 2024
acd6211
Update getNavigatorConfig.xql
bwbohl Feb 4, 2024
620faaf
Update getOverlayOnPage.xql
bwbohl Feb 4, 2024
3f7af01
Update getOverlays.xql
bwbohl Feb 4, 2024
7a62550
Update getPages.xql
bwbohl Feb 4, 2024
c70f889
Update getParts.xql
bwbohl Feb 4, 2024
cd02498
Update getPreferences.xql
bwbohl Feb 5, 2024
cd5951e
Update getReducedDocument.xql
bwbohl Feb 5, 2024
b040e98
Update getRendering.xql
bwbohl Feb 5, 2024
5991f5c
Update getSummary.xql
bwbohl Feb 5, 2024
25b3e27
Update getText.xql
bwbohl Feb 5, 2024
bbbe6e9
Update getWorkID.xql
bwbohl Feb 5, 2024
96473b4
Update getWorks.xql
bwbohl Feb 5, 2024
ac075d8
Update getWorks.xql
bwbohl Feb 5, 2024
3fa4876
Update getXml.xql
bwbohl Feb 5, 2024
ace57d0
Update getZone.xql
bwbohl Feb 5, 2024
0a47835
Update loginToTextGrid.xql
bwbohl Feb 5, 2024
0f13066
Update search.xql
bwbohl Feb 5, 2024
13c84ae
Update annotation.xqm
bwbohl Feb 5, 2024
3689635
Update edition.xqm
bwbohl Feb 5, 2024
1217479
Update annotation.xqm
bwbohl Feb 5, 2024
e98c50b
Update source.xqm
bwbohl Feb 5, 2024
86f2421
Update teitext.xqm
bwbohl Feb 5, 2024
d0fa746
Update util.xqm
bwbohl Feb 5, 2024
5a43478
Update work.xqm
bwbohl Feb 5, 2024
7574caf
Merge branch 'develop' into ftr/xquery-style-conformant
bwbohl Feb 5, 2024
e6bb654
unfiy structuring comments
bwbohl Feb 5, 2024
8fa6a3a
Merge branch 'ftr/xquery-style-conformant' of https://github.com/Edir…
bwbohl Feb 5, 2024
69b35f4
Update CONTRIBUTING.md
bwbohl Feb 5, 2024
500d284
unify license beginning comment
bwbohl Feb 5, 2024
8fba42d
Update getAnnotationsInText.xql
bwbohl Feb 5, 2024
440895b
Merge branch 'ftr/xquery-style-conformant' into refactor/getXml
bwbohl Feb 5, 2024
bf39c25
Merge pull request #351 from Edirom/refactor/getXml
bwbohl Feb 5, 2024
873f79f
Merge branch 'ftr/xquery-style-conformant' into refactor/getZone
bwbohl Feb 5, 2024
8c3404a
Merge pull request #352 from Edirom/refactor/getZone
bwbohl Feb 5, 2024
6df9b5d
Merge branch 'ftr/xquery-style-conformant' into refactor/search
bwbohl Feb 5, 2024
3797252
Merge pull request #353 from Edirom/refactor/search
bwbohl Feb 5, 2024
a2ccf5c
Update add/data/xql/getEditionURI.xql
bwbohl Feb 7, 2024
897c164
Merge branch 'develop' into ftr/xquery-style-conformant
bwbohl Feb 7, 2024
09619a1
Update CONTRIBUTING.md
bwbohl Feb 13, 2024
c601e95
add missing structure-comment
bwbohl Feb 13, 2024
134e2e7
add some documentation
bwbohl Feb 13, 2024
ca7bd6f
fix order of FLOWR expression
bwbohl Feb 13, 2024
7ca98cb
Update getAnnotationPreviews.xql
bwbohl Feb 13, 2024
ec0ce02
Merge branch 'develop' into ftr/xquery-style-conformant
bwbohl Feb 14, 2024
306e236
Update source.xqm
bwbohl Feb 15, 2024
84d924f
Update source.xqm
bwbohl Feb 15, 2024
d3fb564
Merge branch 'develop' into ftr/xquery-style-conformant
bwbohl Feb 20, 2024
6efd943
Update add/data/xql/getAnnotationsInRendering.xql
bwbohl Feb 21, 2024
1ffcb20
Update getAnnotation.xql
bwbohl Feb 21, 2024
3c75f8e
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
8d37206
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
c3fdc72
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
c78e854
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
42a1a0f
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
f69564b
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
c40fd2c
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
bc26c52
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
dc2a07d
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
44b5118
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
0ac69d9
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
52d6a71
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
1ace4df
Update add/data/xql/getSummary.xql
bwbohl Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 138 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
1. Use whitespaces, not tabs to indent code
2. Close file with a newline character

# XQuery Styleguide

# XQuery
For formatting of XQuery files we generally rely on the basic configuration of Synchrosoft’s oXygen XML software family and its “Format & Indent” function.

## xqDoc

Expand All @@ -21,41 +22,158 @@ We use [xqDoc](https://xqdoc.org) for documenting the XQueries in this repositor

## XQuery document structure

### XQuery version
### XQuery version declaration

```xquery
xquery version 3.1;
```

### License Statement
### Beginning comments

For now, the beginning comments should only include the following:

```xquery
(:
For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
:)
: Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
:)
```
The beginning comments and the structuring comments (see below) of the prolog are separated by a blank line.

### Prolog

1. The parts of the prolog, are introduced by a comment followed by a new line.
2. The below form of the comments and the order of the parts is prescriptive.
3. Each part of the prolog ends with a blank line.

```xquery
(: IMPORTS ================================================================= :)
```

Sort imports by type:
1. All `import module namespace` statements registered with eXist-db
2. All `import module namespace` statements of custom modules that are not registered with eXist-db. Always use relative URIs for unregistered `import module namespace` statements.
3. Separate groups with a blank line.
4. In the groups sort alphabetically by prefix.

```xquery
(: NAMESPACE DECLARATIONS ================================================== :)
```

All `declare namespace` statements, sorted alphabetically by prefix.

```xquery
(: OPTION DECLARATIONS ===================================================== :)
```
All `declare option` statements.

```xquery
(: VARIABLE DECLARATIONS =================================================== :)
```
1. Use `declare variable` statements for all required external parameters
2. All global variable declarations, i.e. `declare variable` statements.
3. Separate these two groups with a blank line.
4. In the groups, sort alphabetically.

```xquery
(: FUNCTION DECLARATIONS =================================================== :)
```

### File Header
1. All `declare function` statements.
2. All function declarations have to be preceded by an xqDoc comment.
3. The xqDoc comment and function declaration belonging together are not separated by blank lines – not even one ;-)
4. The comment-function-groups are separated by blank lines.

1. `declare namespace` statements
* sort alphabetically by prefix
2. `import module namespace` statements of registered modules
* sort alphabetically by prefix
3. `import module namespace` statements of custom modules
* sort alphabetically by prefix
* Always use relative URIs for `import module namespace` statements that import for modules not registered with eXist-db.
A prototypical example:

### Declare variables
```xquery
(: FUNCTION DECLARATIONS =========================================== :)
(:~
:
:)
declare function eg:addComment($comment as xs:string, $function as function())
as xs:string
{
}
(:~
:)
declare function eg:addComment($comment as xs:string, $function as function())
as xs:string
{
}
```

### Query body

The Query body start after a structuring comment as follows:

```xquery
(: QUERY BODY ============================================================== :)
```

#### Strings

Note: this is derived from the current usage in Edirom-Online code

* escape with U+00027 APOSTROPHE: `'`

### Literal results

TODO: how should literal results be indented, especially when they are long, e.g., as in the case of [getAudioPlayer.xql](add/data/xql/getAudioPlayer.xql).

* Use `declare variable` statements for all required external parameters
### let statements

Short variable definitions should be in a single line:

```xquery
let $lang := 'de'
```

Longer assignments, especially when the contain if-else-statements or FLWOR-expressions, should break after `:=` and then indent a further level, before following the rules applicable to the respective statements, e.g.:

```xquery
let $elems :=
for $p in $participants
let $id := substring-after($p, '#')
return doc($doc)/id($id)
```

### Function declarations

* functions have to be preceded by an xqDoc comment
```xquery
(:~
: XQdoc comment
:
:
:)
declare function prefix:function-name( $paramOne as datatype, §paramTwo as datatype )
as datatype
{
};
```

- [ ] at the moment return datatypes and opening curly braces of function declarations are still in the same line as the `declare function` statement
- [ ] break long function argument

### XQuery body
### HowTo ToDo:s

* Strings: escape with U+00027 APOSTROPHE: `'`
- [ ] literal results formatting
- [ ] nested return statements
- [ ] parenthesis placement


# Javascript
Expand All @@ -77,7 +195,7 @@ An example of using the function would be:

```javascript
window.doAJAXRequest('data/xql/getAnnotationMeta.xql',
'GET',
'GET',
{
uri: uri,
lang: lang
Expand All @@ -87,3 +205,4 @@ window.doAJAXRequest('data/xql/getAnnotationMeta.xql',
}, this)
);
```

23 changes: 15 additions & 8 deletions add/data/xql/checkTextGridLogin.xql
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
xquery version "3.0";
xquery version "3.1";

declare namespace html="http://www.w3.org/1999/xhtml";
declare namespace h="http://exist-db.org/xquery/httpclient";
(:
: Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
:)

let $sessionId := request:get-parameter('sessionId', '')
(: IMPORTS ================================================================= :)

import module namespace httpclient = "http://exist-db.org/xquery/httpclient";

(: NAMESPACE DECLARATIONS ================================================== :)

let $test := httpclient:head(xs:anyURI('http://textgridlab.org/1.0/tgcrud/rest/textgrid:208dw/data?sessionId=' || $sessionId),
false(), ())
declare namespace html = "http://www.w3.org/1999/xhtml";

(: QUERY BODY ============================================================== :)

let $sessionId := request:get-parameter('sessionId', '')
let $test := httpclient:head(xs:anyURI('http://textgridlab.org/1.0/tgcrud/rest/textgrid:208dw/data?sessionId=' || $sessionId), false(), ())
let $status := $test/root()/httpclient:response/string(@statusCode)
let $status := response:set-status-code(xs:int($status))

return
$status
$status
Loading