Loading TOC...


   $uri as xs:string
) as map:map?


Returns the metadata value of a given document.

$uri The document URI.


(: Set some metadata on a document. :)
xquery version "1.0-ml";
  map:map() => map:with("someKey", "someValue")
            => map:with("someOtherKey", 123));

(: Fetch the metadata. :)
xquery version "1.0-ml";

(: Returns the metadata for the document, as a map. For example:
 : <map:map xmlns:map="http://marklogic.com/xdmp/map" 
 :     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 :     xmlns:xs="http://www.w3.org/2001/XMLSchema">
 :   <map:entry key="someKey">
 :     <map:value xsi:type="xs:string">somevalue</map:value>
 :   </map:entry>
 :   <map:entry key="someOtherKey">
 :     <map:value xsi:type="xs:string">123</map:value>
 :   </map:entry>
 : </map:map> 

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • hi iam using this method to get metadata b https://uploads.disquscdn.com/images/eecd31237df60b489284e7fe831f93401cc39d708c412dbdc5f7fc81aaaeb5ba.png ut im getting output as "returned empty space" can some one help me with this Thanks in advance sai kumar
    • Hello Sai, The xdmp:document-get-metadata() function will return an empty sequence unless you have specifically set metadata on a document using the xdmp:document-set-metadata() update function or by setting metadata on the document when you ingest it. For example, to set metadata on a document when loading it, one approach would be to use: xquery version "1.0-ml"; xdmp:document-insert( "/test.xml", <doc>hello world</doc>, <options xmlns="xdmp:document-insert"> <metadata> { map:map() => map:with("key1", "value1") => map:with("key2", "value2") } </metadata> </options> )
      • hi map:map() => map:with("key1", "value1") => map:with("key2", "value2") what is this part in the code? actually im getting the output but not clear about this part can u explain me Thank you so much for your help sai kumar
        • It is adding key-value pairs to the metadata. Please see the documentation for map:with and the arrow operator: http://docs.marklogic.com/guide/xquery/enhanced#id_86574, http://docs.marklogic.com/map:with. Also, in future, I encourage you to ask questions on stackoverflow.com, where you will reach a much wider audience.
      • hi greg nist, i've used the sample file which u have sent but getting same output im a beginner with this marklogic so can u tell me i'm not getting metadata out. https://uploads.disquscdn.com/images/84b9c7eeee91ed4066ca14fb37e92a5d9b7cfb62aa2684bef8cac8dea0af07b0.png u can see that in the attached ss can u suggest me the necessary changes in it and is there a rest api for fetching 1.List of Documents in a forest 2.and its metadata Thanks in advance sai kumar
        • The query you are running is putting the document into the database with the metadata that I provided in the example. When the query completes, you are getting an empty sequence because the query finished and in the query you didn't ask for anything back. That's OK. That means the document is in your database. Now that the document is in your database, you can run xdmp:document-get-metadata("/test.xml") in order to return the metadata from a document based on its URI, which in the sample I gave you is "/test.xml". If you would prefer to use a REST API to perform basic CRUD operations please consult this section of the docs: http://docs.marklogic.com/REST/client I would also recommend you take a look at some of our free training options so you can learn quickly via hands-on examples: www.marklogic.com/training