diff --git a/vicav.xqm b/vicav.xqm
index ed516a2a..f109a5c6 100644
--- a/vicav.xqm
+++ b/vicav.xqm
@@ -1430,13 +1430,30 @@ declare function vicav:_get_sample_markers() {
declare
%rest:path("/vicav/feature_labels")
%rest:GET
-
+%rest:produces("application/xml")
+%rest:produces("application/json")
+%rest:produces('application/problem+json')
+%rest:produces('application/problem+xml')
function vicav:get_feature_labels() {
+ api-problem:or_result (prof:current-ns(),
+ vicav:_get_feature_labels#0, [], map:merge((cors:header(()), vicav:return_content_header()))
+ )
+};
+
+declare
+function vicav:_get_feature_labels() {
+ let $accept-header := try { request:header("ACCEPT") } catch basex:http { 'application/xhtml+xml' }
+
let $features := collection('vicav_lingfeatures' || vicav:get_project_db())/descendant::tei:TEI//tei:cit[@type="featureSample"]
let $out := for $ana in distinct-values($features/@ana)
return {$features[./@ana = $ana][1]/tei:lbl/text()}
- return
+
+ return if (matches($accept-header, '[+/]json'))
+ then let $renderedJson := xslt:transform(<_>{$out},
+ 'xslt/feature_labels-json.xslt')
+ return serialize($renderedJson, map {"method": "json"})
+ else
(web:response-header(map {'method': 'xml'}, map:merge((cors:header(()), vicav:return_content_header()))),
{$out})
};
@@ -1468,12 +1485,20 @@ declare
%rest:path("/vicav/data_words")
%rest:query-param("type", "{$type}")
%rest:GET
+%rest:produces("application/xml")
+%rest:produces("application/json")
+%rest:produces('application/problem+json')
+%rest:produces('application/problem+xml')
+function vicav:get_data_words($type as xs:string*) {
+ api-problem:or_result (prof:current-ns(),
+ vicav:_get_data_words#1, [$type], map:merge((cors:header(()), vicav:return_content_header()))
+ )
+};
-function vicav:get_sample_words($type as xs:string*) {
+declare function vicav:_get_data_words($type as xs:string*) {
+ let $accept-header := try { request:header("ACCEPT") } catch basex:http { 'application/xhtml+xml' }
let $type := if ($type = () or $type = '') then 'samples' else $type
-
-
let $persons := if ($type = 'samples') then
for $w in collection('vicav_' || $type || vicav:get_project_db())/tei:teiCorpus/tei:TEI/tei:text/tei:body/tei:div[@type="sampleText"]/tei:p/tei:s//tei:w/tei:fs/tei:f[@name="wordform"]/text()
return replace(normalize-space($w), '[\s ]', '')
@@ -1489,6 +1514,11 @@ function vicav:get_sample_words($type as xs:string*) {
return
+ if (matches($accept-header, '[+/]json'))
+ then let $renderedJson := xslt:transform(<_>{$out},
+ 'xslt/data_words-json.xslt')
+ return serialize($renderedJson, map {"method": "json"})
+ else
(web:response-header(map {'method': 'xml'}, map:merge((cors:header(()), vicav:return_content_header()))),
{$out})
};
diff --git a/xslt/data_words-json.xslt b/xslt/data_words-json.xslt
new file mode 100644
index 00000000..921120ea
--- /dev/null
+++ b/xslt/data_words-json.xslt
@@ -0,0 +1,31 @@
+
+
+
+
+ Created on: May 9, 2024
+ Author:Maura Zsofia Abraham
+
+
+
+
+
+
+
+
+
+
+
+ One word
+
+
+ <_ type="string">
+
+
+
+
\ No newline at end of file
diff --git a/xslt/feature_labels-json.xslt b/xslt/feature_labels-json.xslt
new file mode 100644
index 00000000..6e7d90c4
--- /dev/null
+++ b/xslt/feature_labels-json.xslt
@@ -0,0 +1,32 @@
+
+
+
+
+ Created on: May 9, 2024
+ Author:Maura Zsofia Abraham
+
+
+
+
+
+
+
+
+
+
+
+ One marker
+
+
+ <_ type="object">
+
+
+
+
+
\ No newline at end of file