I don't think so - $content/* gives a different error when I run it - nothing
in the error log, but this in the browser window:
<rapi:error>
<rapi:status-code>400</rapi:status-code>
<rapi:status>Bad Request</rapi:status>
<rapi:message-code>XDMP-ARGTYPE</rapi:message-code>
<rapi:message>XDMP-ARGTYPE: (err:XPTY0004)
fn:error("bsh.ParseException: Parse error at line 1, column 637. Encounte...")
-- arg1 is not of type xs:QName?</rapi:message>
</rapi:error>
And a java error in the MLJAM log:
Parse error at line 1, column 637. Encountered: <EOF>
at bsh.Parser.generateParseException(Unknown Source)
at bsh.Parser.jj_consume_token(Unknown Source)
at bsh.Parser.Block(Unknown Source)
at bsh.Parser.Statement(Unknown Source)
at bsh.Parser.BlockStatement(Unknown Source)
at bsh.Parser.Line(Unknown Source)
at bsh.Interpreter.Line(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at com.xqdev.jam.MLJAM.doPost(MLJAM.java:301)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:368)
at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at
org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953)
at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Note that I can run the following from QConsole and open the output file in a
browser just fine:
xquery version "1.0-ml";
import module namespace cpdf =
"http://marklogic.com/rest-api/transform/createPDF" at "createPDF.xqy";
let $pdf :=
let $xslfoDoc :=
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:lncr="http://www.lexis-nexis.com/lncr"
xmlns:caseinfo="http://www.lexisnexis.com/xmlschemas/content/legal/case-information/1/"
xmlns:casesum="http://www.lexisnexis.com/xmlschemas/content/legal/case-summary/1/">
<fo:layout-master-set>
<fo:simple-page-master master-name="LetterPage" page-width="8.5in"
page-height="11in">
<fo:region-body region-name="PageBody" margin="0.7in"/>
<fo:region-before region-name="PageHeader" margin="0.7in"/>
<fo:region-after region-name="PageFooter" margin="0.7in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="LetterPage">
<fo:flow flow-name="PageBody">
<fo:block>Full Casename: </fo:block>
<fo:block>Posture: </fo:block>
<fo:block>Cite Overview: </fo:block>
<fo:block>Overview: </fo:block>
<fo:block>Outcome: </fo:block>
<fo:block>Disposition: </fo:block>
<fo:block>Decision Summary: </fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root> return
document {
(cpdf:start("http://ilabsmltest:8080/mljam/mljam", "mljam", "secret"),
cpdf:fop($xslfoDoc),
cpdf:end())
}
return
xdmp:save("/tmp/example.pdf", $pdf)
Now, what I've placed in $xslfoDoc above is exactly what I get out of (the
default transformation, which is done by XSLT):
http://localhost:8011/v1/documents?uri=/lnc/7XKV-KRG0-YB0V-9128-00000-00.xml
Then, when I run it with the PDF transformation added on:
http://localhost:8011/v1/documents?uri=/lnc/7XKV-KRG0-YB0V-9128-00000-00.xml&transform=createPDF
I get the invalid coercion:
<rapi:error>
<rapi:status-code>500</rapi:status-code>
<rapi:status>INTERNAL ERROR</rapi:status>
<rapi:message-code>XDMP-AS</rapi:message-code>
<rapi:message>XDMP-AS: (err:XPTY0004) $xslfo as element() -- Invalid
coercion: document{<fo:root
xmlns:casesum="http://www.lexisnexis.com/xmlschemas/content/legal/case-summary/..."
xmlns:caseinfo="http://www.lexisnexis.com/xmlschemas/content/legal/case-informat..."
xmlns:lncr="http://www.lexis-nexis.com/lncr"
xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-set><fo:simple-page-master
master-name="Letter...</fo:root>} as element(). See the MarkLogic server
error log for further detail.</rapi:message>
</rapi:error>
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael Blakeley
Sent: Friday, April 05, 2013 3:33 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Probably doing something stupid... - using
modules in REST transform
It looks like there's a transform() function that's expecting an $xslfo to be
an element, but is getting a document-node. I don't see an $xslfo in the code
you supplied, but maybe cpdf:fop($content) needs to be cpdf:fop($content/*)
instead?
XDMP-AS: (err:XPTY0004) $xslfo as element() -- Invalid coercion:
document{<fo:root xml
ns:casesum="http://www.lexisnexis.com/xmlschemas/content/legal/case-summary/..."
xmlns:caseinfo="http://www.lexisnexis.com/xmlschemas/content/legal/case-info
rmat..." xmlns:lncr="http://www.lexis-nexis.com/lncr"
xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-set><fo:simple-page-master
master-name="Letter...</fo:root>} as element()
2013-04-05 14:35:49.504 Info: DocumentsREST: <error:stack>
2013-04-05 14:35:49.504 Info: DocumentsREST: <error:frame>
2013-04-05 14:35:49.504 Info: DocumentsREST:
<error:uri>/marklogic.rest.transform/createPDF/lib/transform.xqy</error:uri>
2013-04-05 14:35:49.504 Info: DocumentsREST: <error:line>1</error:line>
2013-04-05 14:35:49.504 Info: DocumentsREST:
<error:column>12178</error:column>
2013-04-05 14:35:49.504 Info: DocumentsREST:
<error:operation>xdmp:function(fn:QName("http://marklogic.com/rest-api/transform/createPDF",
"transform"))
(map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:map="http://marklogic.com/xdmp/map"><map:entry
key="input-type"><map:value
xsi:type="xs:string">text...</map:map>), map:map(),
document{<fo:root
xmlns:casesum="http://www.lexisnexis.com/xmlschemas/content/legal/case-summary/..."
xmlns:caseinfo="http://www.lexisnexis.com/xmlschemas/content/legal/case-informat..."
xmlns:ln cr="http://www.lexis-nexis.com/lncr"
xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-set><fo:simple-page-master
master-name="Letter...</fo:root>})</error:operation>
2013-04-05 14:35:49.504 Info: DocumentsREST:
<error:xquery-version>1.0-ml</error:xquery-version>
2013-04-05 14:35:49.504 Info: DocumentsREST: </error:frame>
-- Mike
On 5 Apr 2013, at 11:54 , "Steiner, David J. (LNG-DAY)"
<[email protected]> wrote:
> OK, so I've gone the painstaking other way and that is to include all
> functions from the two libraries into one module.
> So, the transform actually loads now.
>
> However, when I try to run it, I get a new error: Invalid coercion.
> 2013-04-05 14:35:49.504 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-05 14:35:49.504 Info: DocumentsREST:
> <error:code>XDMP-AS</error:code>
> 2013-04-05 14:35:49.504 Info: DocumentsREST:
> <error:name>err:XPTY0004</error:name>
> 2013-04-05 14:35:49.504 Info: DocumentsREST:
> <error:xquery-version>1.0-ml</error:xquery-version>
> 2013-04-05 14:35:49.504 Info: DocumentsREST: <error:message>Invalid
> coercion</error:message>
> 2013-04-05 14:35:49.504 Info: DocumentsREST: <error:format-string>XDMP-AS:
> (err:XPTY0004) $xslfo as element() -- Invalid coercion: document{<fo:root
> xml
> ns:casesum="http://www.lexisnexis.com/xmlschemas/content/legal/case-su
> mmary/..."
> xmlns:caseinfo="http://www.lexisnexis.com/xmlschemas/content/legal/cas
> e-info rmat..." xmlns:lncr="http://www.lexis-nexis.com/lncr"
> xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-s
> et><fo:simple-page-master m aster-name="Letter...</fo:root>} as
> element()</error:format-string>
> 2013-04-05 14:35:49.504 Info: DocumentsREST:
> <error:retryable>false</error:retryable>
> 2013-04-05 14:35:49.504 Info: DocumentsREST: <error:expr>$xslfo as
> element()</error:expr>
> ...
> Full error message attached.
>
>
> This is my transform function:
>
> 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
> (document {
> (cpdf:start("http://ilabsmltest:8080/mljam/mljam", "mljam", "secret"),
> cpdf:fop($content),
> cpdf:end())
> })
> };
>
>
> So, maybe I just don't know enough about putting out a PDF in a web Browser...
>
> I simply want to call this (my default transformation converts XML to XSL-FO,
> then the transform converts XSL-FO to PDF):
> http://localhost:8011/v1/documents?uri=/document.xml&transform=createP
> DF
>
> And have a PDF open in a viewer...
> Note: I am not a web app developer, so please forgive me if this is an
> obvious answer...
>
> This (the steps in the function above - cpdf:fop) seems to work in QConsole,
> as I've said - I get a bunch of "stuff" in the window that looks like this:
> %PDF-1.4
> %
> 4 0 obj
> <<
> /Producer (Apache FOP Version 0.93)
> /CreationDate (D:20130405143221-04'0-480')
>>>
> endobj
> 5 0 obj
> << /N 3
> /Length 10 0 R
> /Filter /FlateDecode
>>>
> stream
> x wTS Ͻ7 P khRH...
>
> So I was just assuming that if I could get it to come out in a browser that
> it'd come out as a PDF.
>
> Do I have to do something like change the MIME type of the response somehow?
>
> Thanks,
> David
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Steiner,
> David J. (LNG-DAY)
> Sent: Friday, April 05, 2013 9:16 AM
> To: [email protected]
> Subject: Re: [MarkLogic Dev General] Probably doing something
> stupid... - using modules in REST transform
>
> Hi Charles and Erik (combined responses),
>
> That's correct, I've added it to the REST instance's modules DB.
>
> These are the permissions I have on the library modules (jam.xqy and
> jam-utils.xqy):
> <perms>
> <perm>
> <role>app-builder</role>
> <cap>update</cap>
> </perm>
> <perm>
> <role>app-user</role>
> <cap>execute</cap>
> </perm>
> <perm>
> <role>app-user</role>
> <cap>read</cap>
> </perm>
> <perm>
> <role>rest-reader</role>
> <cap>execute</cap>
> </perm>
> <perm>
> <role>rest-reader</role>
> <cap>read</cap>
> </perm>
> <perm>
> <role>rest-writer</role>
> <cap>update</cap>
> </perm>
> <perm>
> <role>rest-writer</role>
> <cap>insert</cap>
> </perm>
> <perm>
> <role>application-plugin-registrar</role>
> <cap>read</cap>
> </perm>
> <perm>
> <role>application-plugin-registrar</role>
> <cap>execute</cap>
> </perm>
> </perms>
>
> And I still get the ERROR when using: curl --anyauth --user admin:admin -X
> PUT -d@"/home/tpf106/davids/xquery/createPDF.xqy" -H "Content-type:
> application/xquery" 'http://ilabsmltest:8011/v1/config/transforms/createPDF'
> (I'm using 6.0-1.1)
>
> David
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Erik
> Hennum
> Sent: Thursday, April 04, 2013 8:17 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Probably doing something
> stupid... - using modules in REST transform
>
> Hi, David:
>
> The description sounds like a known 6.0-2 bug that occurs when a transform or
> resource service extension imports a module database library that, in turn,
> contains an import.
>
> The workaround is either to put all of the imports in the extension (when
> possible) or to grant execute permission on the module database libraries to
> both the rest-reader and application-plugin-registrar roles.
>
> 6.0-3 should provide a fix for this bug.
>
> There is, however, a related bug that won't be fixed in 6.0-3. If a
> dependency library in the module database is updated, the extension will
> continue to use the old version. The workaround is to update the extension
> any time a dependency in the module database is updated.
>
>
> Hoping that helps,
>
>
> Erik Hennum
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Charles
> Greer
> Sent: Thursday, April 04, 2013 6:50 PM
> To: [email protected]
> Subject: Re: [MarkLogic Dev General] Probably doing something
> stupid... - using modules in REST transform
>
> Hi David,
>
> You're hitting a limitation of the REST API in its first incarnation.
> Early access for ML7 is out, and we've addressed this particular concern by
> providing an endpoint to put your own libraries in the REST instance's
> modules database with the right permissions and all.
>
> It looks like you did this by hand -- the jam libs are in your REST
> instance's modules database, right? In that case, it might be that
> you just need to make them executable by rest-reader role, and also
> make sure they're stored as text (as opposed to binary)
>
> Hope that helps,
>
> Charles
>
> On 04/04/2013 12:55 PM, Steiner, David J. (LNG-DAY) wrote:
>> It works from QC whether I use any of these:
>> import module namespace jam = "http://xqdev.com/jam" at "jam.xqy";
>> import module namespace jam = "http://xqdev.com/jam" at "/jam.xqy";
>> import module namespace jam = "http://xqdev.com/jam" at "
>> /marklogic.rest.transform/createPDF/lib/jam.xqy";
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> Steiner, David J. (LNG-DAY)
>> Sent: Thursday, April 04, 2013 3:46 PM
>> To: 'MarkLogic Developer Discussion'
>> Subject: Re: [MarkLogic Dev General] Probably doing something
>> stupid... - using modules in REST transform
>>
>> OK. I've got the syntax error worked out - it was in the module here, not
>> in the jam(s).
>>
>> So, this works:
>>
>> xquery version "1.0-ml";
>>
>> module namespace cpdf =
>> "http://marklogic.com/rest-api/transform/createPDF";
>>
>> 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
>> (document {
>> <doc/>
>> })
>> };
>>
>> And I can do this successfully:
>> http://localhost:8011/v1/documents?uri=/lnc/7XKV-KRG0-YB0V-9128-00000
>> -
>> 00.xml&transform=createPDF
>>
>>
>> Now, as soon as I add the imports back in, I get the Module Not Found error
>> message:
>>
>> 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
>> (document {
>> <doc/>
>> })
>> };
>>
>> The log is attached.
>>
>> I also tried with the libraries referenced explicitely:
>> /jam.xqy
>> /jam-utils.xqy
>> And
>> /marklogic.rest.transform/createPDF/lib/jam.xqy
>> /marklogic.rest.transform/createPDF/lib/jam-utils.xqy
>>
>> They live in both places.
>>
>> David
>>
>>
>>
>> -----Original Message-----
>> From: Steiner, David J. (LNG-DAY)
>> Sent: Thursday, April 04, 2013 3:04 PM
>> To: MarkLogic Developer Discussion
>> Subject: RE: [MarkLogic Dev General] Probably doing something
>> stupid... - using modules in REST transform
>>
>> 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
>
> --
> 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
> <mlErrorInvalidCoercion.txt>__________________________________________
> _____
> 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