I am just getting started on using BaseX. For that I downloaded basex97.zip and extracted it. My xml data files reside in a directory I will call DATA, and in there are multiple directories with the XMLs sitting on different levels.
I started BaseX by doubleclicking the BaseX.jar, and the GUI came up.
In the left of the Editor window I configured my DATA directory. A tree view allows me to see the correct directory structure. Then I configured the filename filter to be *.xml
, and an additional list view shows me that BaseX found the files I want.
Next I tried to write some queries, and trivial ones work: If I put <test/>
into the editor and execture, the Result window will show the expected output.
But how do I take it from here? Actually I want to run a queries like //text
and would assume BaseX to go through all the XML files and return all elements named text
- regardless in which file or at which position in the file it is found.
So I was able to figure out the correct query. The main part was that I had to use a collection configured with the full path to my documents like so:
let $collection := collection("/full/path/to/DATA")
for $t in $collection//text
return $t
This seems to return the expected data. I will now focus on creating better FLOWR statements.