Hello list,
I'm trying to map HTML with tabs to \starttabulate in ConTeXt.
A div of class "tabulate" is mapped to a \starttabulate ... \stoptabulate 
section,
p elements are rows and span elements of class "tab" produce \NCs in ConTeXt.
That div element has a "format" attribute that must be passed to 
\starttabulate[...]
to format the columns.

I managed to pass that attribute using lua, but I failed using only ConTeXt:

\startbuffer[test]
<text>
  <div class="tabulate" format="|lw(2cm)|cw(2cm)|rw(2cm)|">
    <p>a<span class="tab"> </span>b<span class="tab"> </span>c</p>
  </div>
</text>
\stopbuffer

\startxmlsetups xml:somesetups
  \xmlsetsetup{#1}{text}{xml:text}
  \xmlsetsetup{#1}{div[@class='tabulate']}{xml:div:tabulate}
  \xmlsetsetup{#1}{div[@class='tabulate']/p}{xml:div:tabulate:p}
  
\xmlsetsetup{#1}{div[@class='tabulate']/p/span[@class='tab']}{xml:div:tabulate:p:tab}
\stopxmlsetups

\xmlregistersetup{xml:somesetups}

\startxmlsetups xml:text
  \indenting[{yes,first,12pt}]
  \xmlflush{#1}
\stopxmlsetups

\setuptabulation[rulethickness=1pt,unit=2pt]

\ctxlua{
function xml.functions.divTabulate(t)
  local format = xml.attribute(t, "", "format")
  context.starttabulate( { format } )
  lxml.flush(t)
  context.stoptabulate()
end
}

\startxmlsetups xml:div:tabulate
%  \xmlfunction{#1}{divTabulate}  % this works!
% the following line can't pass the format correctly to ConTeXt
  \starttabulate[{\xmlatt{#1}{format}}]
    \xmlflush{#1}
  \stoptabulate
\stopxmlsetups

\startxmlsetups xml:div:tabulate:p
  \NC{}\xmlflush{#1}\NC\NR
\stopxmlsetups

\startxmlsetups xml:div:tabulate:p:tab
  \NC{}
\stopxmlsetups

\starttext
  \xmlprocessbuffer{main}{test}{}
\stoptext

I suspect it's a simple mistake of mine.
Thanks in advance,
Massi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

Reply via email to