Hello BaseX team, First of all, thank you for giving such a tremendous effort to help BaseX users, we appreciate it.
We’re developing an application that has the sole use of exchanging XML messages with other clients, we chose BaseX to store messages in their xml format and used its RESTful APIs to update the database. Currently storing data in one xml document in one database, but this is not efficient because with time the document will be very large, thus storing and retrieving data from it will take more time.
* Can I select a number of xml nodes from the document without the rest? For example returning only the last 200 xml messages ? if yes how to make it happen with REST methods?
I thought about the solution of using multiple documents, so there is the possibility of retrieving data from one document at a time, but didn’t find a way to make this process automatic because there are number of issues I didn’t find a solution for:
* How can the application know the number and names of existing documents in the database , didn’t find an xquery for this.
Can you suggest better solutions ?
Thank you.
P Respectons ensemble l'environnement. N'imprimez ce message que si nécessaire. Let's respect the environment together. Only print this message if necessary.
Dear Ramzi,
Can I select a number of xml nodes from the document without the rest? For example returning only the last 200 xml messages ? if yes how to make it happen with REST methods?
If you want to limit your results to the first 200 XML documents, you can e.g. attach an XQuery string as query parameter:
http://localhost:8984/rest/your-db?query=subsequence(.,1,200)"
If all elements are stored in a single database, just replace the "." (which refers to the documents of your database) with a path expression:
http://localhost:8984/rest/your-db?query=subsequence(/path/to/your/result/no...)"
A wildcard step (* or */*) may already be sufficient to access all root nodes of a document.
How can the application know the number and names of existing documents in the database , didn’t find an xquery for this.
The number of documents can be retrieved with the count function, and db:path is helpful for requesting the document paths:
http://localhost:8984/rest/your-db?query=count(.) http://localhost/rest/NYT-1987?query=subsequence(.,1,200)!db:path(.)"
The BaseX GUI is probably the best place to write your XPath queries. If the results are satisfying, you can dispatch them via REST.
Hope this helps, Christian
basex-talk@mailman.uni-konstanz.de