Apologies, I hit send before deleting an incomplete thought in the 3rd paragraph. Revised version is below.
On Sun, Dec 29, 2019 at 5:35 PM Joe Wicentowski <joe...@gmail.com> wrote: > Hi David, > > Let me quote from Adam Retter's response to a similar question on > exist-open[^1]: > > > The issue you have is that the Request object only makes sense when your > XQuery is run by eXist-db's webserver, this is because the "request" is the > incoming HTTP request. When running via oxygen there is no HTTP request. > > The same factor affects other utilities that talk to eXist via XML-RPC, > such as eXist's Java Admin Client. See the attached screenshot. > > In the same thread, Roy Walter suggested a workaround: using the > 3-parameter variant of the request:get-parameter function, in which the 3rd > parameter instructs the function whether to fail on error or not.[^2] If > you change your use of the function to: > > ``` > request:get-parameter('story', 'x', false()); > ``` > > ... then the function will return "x" when it otherwise would raise an > error. > > Best, > Joe > > [^1]: https://markmail.org/message/afds3uvbbouees7a > [^2]: https://markmail.org/message/offwjsqd46fcofqc > > On Sun, Dec 29, 2019 at 10:58 AM David Birnbaum <djbp...@gmail.com> wrote: > >> Dear oxygen-user list, >> >> I've constructed an XQuery script for eXist-db that uses the function >> request:get-parameter(). It works as expected in eXide. I have established >> a data source connection between <oXygen/> (XML Editor 21.1, build >> 2019120214, running on MacOS Mojave) and eXist-db (5.0.0) running on >> localhost, and I can open, edit, and save XQuery scripts from inside >> eXist-db within <oXygen/>, from which I conclude that the connection is >> live. Since <oXygen/> apparently cannot use the eXist-db data source >> connection for debugging, instead of using the <oXygen/> XQuery debugger >> perspective to run the script I configured a transformation scenario where >> I specify the localhost eXist-db connection as the Transformer. When I run >> this script, I get the following error message from <oXygen/>: >> >> err:XPDY0002 Variable $request is not bound to an Java object >> >> >> The function is used in a line that reads: >> >> declare variable $story_id as xs:string := request:get-parameter('story', >> 'x'); >> >> >> I thought at first that the error might be because the "request:" >> namespace prefix was not declared and bound (eXist-db declares it >> implicitly), so I added an explicit namespace declaration for it: >> >> declare namespace request="http://exist-db.org/xquery/request"; >> >> >> The error remains. The entire XQuery script is below; it retrieves >> information from a TEI document, based on a user-supplied resource name, if >> the document exists and returns an error message otherwise. >> >> Can someone please help me identify what I have apparently misunderstood >> about running XQuery scripts in an <oXygen/> transformation scenario using >> eXist-db as the XQuery transformer? >> >> Sincerely, >> >> David >> djbp...@gmail.com >> __ >> >> xquery version "3.1"; >> declare default element namespace "http://www.tei-c.org/ns/1.0"; >> declare namespace request="http://exist-db.org/xquery/request"; >> declare variable $stories as document-node()+ := >> collection('/db/apps/neh_06_reading_tei/xml'); >> declare variable $story_id as xs:string := request:get-parameter('story', >> 'x'); >> declare variable $story_filename as xs:string: = concat($story_id, >> '.xml'); >> declare variable $story as document-node()? := >> $stories[ends-with(base-uri(), $story_filename)]; >> >> if ($story) then >> <TEI>{ >> $story//(titleStmt/title | text) >> }</TEI> >> else >> <error xmlns="">{concat('No such story:', $story_id)}</error> >> >> _______________________________________________ >> oXygen-user mailing list >> oXygen-user@oxygenxml.com >> https://www.oxygenxml.com/mailman/listinfo/oxygen-user >> >
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user