How to check if a node is from a database
Saturday, 8 October 2022 · 2 messages
HR
Hans-Jürgen Rennau8 Oct 2022 01:44 #
Dear BaseX people,
what would be an efficient way of checking if a given node is a database node?
According to the documentation, function
db:name() throws an error if the node is not a database node. However, that is not what I observe.(The same applies to db:node-id(), db:node-pre(), db:path()). Therefore I resorted to this way of checking:
try {db:name($node) ! db:exists(.)} catch * {false()}
That is clumsy and unreliable: if applied to a node in a file, db:name() returns the base name of the file, which might accidentally be a database name.
What would you recommend instead?
Kind regards,
Hans-JürgenCG
Christian Grün8 Oct 2022 06:48 #
Good evening/morning Hans-Jürgen,
Thanks for the observation, I have uploaded a new snapshot.
BaseX 10.3 will be released next week.
Cheers,
Christian
[1] https://files.basex.org/releases/latest/
Written for BaseX 10.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery