Re: [NTG-context] processing xml with lua

2013-03-05 Thread Thomas A. Schmitz
On 03/05/2013 11:11 AM, Hans Hagen wrote: \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

Re: [NTG-context] processing xml with lua

2013-03-05 Thread Hans Hagen
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

Re: [NTG-context] processing xml with lua

2013-03-05 Thread Thomas A. Schmitz
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,

Re: [NTG-context] processing xml with lua

2013-03-05 Thread Hans Hagen
On 3/5/2013 9:47 AM, Thomas A. Schmitz wrote: Hi, may I ask another question about my new favorite topic? No? Anyway: here comes. While processing xml, I would like to store the content of a node in a lua table and retrieve it later. The example is silly, but demonstrates my problem. Is there a

Re: [NTG-context] processing xml with lua

2013-03-05 Thread Thomas A. Schmitz
Hi, may I ask another question about my new favorite topic? No? Anyway: here comes. While processing xml, I would like to store the content of a node in a lua table and retrieve it later. The example is silly, but demonstrates my problem. Is there a way to have ConTeXt process and typeset the

Re: [NTG-context] processing xml with lua

2013-02-26 Thread Schmitz Thomas A.
On Feb 26, 2013, at 1:54 PM, Hans Hagen wrote: > you go up to the parent of sections which to far up, try: > > section = xml.attribute(r, "..", "label", "X") > > or > > section = xml.filter(r, "../attribute(label)") > > Mojca, Hans, thanks, that is exactly right! I wasn't too sure about

Re: [NTG-context] processing xml with lua

2013-02-26 Thread Hans Hagen
On 2/26/2013 1:23 PM, Schmitz Thomas A. wrote: Hi all, one of my favorite topics… Here is a minimal example which shows something that I don't understand: when I process the subsection with the lua code, I want to get the value of the current section's "label" attribute in xml.attribute(r, "..

[NTG-context] processing xml with lua

2013-02-26 Thread Schmitz Thomas A.
Hi all, one of my favorite topics… Here is a minimal example which shows something that I don't understand: when I process the subsection with the lua code, I want to get the value of the current section's "label" attribute in xml.attribute(r, "../../section", "label", "X"). So i was expecting