From: Hayim L. <hl...@um...> - 2022-10-11 17:08:47
|
Dear list, This is technically an expath problem rather than an eXist problem, but I was hoping that the accumulated knowledge on the list might provide a quick fix and that this is not list abuse. I am upgrading an app from eXist version 4 to 5+ and need to rewrite an http-post request in one function from the older http-client to the new expath http client. In the attached xql file the post request begins at line 102. My attempted rewrite is wrong. I've tried the following, where $tokens is a json represntation of textual data from which CollateX <https://collatex.net> generates an alignment table that is returned in json as $results let $results := parse-json( content:get-metadata-and-content( http:send-request(<http:request href=" http://52.12.26.11:8080/collatex/collate" method="post"> <http:body media-type="text/plain" content-type="text/plain">{($tokens,$headers)}</http:body> </http:request> ))) return ... (: do stuff with $results :) Unfortunately, I cannot figure out how to address the error report ("Invalid attributes") that eXist returns. /db/apps/digitalmishnah/modules/view.xqlerr:XPTY0004 checking function > parameter 1 in call > contentextraction:get-metadata-and-content(untyped-value-check[xs:base64Binary, > hc:send-request(element {"http:request"} { attribute {href} { > http://52.12.26.11:8080/collatex/collate } attribute {method} { post } > text { } element {"http:body"} { attribute {media-type} { text/plain } > attribute {content-type} { text/plain } { ( $tokens, $headers ) } } text { > } } )]): Invalid attributes [at line 106, column 9] In function: > cmp:compare-mishnah(node(), xs:string, xs:string*, xs:string) > [41:7:/db/apps/digitalmishnah/modules/compare.xql] cmp:compare-view(node(), > map(*)) [-1:-1:/db/apps/digitalmishnah/modules/compare.xql] > templates:process-output(element(), map(*), item()*, element(function)) > [211:9:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:call-by-introspection(element(), map(*), map(*), function(*)) > [189:28:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:call(item(), element(), map(*)) > [137:36:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [148:81:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [428:17:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process-output(element(), map(*), item()*) > [230:9:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process-output(element(), map(*), item()*, element(function)) > [211:9:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:call-by-introspection(element(), map(*), map(*), function(*)) > [189:28:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:call(item(), element(), map(*)) > [137:36:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [133:51:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:process(node()*, map(*)) > [90:9:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] > templates:apply(node()+, function(*), map(*)?, map(*)?) > [53:5:C:\users\hlapin\eXist-db-6.0.1\data\expathrepo\shared-0.9.1\content\templates.xql] I'd be truly grateful for any pointers. Many thanks, HL |