@@ -66,10 +66,10 @@ declare function local:search-element($element as xs:string?, $q as xs:string*,
6666 for $c in tokenize ($collection,',' )
6767 return data:apiSearch ($c, $e, $q, ())
6868 else data:apiSearch ($collection, $e, $q, ())
69- let $hits := if ($local:limit) then
69+ let $hits := if (exists ( $local:limit) ) then
7070 for $hit in $hits
7171 let $id := replace ($hit/ancestor-or-self::tei:TEI/descendant::tei:publicationStmt/tei:idno[@type ='URI' ][1 ],'/tei' ,'' )
72- where contains ($id, $limit)
72+ where contains ($id, $local: limit)
7373 return $hit
7474 else $hits
7575 return
@@ -163,7 +163,7 @@ declare function local:search-element($element as xs:string?, $q as xs:string*,
163163 {attribute { "ref" } { $recID }, concat ($type,$headword[1 ]) }
164164 </passive>
165165 else ()
166- else if ($local:wrap-element) then
166+ else if (exists ( $local:wrap-element) ) then
167167 if (local-name-from-QName ($local:wrap-element) = ('author' , 'relation' )) then
168168 element { $local:wrap-element } {
169169 attribute { "ref" } { $recID },
@@ -237,15 +237,15 @@ let $data :=
237237 if ($path) then
238238 data:get-document ()
239239 else if (exists (request:get-parameter-names ())) then
240- if ($local:api) then
241- if (exists ($local:element) and exist ($local:q)) then
240+ if (exists ( $local:api) ) then
241+ if (exists ($local:element) and exists ($local:q)) then
242242 local:search-element ($local:element, $local:q, $local:collection)
243- else if ($local:geo) then
243+ else if (exists ( $local:geo) ) then
244244 local:coordinates ($local:type, $local:collection)
245245 else <div>Nothing, check params: {request:get-parameter-names ()}</div>
246246 else
247247 let $collectionParam :=
248- if ($local:exist-collection) then
248+ if (exists ( $local:exist-collection) ) then
249249 tokenize (replace ($local:exist-collection, '/tei' , '' ), '/' )[last ()]
250250 else ()
251251let $collection := $collectionParam
@@ -336,13 +336,13 @@ let $collection := $collectionParam
336336 else ()
337337return
338338 if (not (empty ($data))) then
339- if ($local:api) then
340- if ($local:geo) then
339+ if (exists ( $local:api) ) then
340+ if (exists ( $local:geo) ) then
341341 if ($local:format = 'kml' ) then
342342 cntneg:content-negotiation ($data,'kml' ,())
343343 else cntneg:content-negotiation ($data,'geojson' ,())
344344 else
345- let $format := if ($local:format eq 'xml' then 'xml' else 'json'
345+ let $format := if ($local:format = 'xml' ) then 'xml' else 'json'
346346 return cntneg:content-negotiation ($data, $format, ())
347- else cntneg:content-negotiation ($data, $format, $path)
347+ else cntneg:content-negotiation ($data, $local: format, $path)
348348 else ()
0 commit comments