Not sure about cqsh.
xmlsh can pass variables when calling ML functions

http://www.xmlsh.org/ModuleMarkLogic

using the invoke command if the query is on the server (module)
http://www.xmlsh.org/MarkLogicInvoke

invoke -v myquery.xqy var1 value1 var2 value2

using the query command if the query is local
http://www.xmlsh.org/MarkLogicQuery

query -f myquery.xqy -v var1 value1 var2 value2

BUT ... that said , you mention the script expects "string of 1 or more"

so presumably thats a extern variable like

        declare variable $myvar as xs:string+ extern ;


With that your out of luck with ANY XCC based technology.  XCC cannot
pass sequences to scripts foreign or domestic, period.   It simply
doesnt support sequences as variable values. (grumble)

The workaround is you can wrap the sequence in a xml node and create a
wrapper function inside your script to unwrap it.  


Suppose you wrap your values like
<node>
  <value>Value 1</value>
  <value>Value 2</value>
  <value>Value 3</value>
  <value>Value 4</value>
</node>


XQuery:

declare variable $myvar_node as element(node) extern;
declare variable $myvar := $myvar_node//value/string() ;

---------


Now to call it (using xmlsh) you could do this


strings=("Value1" "Value2" "Value3" "Value4")
node=<[ <node>{ for $s in $strings return <value>{$s}</value>} </node>
]>
query -f myquery.xqy -v myvar_node $node


No idea if this could be done in cqsh








-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Paul M
Sent: Thursday, November 04, 2010 10:07 AM
To: [email protected]
Subject: [MarkLogic Dev General] cqsh

I would like to pass a variable to the following using cqsh
cqsh -f myquery.xqy

myquery.xqy expects an external variable to be defined (string of 1 or
more)

Is this possible in cqsh?



      
_______________________________________________
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