The server knows this information we should expose it with an API.

Sent from my iPad (excuse the terseness)
David A Lee
[email protected]<mailto:[email protected]>


On Sep 6, 2012, at 12:15 PM, "Danny Sinang" 
<[email protected]<mailto:[email protected]>> wrote:

What's the prize ? :)

- Danny

On Wed, Sep 5, 2012 at 3:33 PM, Michael Blakeley 
<[email protected]<mailto:[email protected]>> wrote:
Yes, using John's library would be more straightforward. But then Danny 
wouldn't be in the running for the "most surprising use of an XQuery library" 
award.... I understand the winner for this year will be announced in Amsterdam?

Danny, when looking at the parse tree be sure to check for the 'external' 
token. If the variable name and optional type declaration aren't followed by 
'external', then the variable can't be set externally. In 5.0-3.3 it looks like 
such attempts are ignored.

xdmp:eval('
 declare variable $assetId := "x";
 $assetId',
 (xs:QName('assetId'), 'fubar'))
=>
x

xdmp:eval('
 declare variable $assetId external;
 $assetId',
 (xs:QName('assetId'), 'fubar'))
=>
fubar

-- Mike

On 5 Sep 2012, at 11:10 , John Snelson wrote:

> I'm not sure xqysp will do what you need. Take a look at this project
> instead - it's a fully functional XQuery parser in XQuery:
>
> https://github.com/jpcs/xqueryparser.xq
>
> It also does some useful pre-processing, like correctly resolving all
> the QNames in the query for you.
>
> John
>
> On 05/09/12 17:43, Danny Sinang wrote:
>> 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]<mailto:[email protected]>
>> <mailto:[email protected]<mailto:[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]<mailto:[email protected]> 
>> <mailto:[email protected]<mailto:[email protected]>>
>>   Phone: +1 812-482-5224<tel:%2B1%20812-482-5224> 
>> <tel:%2B1%20812-482-5224>____
>>
>>   Cell: +1 812-630-7622<tel:%2B1%20812-630-7622> <tel:%2B1%20812-630-7622>
>>   www.marklogic.com<http://www.marklogic.com> <http://www.marklogic.com/>
>>
>>   ____
>>
>>   __ __
>>
>>   
>> *From:*[email protected]<mailto:[email protected]>
>>   
>> <mailto:[email protected]<mailto:[email protected]>>
>>   
>> [mailto:[email protected]<mailto:[email protected]>
>>   
>> <mailto:[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]<mailto:[email protected]>
>>   <mailto:[email protected]<mailto:[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]<mailto:[email protected]> 
>> <mailto:[email protected]<mailto:[email protected]>>
>>   Phone: +1 812-482-5224<tel:%2B1%20812-482-5224> 
>> <tel:%2B1%20812-482-5224>____
>>
>>   Cell: +1 812-630-7622<tel:%2B1%20812-630-7622> <tel:%2B1%20812-630-7622>
>>   www.marklogic.com<http://www.marklogic.com> <http://www.marklogic.com/>____
>>
>>   ____
>>
>>   
>> *From:*[email protected]<mailto:[email protected]>
>>   
>> <mailto:[email protected]<mailto:[email protected]>>
>>   
>> [mailto:[email protected]<mailto:[email protected]>
>>   
>> <mailto:[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]<mailto:[email protected]> 
>> <mailto:[email protected]<mailto:[email protected]>>
>>   http://developer.marklogic.com/mailman/listinfo/general____
>>
>>   __ __
>>
>>
>>   _______________________________________________
>>   General mailing list
>>   [email protected]<mailto:[email protected]> 
>> <mailto:[email protected]<mailto:[email protected]>>
>>   http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
>
> --
> John Snelson, Lead Engineer                    http://twitter.com/jpcs
> MarkLogic Corporation                         http://www.marklogic.com
> _______________________________________________
> General mailing list
> [email protected]<mailto:[email protected]>
> http://developer.marklogic.com/mailman/listinfo/general
>

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

_______________________________________________
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