> On 4 May 2022, at 22:10, Duncan Hothersall via ntg-context 
> <ntg-context@ntg.nl> wrote:
> Hi.
> I'm processing an XML table and need to set a row span. Because we use a 
> variant of the CALS table model, spans are defined by an attribute saying how 
> many *additional* rows should be spanned, as opposed to how many *in total*. 
> So to translate this into TABLE \bTD[nr=X] syntax I need to add 1.
> I'm guessing this is very easily doable (in lua?) but I've tried various 
> permutations and can't work it out. If anyone could give me a pointer that 
> would be great.
> (In reality I'm going to need to handle lots of other conversions of 
> attribute values into \bTD[...] commands, so if there's a generalised way of 
> doing that sort of thing, or even better if someone has already tackled CALS 
> tables in this way, that would also be great!)

Not CALS, but I do a lot of HTML table processing. I find it all much easier on 
the lua side, because there the 
attributes are just in a table entry of the argument node t ( t.at ):

set up a lua function in the setups:

\startxmlsetups xml:demo:base
 \xmlsetfunction {\xmldocument}{entry}{userdata.xmlfunctions.entry}

and then add this lua code:

userdata.xmlfunctions = {}
function userdata.xmlfunctions.entry (t)
  local rows = (t.at.morerows or 1) + 1

All of the tex-side commands also exist in lua, in the lxml and/or xml table, 

direct output flushing: 
  lxml.all(t, ‘entry’)

filter for processing:
  for b in xml.collected(lxml.getid(t),'../row/entry') do … end

(those are the ones I use a lot, there are many more)

Best wishes,
If your question is of interest to others as well, please add an entry to the 

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

Reply via email to