On 3/5/2013 10:16 AM, Thomas A. Schmitz wrote:
On 03/05/2013 09:58 AM, Hans Hagen wrote:
lookuptable[mytype] = mytype .. " = " .. myvalue
inspect(lookuptable)
the .. triggers a tostring on myvalue which in turn serializes the xml
lookuptable[mytype] = { mytype = myvalue }
would keep myvalue as xml node
Hans, thanks a lot, the explanation makes sense, but your suggestion is
not yet clear enough for me: how would I then process the node?
context(lookuptable[mytype]["mytype"])
gives again the serialized xml.
\startluacode
local lookuptable = { }
function xml.functions.lookup(t)
local mytype = xml.text(t, "c")
local myvalue = lookuptable[mytype]
if not myvalue then
myvalue = xml.first(t, "d")
lookuptable[mytype] = myvalue
context("registered: ")
else
context("reused: ")
end
-- each found node gets an id
lxml.flush(lxml.id(myvalue))
context(" or ")
-- in tex mode a to-tex serializer is the default
xml.cprint(myvalue)
end
\stopluacode
One place to look for tricks is in x-mathml.mkiv / lua (I know, I should
finish that manual).
Hans
-----------------------------------------------------------------
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________