Saxon functions in XQuery or alternatives

Saturday, 4 April 2026 · 4 messages
FB
France Baril4 Apr 2026 12:27 #
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?
BD
Bridger Dyson-Smith4 Apr 2026 14:19 #
Hi France -
Quoted text · France Baril · 10 lines
On Sat, Apr 4, 2026, 6:27 AM France Baril via BaseX-Talk < basex-talk at 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
Quoted text · France Baril · 2 lines
> >
AB
Andy Bunce4 Apr 2026 16:11 #
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
Quoted text · Bridger Dyson-Smith · 27 lines
On Sat, 4 Apr 2026 at 13:19, Bridger Dyson-Smith via BaseX-Talk < basex-talk at mailman.uni-konstanz.de> wrote: > Hi France - > > On Sat, Apr 4, 2026, 6:27 AM France Baril via BaseX-Talk < > basex-talk at 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 > >> >>
BD
Bridger Dyson-Smith4 Apr 2026 16:55 #
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
Quoted text · Andy Bunce · 48 lines
On Sat, Apr 4, 2026, 10:11 AM Andy Bunce <bunce.andy at 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 at mailman.uni-konstanz.de> wrote: > >> Hi France - >> >> On Sat, Apr 4, 2026, 6:27 AM France Baril via BaseX-Talk < >> basex-talk at 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 >> >>> >>>

⚡Generated with XQuery