Might not be difficult, but i cannot find the correct command and syntax:
I have a BaseX database opened that holds several XML documents:
/document-uri()
looks like this
/dirA/dirA1/x01.xml
/dirA/dirA1/x02.xml
/dirA/dirA2/x03.xml
/dirA/dirA3/dirA31/x04.xml
/dirA/dirA3/dirA31/x05.xml
/dirA/dirA3/dirA32/x06.xml
/dirB/dirB1/x07.xml
/dirB/dirB2/x08.xml
/dirC/dirC1/x09.xml
/dirC/dirC2/dirC11/x10.xml
/dirD/dirD1/dirD11/x11.xml
/dirE/dirE1/dirE11/x12.xml
What i am looking for is a XQuery to select a document by URI and use it as XPath context, s.th. like this:
document("/dirA/dirA1/x01.xml")/root/foo
Another one would be super useful as well: select all documents in a dir path (recursively:))
document("/dirA/dirA1/")/root/foo
There is a
doc
function sodoc('/dirA/dirA1/x01.xml')
should select the document. There is also thecollection
function which probably allows you to selectcollection('/dirA/dirA1')
, the exact use of the collection function is depending on the XQuery processor and e.g. how you set up your DB in BaseX.So basically the
doc
and thecollection
functions should help in XQuery. Only XSLT has a function nameddocument
you have used in your samples.