I am trying to to grab the line and colum number of an expression found with ft:search to better integrate results for dynamic interaction in an XML editor. I was hoping to use saxon:line-number, saxon:character-number, but they are unavailable in BaseX XQuery, only available in xslt:transform. Do you have suggestions on how to extract these details from what's available right now in XQuery?
Hi France - On Sat, Apr 4, 2026, 6:27 AM France Baril via BaseX-Talk < basex-talk@mailman.uni-konstanz.de> wrote:
I am trying to to grab the line and colum number of an expression found with ft:search to better integrate results for dynamic interaction in an XML editor. I was hoping to use saxon:line-number, saxon:character-number, but they are unavailable in BaseX XQuery, only available in xslt:transform. Do you have suggestions on how to extract these details from what's available right now in XQuery?
You might have some luck with wrapping your expression in a try/catch but you'd need to throw some kind of error. The $err:line-number and $err:column-number variables are the first thing that comes to mind. I'm sure someone else has a clever idea though. Hope that's helpful! Best, Bridger
Hi France, Bridger, I don't think `$err:line-number` etc will help as these refer to the XQuery source. Getting line/col locations for nodes in XML sources is something an XML parser could do, but often they don't. I think, this can not be done with BaseX XQuery out-of-the-box. If you are happy writing some Java bridge code, then these links suggest that a SAX parser [1] or specifically Saxonhe 12.5 [2] could help. /Andy [1] https://stackoverflow.com/a/4916212/3210344 [2] https://github.com/xspec/xspec/issues/1971 On Sat, 4 Apr 2026 at 13:19, Bridger Dyson-Smith via BaseX-Talk < basex-talk@mailman.uni-konstanz.de> wrote:
Hi France -
On Sat, Apr 4, 2026, 6:27 AM France Baril via BaseX-Talk < basex-talk@mailman.uni-konstanz.de> wrote:
I am trying to to grab the line and colum number of an expression found with ft:search to better integrate results for dynamic interaction in an XML editor. I was hoping to use saxon:line-number, saxon:character-number, but they are unavailable in BaseX XQuery, only available in xslt:transform. Do you have suggestions on how to extract these details from what's available right now in XQuery?
You might have some luck with wrapping your expression in a try/catch but you'd need to throw some kind of error. The $err:line-number and $err:column-number variables are the first thing that comes to mind. I'm sure someone else has a clever idea though.
Hope that's helpful! Best, Bridger
Andy, Hi and thank you for that observation! I keyed on the initial "expression" and thought it was related to the xquery code, not the (x)queried document(s). Best, Bridger On Sat, Apr 4, 2026, 10:11 AM Andy Bunce <bunce.andy@gmail.com> wrote:
Hi France, Bridger,
I don't think `$err:line-number` etc will help as these refer to the XQuery source. Getting line/col locations for nodes in XML sources is something an XML parser could do, but often they don't.
I think, this can not be done with BaseX XQuery out-of-the-box. If you are happy writing some Java bridge code, then these links suggest that a SAX parser [1] or specifically Saxonhe 12.5 [2] could help.
/Andy
[1] https://stackoverflow.com/a/4916212/3210344 [2] https://github.com/xspec/xspec/issues/1971
On Sat, 4 Apr 2026 at 13:19, Bridger Dyson-Smith via BaseX-Talk < basex-talk@mailman.uni-konstanz.de> wrote:
Hi France -
On Sat, Apr 4, 2026, 6:27 AM France Baril via BaseX-Talk < basex-talk@mailman.uni-konstanz.de> wrote:
I am trying to to grab the line and colum number of an expression found with ft:search to better integrate results for dynamic interaction in an XML editor. I was hoping to use saxon:line-number, saxon:character-number, but they are unavailable in BaseX XQuery, only available in xslt:transform. Do you have suggestions on how to extract these details from what's available right now in XQuery?
You might have some luck with wrapping your expression in a try/catch but you'd need to throw some kind of error. The $err:line-number and $err:column-number variables are the first thing that comes to mind. I'm sure someone else has a clever idea though.
Hope that's helpful! Best, Bridger
participants (3)
-
Andy Bunce -
Bridger Dyson-Smith -
France Baril