> Hello list, > is there a Lua function to get the XML path of an element as a > string? >
Found. I adapted a function from lxml-tex.lua (chainpath): function xmlpath( e, nonamespace ) if e then local t = { } while e do local tg = e.tg local rt = e.__p__ local ns = e.ns if tg == "@rt@" then break elseif rt.tg == "@rt@" then if nonamespace or not ns or ns == "" then t[ #t + 1 ] = tg else t[ #t + 1 ] = ns .. ":" .. tg end else if nonamespace or not ns or ns == "" then t[ #t + 1 ] = tg .. "[" .. e.ei .. "]" else t[ #t + 1 ] = ns .. ":" .. tg .. "[" .. e.ei .. "]" end end e = rt end return table.concat( table.reverse( t ), "/" ) else return "" end end ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________