I think xqysp can do the parsing.

Just need someone to validate that my planned approach (looking for the
element after "declare" and "variable") is right or if I should take other
things into consideration.

import module namespace p = "com.blakeley.xqysp" at "xqysp.xqy";

let $source := "
                declare variable $assetId as xs:string
                let $x := '1'
                let $y := '2'
                return $x
               "
let $parsed := p:parse($source)

return $parsed


And the results were :

<root xmlns:xml="http://www.w3.org/XML/1998/namespace"; xmlns="
com.blakeley.xqysp">

   -  <literal>declare</literal>
   -  <literal>variable</literal>
   -  <literal>assetId</literal>
   -  <literal>as</literal>
   -  <field name="xs" op=":"><literal>string</literal></field>
   -  <literal>let</literal>
   -  <field name="x" op=":"><literal>1'</literal></field>
   -  <literal>let</literal>
   -  <field name="y" op=":"><literal>2'</literal></field>
   -  <literal>return</literal>
   -  <literal>x</literal>

 </root>

Regards,
Danny

On Wed, Sep 5, 2012 at 12:32 PM, David Lee <[email protected]> wrote:

> Thats a little tougher ... I dont know of a tool that can parse the XQuery
> to determine its declared external variables.****
>
> Stylus Studio can do this for on-filesystem (not marklogic) XQuery ... ***
> *
>
> Its quite nice that way ... but unfortunately SS dropped MarkLogic support
> about 5 years ago :(****
>
> Oxygen might be able to ... but I havent run into it.****
>
> ** **
>
>
> -----------------------------------------------------------------------------
> ****
>
> David Lee
> Lead Engineer
> MarkLogic Corporation
> [email protected]
> Phone: +1 812-482-5224****
>
> Cell:  +1 812-630-7622
> www.marklogic.com
>
> ****
>
> ** **
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Danny Sinang
> *Sent:* Wednesday, September 05, 2012 12:25 PM
> *To:* MarkLogic Developer Discussion
> *Subject:* Re: [MarkLogic Dev General] Xquery invoker****
>
> ** **
>
> Hi David,****
>
> ** **
>
> This is indeed easier than calling xdmp:invoke() in CQ, but I was hoping
> to also save myself the effort of finding out what variables a script
> accepts and typing in the variable name.****
>
> ** **
>
> Regards,****
>
> Danny****
>
> ** **
>
> On Wed, Sep 5, 2012 at 12:10 PM, David Lee <[email protected]>
> wrote:****
>
> You might look at the marklogic extension to xmlsh.****
>
> Its not a web app but a terminal app (but it also has a GUI now).****
>
> This allows you to invoke stored xqueries easily using "invoke"****
>
>  ****
>
> e.g.****
>
> import module ml=marklogic ****
>
> ...****
>
>  ****
>
> ml:invoke test.xqy****
>
>  ****
>
> Let me know if you would like further info****
>
>  ****
>
> http://www.xmlsh.org/MarkLogicInvoke****
>
> http://www.xmlsh.org/HomePage****
>
> http://www.xmlsh.org/ModuleMarkLogic****
>
>  ****
>
>
> -----------------------------------------------------------------------------
> ****
>
> David Lee
> Lead Engineer
> MarkLogic Corporation
> [email protected]
> Phone: +1 812-482-5224****
>
> Cell:  +1 812-630-7622
> www.marklogic.com****
>
>  ****
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Danny Sinang
> *Sent:* Wednesday, September 05, 2012 11:56 AM
> *To:* general
> *Subject:* [MarkLogic Dev General] Xquery invoker****
>
>  ****
>
> Hi,****
>
>  ****
>
> I find myself having to call xdmp:invoke() via CQ and entering the .xqy
> path and its parameters is tedious.****
>
>  ****
>
> Am thinking of writing a web app that would list all .xqy files in a given
> folder. Once the user has chosen a .xqy file, the web app will then display
> a label + text input field for each parameter that the said .xqy file
> accepts.****
>
>  ****
>
> But before I dive in, a few questions :****
>
>  ****
>
> 1. Is there already a tool like this (why reinvent the wheel) ?****
>
>  ****
>
> 2. Is there an Xquery parser out there that will readily tell me what
> parameters a given xqy file accepts ?****
>
>  ****
>
>     I saw some mention of XQYSP. I guess I can look for "literal" elements
> with the value "declare" and "variable" and then look for the next literal
> to get the name of the variable. Would this be the best way to go about it ?
> ****
>
>  ****
>
> Regards,****
>
> Danny****
>
>  ****
>
>  ****
>
>  ****
>
>   ****
>
>
> _______________________________________________
> 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