Reputation: 734
I have a document which has many XML documents with this hierarchy:
<envelope>
<headers>1211</headers>
<instance>
<info xmlns:es="http://marklogic.com/entity-services">
<title>main document</title>
<version>1.0.2</version>
</info>
<Firstdocument xmlns="http://nl.abnamro.com/cre">
<mainId>0500910197</mainId>
<mainIdType>flowchart</mainIdType>
<contact>
<contactId>
<value>1120721</value>
<scheme>main schema</scheme>
</contactId>
</contact>
</Firstdocument>
</instance>
<attachments></attachments>
</envelope>
I have updated the actual document. I have similar documents in my database of MarkLogic. How can I return all uris where the value
= 1120721?
Upvotes: 1
Views: 65
Reputation: 66781
Now that you have updated your question with a different XML structure, I suspect that the issues you have been having are that you are not taking into account the namespaces that your elements are bound to.
Since namespace-prefixes are not being used, it can be very easy to overlook and not realize that the elements are bound to a namespace, or which one is in scope.
In your example XML, the value
element is a descendant of Firstdocument
, which is bound to the http://nl.abnamro.com/cre
namespace.
<Firstdocument xmlns="http://nl.abnamro.com/cre">
So, in order to search the database for docs with that element and the value "1120721", you need to declare that namespace and use it when constructing the QName:
declare namespace cre = "http://nl.abnamro.com/cre";
cts:search(doc(), cts:element-value-query(xs:QName("cre:value"), "1120721"))
Upvotes: 1