Loading TOC...

xdmp:database-path-namespaces

xdmp:database-path-namespaces(
   [$dbid as xs:unsignedLong]
) as Element()

Summary

Returns the list of path namespaces for the given database id.

Parameters
$dbid The id for the database to get the path namespaces for. Empty for the current database.

Example


xquery version "1.0-ml";

xdmp:database-path-namespaces(xdmp:database("Documents"))

=> List of path-namespaces defined on Documents

<path-namespaces xmlns="http://marklogic.com/xdmp/database">
  <path-namespace>
    <prefix>wm</prefix>
    <namespace-uri>http://www.mediawiki.org/xml/export-0.4/</namespace-uri>
  </path-namespace>
  <path-namespace>
    <prefix>aaa</prefix>
    <namespace-uri>http://www.aaa.org/</namespace-uri>
  </path-namespace>
</path-namespaces>

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

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • I want to get all the existing namespaces in my database, and the query is not returning them. Thanks. xquery version "1.0-ml"; xdmp:database-path-namespaces(xdmp:database("hcp4-1-13")) result <path-namespaces xmlns="http://marklogic.com/xdmp/database"/>
    • This function only returns path namespaces that you have configured for the database. Maybe you have not configured any? You need these to configure path fields and path range indexes.
      • Thanks for the quick answer. Probably I am confusing things. I am displaying an object and I can see a namespace declaration xmlns:r query: doc("/$RESOURCE$/100/res-14.xml") result: <?xml version="1.0" encoding="UTF-8"?> <r:res r:id="14" xmlns:r="http://www.rsuitecms.com/rsuite/ns/metadata"><r:md> <r:id>14</r:id> ..... I need a query to get all our namespaces like this one http://www.rsuitecms.com/rsuite/ns/metadata. Is that possible? is it really a namespace?
        • You can do that with XPath. The path-namespaces api returns database configuration, not data from your document. Here is a way to do something like that in XPath (there are other ways too): let $node := <r:res r:id="14" xmlns:r="r-namespace"> <r:md> <r:id>14</r:id> </r:md> </r:res> return $node/namespace::* => namespace{"r"}{"r-namespace"} namespace{"xml"}{"http://www.w3.org/XML/1998/namespace"}