[NTG-context] processing lua table in xml...

Thomas A. Schmitz thomas.schmitz at uni-bonn.de
Tue Dec 29 10:14:19 CET 2015


Dear all,

I had asked a similar question some time ago and had received a reply 
from Hans (http://article.gmane.org/gmane.comp.tex.context/81049), but 
the method there doesn't work in this case. Working example difficult, 
hence code snippets, I'm afraid.

I process file A.xml. I pull in stuff from file B.xml and store the 
result as a lua table:

for e in xml.collected(xml.load('B.xml'), 'a') do
    for d in xml.collected(lxml.id(e), 'b') do
       local sortword = xml.attribute(b, "/", "xml:id", "0")
       local entryword = xml.text(b, "entry")
       local translation = xml.first(b, "translation")
       mytable[sortword] = { }
       mytable[sortword]["ew"] = entryword
       mytable[sortword]["tr"] = translation
    end
end

so the table contains the xml. The "translation" part contains further 
nested xml elements. Later, when processing A.xml, I want to retrieve 
this stored xml and have it processed:

local checkword = xml.text(t, "c")
local translation = mytable[checkword]["tr"]

but whatever I try:

lxml.flush(lxml.id(translation))

or

xml.cprint(voktable[myword]["tr"])

or

xml.cprint(translation)

I always get the serialized xml typeset, but not processed. So: how can 
I get context to process the xml that is stored in the table?

All best

Thomas


More information about the ntg-context mailing list