Yes, fn:path (not fn:node)! the following works
<fas><nom>this is an example</nom></fas>/nom/fn:path(.) with the useful result Q{http://www.w3.org/2005/xpath-functions}root()/Q{}nom[1] but the following does not (because tokenize() does not return a node) <fas><nom>this is an example</nom></fas>/tokenize(nom, " ")/fn:path(.) what I was looking for is a function returning something like <t path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}nom[1]" start="0" end="3">this</t> <t path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}nom[1]" start="5" end="6">is</t> <t path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}nom[1]" start="8" end="9">an</t> <t path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}nom[1]" start="11" end="17">example</t> > On Jul 6, 2018, at 1:39 PM, Christian Grün <christian.gr...@gmail.com> wrote: > > Hi Giuseppe, > >> fn:node() returns the path to a node (including the text node): Is there a >> similar function to get character offsets within a text node? > > I am not sure what you need. Do you talk about fn:path? What could the > character offset be / do you have an example? > > Grazie, > Christian > > > >> On Jul 6, 2018, at 10:24 AM, Christian Grün <christian.gr...@gmail.com> >> wrote: >> >> 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 >> >> [1] http://docs.basex.org/wiki/Database_Module#db:node-id >> >> >> On Thu, Jul 5, 2018 at 5:49 PM Fabrice ETANCHAUD >> <fetanch...@pch.cerfrance.fr> wrote: >> >> >> As BaseX does not work on the XML textual representation, it might not be >> possible. >> >> >> >> >> >> De : BaseX-Talk [mailto:basex-talk-boun...@mailman.uni-konstanz.de] De la >> part de ????? ?????? >> Envoyé : jeudi 5 juillet 2018 17:10 >> À : basex-talk@mailman.uni-konstanz.de >> Objet : [basex-talk] Add line-number function >> >> >> >> >> >> >> >> Hello, could the $err:line-number [1] variable help you ? >> >> [1] http://docs.basex.org/wiki/XQuery_3.0#Try.2FCatch >> >> Best regards, >> >> Fabrice ETANCHAUD >> cerfrancepch >> >> No, $err:line-number show line number of xquery file. >> I want this: >> >> Example.xml -> >> 1: <root> >> 2: <child> >> 3: <grandchild>text1</grandchild> >> 4: <grandchild>text2</grandchild> >> 5: <grandchild>text3</grandchild> >> 6: <grandchild>text4</grandchild> >> 7: </child> >> 8: </root> >> >> Xquery -> >> let $f := doc("example.xml") >> let $e := $f/root/child[1]/grandchild[3] >> >> let $line := line-number($e) >> >> And I want get $line = 5 ! >> >> >> >