Hello David,
No luck, I am getting following error when I try your suggestion:
com.marklogic.xcc.exceptions.XQueryException: XDMP-TOOFEWARGS: (err:XPST0017) 
fn:document-uri() -- Too few args, expected 1 but got 0 [Session: user=user, 
cb=XCCTestDB [ContentSource: user=user, cb=XCCTestDB [provider: 
address=localhost/127.0.0.1:8006, pool=1/64]]] [Client: XCC/4.2-7, Server: 
XDBC/5.0-1]in /eval, on line 1expr: fn:document-uri()        at 
com.marklogic.xcc.impl.handlers.ServerExceptionHandler.handleResponse(ServerExceptionHandler.java:30)
        at 
com.marklogic.xcc.impl.handlers.EvalRequestController.serverDialog(EvalRequestController.java:78)
        at 
com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:78)
        at 
com.marklogic.xcc.impl.SessionImpl.submitRequest(SessionImpl.java:268)
Basically I want to be able to get images stored in Marklogic server back on a 
JSP page in an <img> tag. So far, I can get the html content upto the JSP page, 
however to render image, I want to be able to use the same name used while 
storing the image in Marklogic database e.g. image1,2,3 etc as document URI.
I tried following in QConsole which works but there are two problems with it: 
for $x in collection("user10")returnfn:document-uri($x)
Problem:1 : It retrieves only the file names so I will have to write one query 
to get the content and other query to get the file names, that does not sound 
quite right.
Problem:2:Even if problem-1 is not an issue, how do I get it to work from Java 
code? Should I copy these lines in a .xqy module/page and invoke it somehow 
from JSP?

Is there any better way to get image and it's document-uri in one go from 
Marklogic. I stored them as binary instances when creating content. I am using 
Marklogic-5.
ThanksAmaresh Wakkar

From: d...@epocrates.com
To: general@developer.marklogic.com
Date: Mon, 14 Nov 2011 15:08:19 +0000
Subject: Re: [MarkLogic Dev General] Retrieving file name/document URI of 
binary        content











Try this:
 
    Request request = session.newAdhocQuery(" 
collection('imageCollection')/document-uri() ");
 
 
 

----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
d...@epocrates.com
812-482-5224

 


From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com]
On Behalf Of Amar Wakkar

Sent: Monday, November 14, 2011 9:27 AM

To: general@developer.marklogic.com

Subject: [MarkLogic Dev General] Retrieving file name/document URI of binary 
content


 

Dear all,

 


I am learning ways of doing things in Marklogic server. I have managed to save 
a collection to Marklogic server which consists of few .gif images.
 The document URI's are the actual file names when I stored them in collection 
e.g. image1, image2 etc..The collection is named "imageCollection". I can query 
for "imageCollection" and it does return 3 images in result set. Unfortunately, 
I am unable to figure
 out how to get "file name" or Document URI of these images ? 


 


 


           
createOptions = ContentCreateOptions.newBinaryInstance();


       
    createOptions.setCollections(new String[]{"imageCollection"});


       
    


       
    createOptions.setFormatBinary();


 


       
    content = 
ContentFactory.newContent(someContent.getAttachmentsFileNames()[i], 
someContent.getAttachments()[i], createOptions);


            System.out.println("Inserting contents..");


            session.insertContent(content);


         


 


The call to 


 



    Request request = session.newAdhocQuery(" collection(\"imageCollection\") 
");


 



           
ResultSequence rs = session.submitRequest(request);



 



while(rs.hasNext()){


                       
System.out.println("Inside contentDao 44444444");


 


                       
ResultItem item = rs.next();


 


       


Following call returns null


       System.out.println(item.getDocumentURI());


 


Please help me understand how to get the file names of the images so that I can 
use them to render back on screen.


 


 


Thanks


Amaresh Wakkar


      




 






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

Reply via email to