Hi Charles,

OK...  I'll get back to the binary bit - never tried to produce a PDF, so I'm 
not sure I'm clear on "wrap the binary output you want into a document node".

So, to get an idea of what's happening, I changed the module to this:
xquery version "1.0-ml";

module namespace cpdf = "http://marklogic.com/rest-api/transform/createPDF";;

import module namespace jam = "http://xqdev.com/jam"; at "jam.xqy";
import module namespace jamu = "http://xqdev.com/jam-utils"; at "jam-utils.xqy";

declare function cpdf:transform(
  $context as map:map,
  $params as map:map,
  $content as document-node()
) as document-node()
{
  if (fn:empty($content/*)) then $content
  else
<doc>{
jam:start("http://localhost:8080/mljam";, "mljam", "secret"),
jam:eval-get("1+1"),
jam:end()
}</doc>
(:
<doc>{
(jam:start("http://ilabsmltest:8080/mljam/mljam";, "mljam", "secret"),
jamu:fop($content),
jam:end())
}</doc>
:)
};

And this is the error from the error log:
2013-04-04 13:36:42.280 Info: DocumentsREST: <error:error 
xsi:schemaLocation="http://marklogic.com/xdmp/error error.xsd" 
xmlns:error="http://marklogic.com/xd
mp/error" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
2013-04-04 13:36:42.280 Info: DocumentsREST:   
<error:code>XDMP-MODNOTFOUND</error:code>
2013-04-04 13:36:42.280 Info: DocumentsREST:   
<error:name>err:XQST0059</error:name>
2013-04-04 13:36:42.280 Info: DocumentsREST:   
<error:xquery-version>1.0-ml</error:xquery-version>
2013-04-04 13:36:42.280 Info: DocumentsREST:   <error:message>Module not 
found</error:message>
2013-04-04 13:36:42.280 Info: DocumentsREST:   
<error:format-string>XDMP-MODNOTFOUND: (err:XQST0059) Module 
/marklogic.rest.transform/createPDF/lib/jam.xqy n
ot found</error:format-string>...

So, my newest question is: how do I properly specify the modules in the REST 
transform XQuery module (the jam.xqy and jam-utils.xqy which live in the 
modules DB for REST app server)?

Thanks,
David

From: [email protected] 
[mailto:[email protected]] On Behalf Of Charles Greer
Sent: Thursday, April 04, 2013 1:00 PM
To: [email protected]
Subject: Re: [MarkLogic Dev General] Probably doing something stupid...

Hi David,

For a 500 error you should get a little more detail in the server logs, but one 
thing you mention is indeed wrong -- you need to return a document-node from 
the transform.

It should be possible to wrap the binary output you want into a document node 
though.

Charles


constructor
On 04/04/2013 07:32 AM, Steiner, David J. (LNG-DAY) wrote:

Trying to do the following:

curl --anyauth --user id:pass -X PUT 
-d@"./createPDF.xqy<mailto:-d@%22./createPDF.xqy>" -H "Content-type: 
application/xquery" 'http://ilabsmltest:8011/v1/config/transforms/createPDF'



And getting the error:

<rapi:error 
xmlns:rapi="http://marklogic.com/rest-api";<http://marklogic.com/rest-api>>

<rapi:status-code>500</rapi:status-code>

<rapi:status>INTERNAL ERROR</rapi:status>

<rapi:message-code/>

<rapi:message>500 Internal Server Error internal error</rapi:message>

</rapi:error>



The following works from QConsole:

xquery version "1.0-ml";

import module namespace jam = "http://xqdev.com/jam";<http://xqdev.com/jam> at 
"jam.xqy";

import module namespace jamu = 
"http://xqdev.com/jam-utils";<http://xqdev.com/jam-utils> at "jam-utils.xqy";



let $xslfoDoc :=  [xsl-fo deleted]

return

(jam:start("http://ilabsmltest:8080/mljam/mljam";<http://ilabsmltest:8080/mljam/mljam>,
 "mljam", "secret"),

jamu:fop($xslfoDoc),

jam:end())



So, I'm trying to make a XQuery transformation module out of it :

xquery version "1.0-ml";



module namespace cpdf = 
"http://marklogic.com/rest-api/transform/createPDF";<http://marklogic.com/rest-api/transform/createPDF>;



import module namespace jam = "http://xqdev.com/jam";<http://xqdev.com/jam> at 
"jam.xqy";

import module namespace jamu = 
"http://xqdev.com/jam-utils";<http://xqdev.com/jam-utils> at "jam-utils.xqy";



declare function cpdf:transform(

  $context as map:map,

  $params as map:map,

  $content as document-node()

) as binary()

{

  if (fn:empty($content/*)) then $content

  else

(jam:start("http://ilabsmltest:8080/mljam/mljam";<http://ilabsmltest:8080/mljam/mljam>,
 "mljam", "secret"),

jamu:fop($content),

jam:end())

};





I'm assuming that there's just something wrong with the imports... and/or 
namespacing...

And not that I can't return a binary() instead of a document-node().





Thanks,

David








_______________________________________________

General mailing list

[email protected]<mailto:[email protected]>

http://developer.marklogic.com/mailman/listinfo/general



--

Charles Greer

Senior Engineer

MarkLogic Corporation

[email protected]<mailto:[email protected]>

Phone: +1 707 408 3277

www.marklogic.com<http://www.marklogic.com>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to