It makes sense that no error is logged, because the REST api seems to have a 
try-catch around the call into your code. Otherwise it would not be able to 
wrap the error in that 'rapi' XML.

I'm much less sure why it's working in qconsole but not via REST. But my guess 
is that you have at least two copies of the library available. REST is using 
one with that syntax error, and qconsole is using the one that you expect it to 
use.

It's also just possible that MarkLogic is caching a bad copy of the library 
module. That should not happen. But if you want to rule that out, the simplest 
way is to restart MarkLogic. If that isn't practical, you could install another 
copy of the library module with a different name, and change the import to 
match.

-- Mike

On 4 Apr 2013, at 12:04 , "Steiner, David J. (LNG-DAY)" 
<[email protected]> wrote:

> Yeah, but the exact same library works just fine when I use it from Query 
> Console (see original note).
> 
> Also, there are no error messages produced in the error log.
> The only error messages I have are those returned in the rapi:error.
> 
> I'm not sure why it would work in QC and not here...
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Michael Blakeley
> Sent: Thursday, April 04, 2013 3:01 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Probably doing something stupid... - 
> using modules in REST transform
> 
> I think the library *is* accessible, because that looks like a syntax error 
> inside the library.
> 
>> XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, 
>> unexpected QName_, expecting Else_
> 
> It would be nice to have the rest of the error stack so you had the line 
> number, but that's the kind of error you might get from misspelling 'else' or 
> leaving it out.
> 
>    if (false()) then 'foo' esle 'bar'
>    =>
>    XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected 
> QName_, expecting Else_
> 
> -- Mike
> 
> On 4 Apr 2013, at 11:45 , "Steiner, David J. (LNG-DAY)" 
> <[email protected]> wrote:
> 
>> Got it...  That was easy...  Thanks Mike!
>> 
>> However, I still need would need to access these jam libraries that I have 
>> in the modules DB. 
>> 
>> Is the answer just to put them in "/marklogic.rest.transform/createPDF/lib/"?
>> 
>> If so, where's that in the documentation on creating the XQuery 
>> Transformations in the REST API?
>> 
>> If not, am I attempting something that's not possible?
>> 
>> So, instead of just asking, I tried simply loading the modules to 
>> "/marklogic.rest.transform/createPDF/lib/" instead of just "/".
>> 
>> I now get a new error:
>> <rapi:error xmlns:rapi="http://marklogic.com/rest-api";>
>>      <rapi:status-code>400</rapi:status-code>
>>      <rapi:status>Bad Request</rapi:status>
>>      <rapi:message-code>RESTAPI-INVALIDCONTENT</rapi:message-code>
>>      <rapi:message>RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: 
>> library for createPDF has errors - XDMP-UNEXPECTED: (err:XPST0003) 
>> Unexpected token syntax error, unexpected QName_, expecting 
>> Else_</rapi:message> </rapi:error>
>> 
>> Thus, I'm still stuck with not being able to access these libraries...
>> 
>> -----Original Message-----
>> From: [email protected] 
>> [mailto:[email protected]] On Behalf Of Michael 
>> Blakeley
>> Sent: Thursday, April 04, 2013 2:23 PM
>> To: MarkLogic Developer Discussion
>> Subject: Re: [MarkLogic Dev General] Probably doing something 
>> stupid... - using modules in REST transform
>> 
>> To construct a document-node:
>> 
>>   document { <test/> }
>> 
>> If you xdmp:describe that output you should see that there is a 
>> document-node around the test element. As usual you can put any XQuery 
>> expression inside the curly braces.
>> 
>> -- Mike
>> 
>> On 4 Apr 2013, at 10:43 , "Steiner, David J. (LNG-DAY)" 
>> <[email protected]> wrote:
>> 
>>> 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" -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";>
>>> <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"; at "jam.xqy"; 
>>> import module namespace jamu = "http://xqdev.com/jam-utils"; at 
>>> "jam-utils.xqy";
>>> 
>>> let $xslfoDoc :=  [xsl-fo deleted]
>>> return
>>> (jam:start("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";;
>>> 
>>> 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 binary()
>>> {
>>> if (fn:empty($content/*)) then $content  else 
>>> (jam:start("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]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>> 
>>> 
>>> --
>>> Charles Greer
>>> Senior Engineer
>>> MarkLogic Corporation
>>> [email protected]
>>> Phone: +1 707 408 3277
>>> www.marklogic.com
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>> 
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>> 
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 

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

Reply via email to