Commit e27376cf authored by Mathias Goebel's avatar Mathias Goebel 🎠 Committed by mrodzis
Browse files

closes #117

seems that eXist behavior changed, empty string != empty - thats for
sure.
parent 765be049
......@@ -20,8 +20,6 @@ import module namespace config="http://textgrid.de/ns/SADE/config" at "../config
import module namespace ixp="http://fontane-nb.dariah.eu/index-processor" at "index-processor.xqm";
import module namespace rest="http://exquery.org/ns/restxq";
declare variable $index:dataPath := "/db/sade-projects/textgrid/data/xml/data";
(:~
: resolves and lists all references on a given page based on their index data
:
......@@ -58,14 +56,14 @@ declare
function index:entites-per-page($uri as xs:string, $surface as xs:string)
as element(xhtml:ul)* {
let $docpath := $index:dataPath || "/" || $uri || ".xml"
let $docpath := $ixp:dataPath || $uri || ".xml"
let $surface := tokenize($surface, "-")
(: test for document available :)
return
if(not(doc-available($docpath)))
then
let $docsInDb := collection($index:dataPath)//tei:sourceDoc
let $docsInDb := $ixp:dataCollection//tei:sourceDoc
/replace(base-uri(), "\.xml|/|db|sade-projects|textgrid|data|xml", "")
=> string-join(", ")
return
......@@ -101,7 +99,7 @@ return
element xhtml:ul {
for $entity in $entities[substring-before(., ":") = $group]
let $ref := substring-after($entity, ":")
let $index := (collection($index:dataPath)/id($ref))[1]
let $index := ($ixp:dataCollection/id($ref))[1]
let $name := string($index/*[1])
let $list := index:get-list-by-id($ref)
let $href := "register.html?e=" || $ref
......@@ -159,7 +157,7 @@ declare
function index:get-list-by-id($id as xs:string)
as xs:string {
let $entity := collection($index:dataPath)/id($id)[ not(. instance of element(tei:handNote) ) ]
let $entity := $ixp:dataCollection/id($id)[ not(. instance of element(tei:handNote) ) ]
let $test := if($entity[2]) then error(QName("FONTANE", "INDEX-API3"), "Entity »" || $id || "« has more then one occurence." ) else ()
return
switch ( $entity/local-name() )
......@@ -214,7 +212,7 @@ declare
%test:assertTrue
function index:rendered-entity($id as xs:string)
as item()* {
let $node := collection($index:dataPath)/id($id)
let $node := $ixp:dataCollection/id($id)
let $type := $node/root()//tei:body/*[1]/local-name()
(: listEvent, listPlace, listOrg, listPerson or list :)
return
......@@ -252,6 +250,7 @@ declare
%test:name("simple search")
%test:arg("query", "Dom Karlos")
%test:arg("index", "listEvent,listOrg,listPerson,listPlace,list-works,list-Fontane,list-periodicals")
%test:assertXPath("array:size($result) = 2")
function index:search($query as xs:string, $index)
......@@ -261,12 +260,12 @@ return if(string-length($query) lt 2) then () else
let $prepare := tokenize($index, ",")
let $hits :=
(
collection($index:dataPath)//tei:person[contains(tei:persName, $query)],
collection($index:dataPath)//tei:personGrp[contains(tei:persName, $query)],
collection($index:dataPath)//tei:place[contains(tei:placeName, $query)],
collection($index:dataPath)//tei:org[contains(tei:orgName, $query)],
collection($index:dataPath)//tei:event[contains(tei:label, $query)],
collection($index:dataPath)//tei:item[tei:name/contains(., $query) = true()]
$ixp:dataCollection//tei:person[contains(tei:persName, $query)],
$ixp:dataCollection//tei:personGrp[contains(tei:persName, $query)],
$ixp:dataCollection//tei:place[contains(tei:placeName, $query)],
$ixp:dataCollection//tei:org[contains(tei:orgName, $query)],
$ixp:dataCollection//tei:event[contains(tei:label, $query)],
$ixp:dataCollection//tei:item[tei:name/contains(., $query) = true()]
)
return
array{
......@@ -300,9 +299,9 @@ declare
%test:arg("id", "Arnoldi-Denkmal")
%test:arg("type", "plc")
%test:assertTrue
%test:assertXPath("$result?1 => exists()")
function index:rendered-entity($type as xs:string, $id as xs:string)
as item()* {
as array(*) {
let $request :=
<hc:request
method="get"
......
......@@ -32,6 +32,7 @@ declare variable $ixp:notebookParam := try {request:get-parameter('nb', '')} cat
declare variable $ixp:getNotebook := $ixp:targetStart || $ixp:notebookParam;
declare variable $ixp:dataCollection := collection($config:data-root || "/data");
declare variable $ixp:dataPath := '/db/sade-projects/textgrid/data/xml/data/';
(:~
: Helper function to collect all main nodes from the index files.
......
......@@ -12,7 +12,7 @@ declare variable $f-misc:metadata-collection := collection("/db/sade-projects/t
declare
%test:arg("baseUri","textgrid:16b00") %test:assertEquals("Notizbuch C7")
%test:arg("baseUri","") %test:assertEquals("")
%test:arg("baseUri","") %test:assertEmpty
function f-misc:get-title-by-baseUri($baseUri as xs:string)
as xs:string? {
if($baseUri = "") then () else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment