From b89645a5cc7acd1eb5ccf4a9f16173b69335e324 Mon Sep 17 00:00:00 2001 From: Oleg Belyaev Date: Sun, 23 Mar 2025 14:25:15 +0300 Subject: [PATCH] fix search paging --- xq/restx_dict_cached.xq | 9 ++++----- xq/test.xq | 20 ++++++++++++++++---- xsl/standardize.xsl | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/xq/restx_dict_cached.xq b/xq/restx_dict_cached.xq index 24a5b79..041d990 100644 --- a/xq/restx_dict_cached.xq +++ b/xq/restx_dict_cached.xq @@ -186,15 +186,14 @@ declare %rest:path("{$lang}/search/new") $sd(1)('entry_id'), string-join($sd(1)('path')?*,"|")) else - let $r5 := session:set('searchN',0) - return web:redirect('../dict') + web:redirect('../search/clear') }; declare %rest:path("{$lang}/search/next") %output:method("html") %output:html-version('5') function page:search-next($lang) { - let $n := session:get('searchN')+1 + let $n as xs:integer := session:get('searchN')+1 let $r1 := session:set('searchN', $n) let $sd := session:get('searchData') return page:by-id($lang, $sd($n)('entry_id'), string-join($sd($n)('path')?*,"|")) @@ -204,7 +203,7 @@ declare %rest:path("{$lang}/search/prev") %output:method("html") %output:html-version('5') function page:search-prev($lang) { - let $n := session:get('searchN')-1 + let $n as xs:integer := session:get('searchN')-1 let $r1 := session:set('searchN', $n) let $sd := session:get('searchData') return page:by-id($lang, $sd($n)('entry_id'), string-join($sd($n)('path')?*,"|")) @@ -214,7 +213,7 @@ declare %rest:path("{$lang}/search/position") %rest:query-param("p", "{$p}") %output:method("html") %output:html-version('5') - function page:search-position($lang,$p) { + function page:search-position($lang, $p as xs:integer) { let $r1 := session:set('searchN', $p) let $sd := session:get('searchData') return page:by-id($lang, $sd($p)('entry_id'), string-join($sd($p)('path')?*,"|")) diff --git a/xq/test.xq b/xq/test.xq index 98b9f96..fcd0bc2 100644 --- a/xq/test.xq +++ b/xq/test.xq @@ -3,8 +3,22 @@ declare namespace abv = "http://ossetic-studies.org/ns/abaevdict"; import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at './abv-mod.xqm'; -let $doc := db:get('abaevdict_en','/xml/entry_az.xml') -return string(abv-m:make-html($doc, 'ru')/article[1]/@id) +for $a in [1,2,3]?* +return $a + +(: let $doc-tr := $doc transform with { + replace node xquery:eval("/Q{http://www.tei-c.org/ns/1.0}entry[1]/Q{http://www.tei-c.org/ns/1.0}etym[1]/Q{http://www.tei-c.org/ns/1.0}mentioned[2]/Q{http://www.tei-c.org/ns/1.0}mentioned[18]", {'': .}) + with {xquery:eval("/Q{http://www.tei-c.org/ns/1.0}entry[1]/Q{http://www.tei-c.org/ns/1.0}etym[1]/Q{http://www.tei-c.org/ns/1.0}mentioned[2]/Q{http://www.tei-c.org/ns/1.0}mentioned[18]", {'': .})} +} +return $doc :) + +(: array{for $doc in collection('abaevdict_en/xml') +let $hits := for $node in $doc//text() + where $node contains text 'friend' + return path($node) +where count($hits) > 0 +return {'entry_id': string($doc/tei:entry[1]/@xml:id), 'xpath': array{$hits}}} :) + (: let $nid := db:node-id($doc/tei:entry[1]/tei:note[1]) :) (: return $nid :) (: return xquery:eval('declare namespace tei = "http://www.tei-c.org/ns/1.0";//tei:note',{'': $doc}) :) @@ -15,8 +29,6 @@ return string(abv-m:make-html($doc, 'ru')/article[1]/@id) (: import module namespace api = 'http://ossetic-studies.org/ns/abaevdict-api' at './restx_api.xq'; :) -(: abv-m:make-html(doc('abaevdict_en/xml/entry_az.xml')//tei:mentioned,'en') :) - (: abv-m:langname-by-id('inc-x-old-vaidika','en') :) (: SERIALIZE AS JSONML :) diff --git a/xsl/standardize.xsl b/xsl/standardize.xsl index 85382df..e199269 100644 --- a/xsl/standardize.xsl +++ b/xsl/standardize.xsl @@ -38,7 +38,7 @@ - +