You may use below queries to return document(s) in marklogic server.
fn:doc() or doc()
Returns all the documents in the database
To return the first document
fn:doc()[1]
To return specific document(s) with a known URI
USE
fn:doc(
[uri as xs:string*]
) as document-node()*
xs:string* –> URI(s) of the document to retrieve.
for eg.
1) To return document having URI “/sample/mydoc.xml”
fn:doc(“/sample/mydoc.xml”)
2) To return documents having URI “/sample/mydoc1.xml” and “/sample/mydoc2.xml”
fn:doc((“/sample/mydoc1.xml”, “/sample/mydoc2.xml”))
fn:collection() – Returns all the documents in the database
To return the first document in the collection
fn:collection()[1]
fn:collection(
[uri as xs:string*]
) as document-node()*
xs:string* –> a list of URIs or collection name
returns all of the documents in the collection as document-node()*.
for eg.
fn:collection(“collectionName”)
A simple Xquery file to return a document with the URI coming from external parameter.
-----------------------------------------
xquery version "1.0-ml";
declare namespace ns1= "http://www.examplenamespace.com/ns1";
declare variable $externparameter as xs:string external;
<document>
{
fn:doc($externparameter)
}
</document>
----------------------------------------------

No comments:
Post a Comment