I’ve used one XML database eXist-db to do some XQuery testing. I have an xml collection called
“media_data_101109.xml”, and I’ve put it in direcotry
/db/wb/portfolio/media_data_101109.xml
Then I went to the eXist Sandbox, which is a GUI for doing XQuery, and type in the following XQuery:
let $mediaNodes := doc('db/wb/portfolio/media_data_101109.xml')
return $mediaNodes//media[contains(@product,"wb")]
but it failed to retrieve any results back.
However, if I prepend the server name in front of the URI string like:
let $mediaNodes := doc('http://localhost:8080/exist/rest/db/portfolio/media_data_101109.xml')
Then it worked fine (though a bit slow).
As I remembered, the first XQuery worked perfectly fine in the past, but since yesterday, it failed to retrieve any thing unless I specify the server name in the URI string.
Could anybody give me some idea on where things might went wrong here? I thought there might be some problems with my port settings? So the eXist-db might not be normally rnning?Thanks in advance.
The Base URI from the Static Context is used for the resolution of relative URI.
If your XQuery has no URI (because is built dynamically, because you didn’t save it jet as a resource with the GUI, etc.), then you need to explicity define a Base URI.
From http://www.w3.org/TR/2010/REC-xquery-20101214/#id-base-uri-decl