Querying documents by a full path pattern
JBJacob Borisov19 May 2017 13:27 # Hello. Is it possible to select documents in a database by a path pattern?
For example, there is a database storing following documents:
dir1/a.xml
dir1/b.xml
dir2/a.xml
dir2/b.xml
I want to select documents named 'b.xml' only. I guess something like
db:open('dbname', '*/b.xml')/*
but it returns empty result. Thanks!
CGChristian Grün19 May 2017 13:36 # Quoted text · Jacob Borisov · 1 line
> Hello. Is it possible to select documents in a database by a path pattern?
You can use predicates instead. Examples:
db:open('dbname')[ends-with(db:path(.), '/b.xml')]
db:open('dbname')[matches(db:path(.), '/b\.xml$')]
Hope this helps,
Christian
Quoted text · Jacob Borisov · 12 lines
> For example, there is a database storing following documents:
>
> dir1/a.xml
> dir1/b.xml
> dir2/a.xml
> dir2/b.xml
>
> I want to select documents named 'b.xml' only. I guess something like
>
> db:open('dbname', '*/b.xml')/*
>
> but it returns empty result. Thanks!
⚡Generated with XQuery