David,

One way to get around these restrictions is to pass in a string representing 
XML into the function. Calling xdmp:unquote on the string inside the function 
and going about your processing from there.

-fs

From: [email protected] 
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Sunday, March 14, 2010 4:04 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Problem creating a SEQUENCE in XCCtopassto 
xquery function

I guess that answers THAT question ... I cant send Nodes as variables either :( 
:(

Exception running: ml:query
com.marklogic.xcc.exceptions.UnimplementedFeatureException: Setting variables 
of type XdmNode is not supported




From: [email protected] 
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Sunday, March 14, 2010 10:06 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Problem creating a SEQUENCE in XCCtopassto 
xquery function

Thanks for the suggestion, but in this case its a tool ("put" command from the 
marklogic extension module to xmlsh)
where I dont know ahead of time what will be passed in, it could be 1 file or 
even xml expression, or 10million files in 1 million directories.

I've gotten it to work by dynamically creating a (potentially  huge) xquery 
statement which replicates the xquery commands one per argument instead of 
doing a loop.   Its only 1 xquery command ( xdmp:directory-create( xxx ) ) .
This seems to work well enough for small tasks, I'm not sure yet what its going 
to do when I try 1 million lines.
Not sure if the cost of creating an xml docment containing 1 million elements 
and passing that to the ad-hoc script will
be more or less efficient (including my side creating the document then the XCC 
code parsing it and the server reconstructing it),
then it would be to generate send 1 million lines of xquery ...

Its probably 'better' even if slower, to create the xml doc ...  but I'd still 
like to be able to send a sequence like I'd expect any XQuery processor to be 
able to natively handle.





From: [email protected] 
[mailto:[email protected]] On Behalf Of Keith L. Breinholt
Sent: Saturday, March 13, 2010 11:18 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Problem creating a SEQUENCE in XCC 
topassto xquery function

Let me rephrase that:  If you are backing up or loading the same or similar 
sets of documents and directories it might be easier to create an XML 
configuration file that you can pass for each run.

Keith L. Breinholt
[email protected]<mailto:[email protected]>

From: [email protected] 
[mailto:[email protected]] On Behalf Of Keith L. Breinholt
Sent: Saturday, March 13, 2010 9:04 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Problem creating a SEQUENCE in XCC to 
passto xquery function

David,

Have you thought about creating a simple XML document and passing that to your 
xquery?

Might be easier.  Especially if the documents you load are similar and/or 
configurable.

Just a thought.

Keith L. Breinholt
[email protected]<mailto:[email protected]>

From: [email protected] 
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Saturday, March 13, 2010 8:26 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Problem creating a SEQUENCE in XCC to 
passto xquery function

I got one step further with this.   the 3 arg setNewVariable is already calling 
 valueVactory.newSequence
I got further by replacing it with this

     request.setNewVariable( new XName("", "dirs"),  
ValueFactory.newSequence(dirs.toArray(new XdmValue[dirs.size()])));


Now I got

com.marklogic.xcc.exceptions.UnimplementedFeatureException: Setting variables 
that are sequences is not supported


So I guess sequences are not supported ... UG ...

Could I put in a feature request to support sequences for XCC xquery calls ?


What I'm trying to do is avoid 10,000 calls to adHocQuery by passing in all the 
values as an argument.
My next step will be to try create an Element as the argument instead of a 
sequence.
Any chance elements are supported as variables in XCC ???

If that doesnt work then I suppose I'll serialize a huge XQuery document with 
in-line values to construct a sequence ...


-David


From: [email protected] 
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Saturday, March 13, 2010 10:04 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] Problem creating a SEQUENCE in XCC to passto 
xquery function

I'm trying to create a SEQUENCE in XCC to pass to an ad-hoc xquery.
I want a sequence of xs:string

I create a linked-list of XdmValue using this :


List<XdmValue> dirs = new LinkedList<XdmValue>();
...

XdmValue xdm = ValueFactory.newValue(ValueType.XS_STRING, uri);
dirs.add(xdm);

Then call this

request.setNewVariable("dirs",
     ValueType.SEQUENCE,
     ValueFactory.newSequence(dirs.toArray(new XdmValue[dirs.size()])));

I get this exception :

java.lang.IllegalArgumentException: Value must be array of XdmValue


Inspecting dirs I find each entry is of type XsStringImpl which is implements 
XdmValue (indirectly)
So I dont see where my problem is ...

Any suggestions on making a sequence of strings to pass through XCC ?



----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
[email protected]<mailto:[email protected]>
812-482-5224



NOTICE: This email message is for the sole use of the intended recipient(s) and 
may contain confidential and privileged information. Any unauthorized review, 
use, disclosure or distribution is prohibited. If you are not the intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to