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

Hans Hagen pragma at wxs.nl
Tue Dec 29 11:09:46 CET 2015


On 12/29/2015 10:14 AM, Thomas A. Schmitz wrote:
> 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?

hard to say without an example but there is probably no setup associated 
to what you flush so does lxml.command (id, pattern, setup) work i.e. 
force a setup to be applied?

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list