[MarkLogic Dev General] Java XCC save query result to file

Gary Larsen gary.larsen at envisn.com
Tue Mar 20 14:43:46 PDT 2012


Hi Ron,

I will try the caching options.  What had me confused was getting to the
XdmItem. Wasn't aware of asString() either.

Thanks for the help

Gary 

-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Ron Hitchens
Sent: Tuesday, March 20, 2012 5:06 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Java XCC save query result to file


   Simple.  Call asString() on the ResultSequence object
and write the String to a file.  Or asStrings() if you
want a separate String for each item in the sequence to
send to different files.

   Or, if the result is truly streaming (see the setCacheResult())
method of the RequestOptions class, streaming is not the default),
you can use the writeTo() methods on the ResultItem(s) in the
ResultSequence.  These take an open Writer or OutputStream and
copy the data across.  They work if you're not streaming, as well.

   There is an example in the XCC JavaDocs that might be helpful.
Go to http://community.marklogic.com/pubs/5.0/javadoc/index.html,
click the com.marklogic.xcc.examples package and then ContentFetcher
class (top one).  Look for the "Click here for the source code for
this class" link just above the Constructor Summary heading.

On Mar 20, 2012, at 8:37 PM, Gary Larsen wrote:

> Hi,
>  
> For some queries I'm using the xdmp:save() function to store results to
file.   This will not always work because the MarkLogic server may not have
access to the share location.
>  
> Instead the results will need to be saved by the application by streaming
the ResultSequence returned from session.submitRequest(request) call.
>  
> Is there a preferred way to do this?
>  
> Thanks for your advice.  An example would be helpful if you have one.
>  
> Gary
>  
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general

---
Ron Hitchens {mailto:ron at ronsoft.com}   Ronsoft Technologies
     +44 7879 358 212 (voice)          http://www.ronsoft.com
     +1 707 924 3878 (fax)              Bit Twiddling At Its Finest
"No amount of belief establishes any fact." -Unknown




_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general



More information about the General mailing list