Thanks for the detailed answer.
Our software is developed in .NET. And we use BaseX as a Xquery processor. We use fn:path and return path to error element to user. But it's not enough. Our users are ordinary people, not IT, and they want to see in which lines of xml files there are mistakes. Now after execution of xquery by BaseX our application load xml file (in memory to XDocument object from .NET XML) with specified flag SetLineInfo. Then we execute returned xpath to select node in loaded xml file and get line number of selected node. Then we return line number to user. That is, we have to load the file by .NET only to get the line number. If BaseX could do it itself we wouldn't have to load xml file at all. It would be a great benefit for us.
Is it possible to add some _mode_ in BaseX to store line numbers even with additional memory and undefined line numbers on changed or updated xml nodes?
Пятница, 6 июля 2018, 15:24 +07:00 от Christian Grün christian.gruen@gmail.com:
Hi Symantis,
The original line numbers are not stored in XML databases (they may change after updated, and would consume additional memory), so you won’t be able to retrieve them with XQuery.
As far as I know, this does not work in eXist-db either; the eXist link you referenced gives you the line of the util:line-number expression in your XQuery module. As Fabrice pointed out (thanks!), this could also be realized with $err:line-number.
With Saxon, it works indeed. However, you’ll need you use the -l command line option (otherwise, due to performance considerations, line numbers will be discarded as well).
On query/database level, there are two ways to get a direct reference: • With fn:path, you get an XPath expression that points to your node. • With db:node-pre [1], you get a direct reference to the node in a database.
Best, Christian