Thanks Jakob, this looks like it could be promising. We'll keep our eyes on 
this effort.

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jakob Fix
Sent: Thursday, August 01, 2013 10:48 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Modifying rewriter.xqy

Hi,

you might also want to look at restxq (and its early open-source implementation 
for MarkLogic rxq) which is layered on top of the rest api. This would allow 
you to create very easily the required endpoints, and call your functions from 
there. Obviously rxq is in its early stages, but it's really quite usable.

http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-specification.html
https://github.com/xquery/rxq curtesy of Jim Fuller.

cheers,
Jakob.


On Thu, Aug 1, 2013 at 4:20 PM, Colleen Whitney 
<[email protected]<mailto:[email protected]>> wrote:
Hi Zach,

I think it might be better to start with a little more information about *why* 
you're trying to modify the rewriter.  That's important, because if there's 
another way to accomplish what you're trying to do without changing this code, 
you'll be much happier when you go to upgrade in the future (because that code 
will be replaced during upgrade).

I'm going to make a wild guess that you're trying to do two things:

 * Make your "appl" options the default options that are called on every call 
to the search endoint.

 * Make requests starting with /item/ map to a particular call to the documents 
endpoint.

If that's correct, then I have two suggestions that might make it possible for 
you to get what you want without touching the rewriter.

* You can set your "appl" options as your default options by persisting them 
using the special name "default"  (the same way you did when configuring your 
"appl" options).

* You can create an extension to the API that accomplishes the second task if 
you don't mind that your URL pattern isn't starting with /item.

--Colleen

________________________________
From: 
[email protected]<mailto:[email protected]>
 
[[email protected]<mailto:[email protected]>]
 on behalf of Dunlap, Zachariah [[email protected]<mailto:[email protected]>]
Sent: Thursday, August 01, 2013 7:04 AM
To: [email protected]<mailto:[email protected]>
Subject: [MarkLogic Dev General] Modifying rewriter.xqy
I'd like to make some modifications to rewriter.xqy found at: 
/MarkLogic/rest-api/rewriter.xqy.

I've copied rewrite.xqy and changed it as follows:

xquery version "1.0-ml";

(: Copyright 2011-2013 MarkLogic Corporation.  All Rights Reserved. :)
import module namespace amped-common = 
"http://marklogic.com/appservices/util-amped";
    at "/MarkLogic/appservices/utils/common-amped.xqy";

amped-common:appservices-check-license-valid();

import module namespace rest = "http://marklogic.com/appservices/rest";
    at "/MarkLogic/appservices/utils/rest.xqy";

import module namespace conf = "http://marklogic.com/rest-api/endpoints/config";
    at "/MarkLogic/rest-api/endpoints/config.xqy";

declare default function namespace "http://www.w3.org/2005/xpath-functions";;
declare option xdmp:mapping "false";

let $uri  := xdmp:get-request-url()
let $customuri := if (fn:starts-with($uri, "/search?q=")) then fn:replace($uri, 
"^/search\?q=", "/v1/search?options=appl&amp;q=")
    else if (fn:starts-with($uri, "/item/")) then fn:replace($uri, "/item/", 
"/v1/documents?format=xml&amp;uri=/content/")
    else $uri

return (
        conf:rewrite(xdmp:get-request-method(), $customuri, 
xdmp:get-request-path()),
        $customuri
        )[1]

Unfortunately, it seems that anything after the ? in my fn:replace statement is 
getting dropped. I gather this is because there is something in config.xqy or 
elsewhere that is saying the ? should be the end of the line, but I can't 
locate it. I've tried URL encoding the ? but that doesn't work either.

If anyone has any suggestions on how I can get past this hurdle or can suggest 
a better way for me to achieve what I'm trying to do, I welcome your input.

Thanks,

Zach

The information contained in this communication is intended for the use
of the designated recipients named above. If the reader of this
communication is not the intended recipient, you are hereby notified
that you have received this communication in error, and that any review,
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please
notify The Associated Press immediately by telephone at 
+1-212-621-1898<tel:%2B1-212-621-1898>
and delete this email. Thank you.
[IP_US_DISC]


msk dccc60c6d2c3a6438f0cf467d9a4938

_______________________________________________
General mailing list
[email protected]<mailto:[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