From 934a66a6c782cc21784292e9e489f286ea313362 Mon Sep 17 00:00:00 2001 From: Mau Zsofia Abraham Date: Wed, 17 Jul 2024 13:32:20 +0200 Subject: [PATCH 1/3] Support specchars and remove yet another shawi reference --- vicav.xqm | 17 +++-------------- xslt/menu-json.xslt | 12 ++++++++++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/vicav.xqm b/vicav.xqm index 8283a1a..0198c82 100644 --- a/vicav.xqm +++ b/vicav.xqm @@ -147,7 +147,7 @@ function vicav:_project_config() { then collection('prerendered_json')//json update {insert node true as first into ./projectConfig, .//text()[contains(., '{{host_name}}')]!(replace value of node . with replace(., '{{host_name}}/{{path}}', $publicURI, 'q'))} - else vicav:project_config_json_as_xml($publicURI) update {insert node false as first into ./json/projectConfig} + else vicav:project_config_json_as_xml($publicURI) return serialize($jsonAsXML, map {"method": "json", "indent": "no"}) else let $renderedMenu := xslt:transform($config/menu, 'xslt/menu.xslt') return {$config}{$renderedMenu} @@ -1875,7 +1875,6 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, || '&queryselector=cqlrow&cql='||$query-parts||'&default_attr=word&attrs=wid&kwicleftctx=-1&kwicrightctx=0&refs=u.id,doc.id&pagesize=100000' , $_ := admin:write-log($request, 'INFO') - let $result := if ($noske_host) then http:send-request(, $request) @@ -1907,7 +1906,6 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, } }:) - let $consecutiveIds := [] (:let $docUandIds := map:merge():) let $hits := {if (not($result)) then '' else for $line in $result/json/Lines/_ @@ -1921,21 +1919,12 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, else if (count($line/Right/_) > 0) then $line/Right/_[1]/text() else "" let $u := collection('vicav_corpus') - /descendant::tei:TEI[./tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[@type="SHAWICorpusID"]/text() = $docId] + /descendant::tei:TEI[./tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno/text() = $docId] /tei:text/tei:body/tei:div/tei:annotationBlock/tei:u[@xml:id = $uId] return {$u}{$tokenId!{normalize-space(.)}}} (: , $_ := admin:write-log(serialize($hits), 'INFO') :) (: , $_ := file:write(file:resolve-path('hits.xml', file:base-dir()), $hits, map { "method": "xml"}) :) - - return if (matches($accept-header, '[+/]json')) - then - let $transformedOutput := xslt:transform($hits, 'xslt/corpus_search_result_json.xslt', map{ 'query': $query}) - return serialize($transformedOutput, map {"method": "json", "indent": "no"}) - else - let $out := vicav:transform($hits, $xslt, $print, map{ 'query': $query }) - return $out - - + return $hits }; diff --git a/xslt/menu-json.xslt b/xslt/menu-json.xslt index e2717c6..790c6a0 100644 --- a/xslt/menu-json.xslt +++ b/xslt/menu-json.xslt @@ -20,7 +20,7 @@ - + @@ -56,7 +56,15 @@ - + + + <_ type="object"> + + + + + + <_ type="object"> From 318ba275135de1522eaf05a30a03732c41c240ac Mon Sep 17 00:00:00 2001 From: Mau Zsofia Abraham Date: Wed, 17 Jul 2024 13:35:38 +0200 Subject: [PATCH 2/3] Support specchars and remove yet another shawi reference --- vicav.xqm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/vicav.xqm b/vicav.xqm index 0198c82..c75bb55 100644 --- a/vicav.xqm +++ b/vicav.xqm @@ -147,7 +147,7 @@ function vicav:_project_config() { then collection('prerendered_json')//json update {insert node true as first into ./projectConfig, .//text()[contains(., '{{host_name}}')]!(replace value of node . with replace(., '{{host_name}}/{{path}}', $publicURI, 'q'))} - else vicav:project_config_json_as_xml($publicURI) + else vicav:project_config_json_as_xml($publicURI) update {insert node false as first into ./json/projectConfig} return serialize($jsonAsXML, map {"method": "json", "indent": "no"}) else let $renderedMenu := xslt:transform($config/menu, 'xslt/menu.xslt') return {$config}{$renderedMenu} @@ -1875,6 +1875,7 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, || '&queryselector=cqlrow&cql='||$query-parts||'&default_attr=word&attrs=wid&kwicleftctx=-1&kwicrightctx=0&refs=u.id,doc.id&pagesize=100000' , $_ := admin:write-log($request, 'INFO') + let $result := if ($noske_host) then http:send-request(, $request) @@ -1906,6 +1907,7 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, } }:) + let $consecutiveIds := [] (:let $docUandIds := map:merge():) let $hits := {if (not($result)) then '' else for $line in $result/json/Lines/_ @@ -1924,7 +1926,16 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, return {$u}{$tokenId!{normalize-space(.)}}} (: , $_ := admin:write-log(serialize($hits), 'INFO') :) (: , $_ := file:write(file:resolve-path('hits.xml', file:base-dir()), $hits, map { "method": "xml"}) :) - return $hits + + return if (matches($accept-header, '[+/]json')) + then + let $transformedOutput := xslt:transform($hits, 'xslt/corpus_search_result_json.xslt', map{ 'query': $query}) + return serialize($transformedOutput, map {"method": "json", "indent": "no"}) + else + let $out := vicav:transform($hits, $xslt, $print, map{ 'query': $query }) + return $out + + }; From bf0524b6c692ac088098527531aaaecc97f1c0b3 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Wed, 17 Jul 2024 14:32:33 +0200 Subject: [PATCH 3/3] There can be other idno so select what ends in CorpusID --- vicav.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vicav.xqm b/vicav.xqm index c75bb55..ad8cce8 100644 --- a/vicav.xqm +++ b/vicav.xqm @@ -1921,7 +1921,7 @@ declare function vicav:_search_corpus($query as xs:string, $print as xs:string?, else if (count($line/Right/_) > 0) then $line/Right/_[1]/text() else "" let $u := collection('vicav_corpus') - /descendant::tei:TEI[./tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno/text() = $docId] + /descendant::tei:TEI[./tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[ends-with(@type, "CorpusID")]/text() = $docId] /tei:text/tei:body/tei:div/tei:annotationBlock/tei:u[@xml:id = $uId] return {$u}{$tokenId!{normalize-space(.)}}} (: , $_ := admin:write-log(serialize($hits), 'INFO') :)