From 5b7c7a51f408dbcce2a0926948c47e5bf045ed3d Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Tue, 28 May 2013 00:36:00 +0200
Subject: stable 2013.05.28 00:36

---
 tex/context/base/cont-new.mkiv                     |   2 +-
 tex/context/base/cont-new.tmp                      |  83 ++++
 tex/context/base/context-version.pdf               | Bin 4112 -> 4111 bytes
 tex/context/base/context.mkiv                      |   4 +-
 tex/context/base/context.tmp                       | 513 +++++++++++++++++++++
 tex/context/base/lxml-ini.mkiv                     |   4 +-
 tex/context/base/m-sql.mkiv                        |  17 +
 tex/context/base/s-sql-tables.lua                  | 152 ++++++
 tex/context/base/status-files.pdf                  | Bin 24683 -> 24734 bytes
 tex/context/base/status-lua.pdf                    | Bin 212075 -> 212009 bytes
 tex/context/base/status-mkiv.lua                   |  30 ++
 tex/context/base/tabl-ntb.mkiv                     |   4 +-
 tex/context/base/tabl-xtb.mkvi                     |  55 ++-
 tex/context/base/x-cals.lua                        |  10 +-
 tex/context/base/x-cals.mkiv                       |   2 +-
 tex/context/base/x-mathml.mkiv                     |   2 +
 tex/generic/context/luatex/luatex-fonts-merged.lua |   2 +-
 17 files changed, 841 insertions(+), 39 deletions(-)
 create mode 100644 tex/context/base/cont-new.tmp
 create mode 100644 tex/context/base/context.tmp
 create mode 100644 tex/context/base/m-sql.mkiv
 create mode 100644 tex/context/base/s-sql-tables.lua

diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index b5eae93e3..7f241e357 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2013.05.27 11:04}
+\newcontextversion{2013.05.28 00:36}
 
 %D This file is loaded at runtime, thereby providing an excellent place for
 %D hacks, patches, extensions and new features.
diff --git a/tex/context/base/cont-new.tmp b/tex/context/base/cont-new.tmp
new file mode 100644
index 000000000..5d4fcd60a
--- /dev/null
+++ b/tex/context/base/cont-new.tmp
@@ -0,0 +1,83 @@
+%D \module
+%D   [       file=cont-new,
+%D        version=1995.10.10,
+%D          title=\CONTEXT\ Miscellaneous Macros,
+%D       subtitle=New Macros,
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\newcontextversion{2013.05.28 00:34}
+
+%D This file is loaded at runtime, thereby providing an excellent place for
+%D hacks, patches, extensions and new features.
+
+\unprotect
+
+% \writestatus\m!system{beware: some patches loaded from cont-new.mkiv}
+
+% \attribute152\zerocount : marks ... lots of sweeps so best early in list
+
+%D Maybe:
+
+\unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox}
+\unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop}
+
+%D Maybe:
+
+% \startluacode
+% function context.loadfile(filename)
+%     context(string.strip(io.loaddata(resolvers.findfile(filename))))
+% end
+% \stopluacode
+%
+% \edef\tufte{\cldcommand{loadfile("tufte.tex")}}
+
+%D Needs some work:
+
+\unexpanded\def\startgridcorrection
+  {\dosingleempty\spac_grid_correction_start}
+
+\def\spac_grid_correction_start[#1]%
+  {\ifgridsnapping
+     \snaptogrid[#1]\vbox\bgroup
+   \else
+     \startbaselinecorrection
+   \fi}
+
+\unexpanded\def\stopgridcorrection
+  {\ifgridsnapping
+     \egroup
+   \else
+     \stopbaselinecorrection
+   \fi}
+
+\unexpanded\def\checkgridsnapping
+  {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi}
+
+%D Probably obsolete:
+
+\unexpanded\def\startcolumnmakeup % don't change
+  {\bgroup
+   \getrawnoflines\textheight % raw as we cna have topskip
+   \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax
+     \bgroup
+     \forgetall}
+
+\unexpanded\def\stopcolumnmakeup
+  {\egroup
+   \dp\scratchbox\zeropoint
+   \wd\scratchbox\textwidth
+   \box\scratchbox
+   \egroup
+   \page_otr_command_synchronize_hsize}
+
+%D Till we fixed all styles:
+
+\let\\=\crlf
+
+\protect \endinput
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index d51f48fba..1c70a39fc 100644
Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 3fed26db3..eaa431122 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -25,8 +25,8 @@
 %D up and the dependencies are more consistent.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2013.05.27 19:11}
-\edef\contextkind   {beta}
+\edef\contextversion{2013.05.28 00:36}
+\edef\contextkind   {current}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/context.tmp b/tex/context/base/context.tmp
new file mode 100644
index 000000000..7976b4641
--- /dev/null
+++ b/tex/context/base/context.tmp
@@ -0,0 +1,513 @@
+%D \module
+%D   [       file=context,
+%D        version=2008.28.10, % 1995.10.10,
+%D          title=\CONTEXT,
+%D       subtitle=\CONTEXT\ Format Generation,
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\catcode`\{=1 \catcode`\}=2 \catcode`\#=6
+
+%D From the next string (which is set by the script that assembles the
+%D distribution) later on we will calculate a number that can be used
+%D by use modules to identify the feature level. Starting with version
+%D 2004.8.30 the low level interface is english. Watch out and adapt
+%D your styles an modules.
+
+% \everypar{\writestatus{!!!!}{some spurious input in line \the\inputlineno}\wait}
+
+%D The order of loading will change when all modules have been cleaned
+%D up and the dependencies are more consistent.
+
+\edef\contextformat {\jobname}
+\edef\contextversion{2013.05.28 00:34}
+\edef\contextkind   {beta}
+
+%D For those who want to use this:
+
+\let\fmtname   \contextformat
+\let\fmtversion\contextversion
+
+%D Loading:
+
+\edef\mksuffix   {mkiv}
+\edef\contextmark{MKIV}
+
+\ifx\normalinput\undefined \let\normalinput\input \fi
+
+\def\loadcorefile#1{\normalinput#1\relax}
+\def\loadmarkfile#1{\normalinput#1.\mksuffix\relax}
+\def\loadmkiifile#1{}
+\def\loadmkivfile#1{\normalinput#1.mkiv\relax}
+\def\loadmkvifile#1{\normalinput#1.mkvi\relax}
+
+%D First we load the system modules. These implement a lot of
+%D manipulation macros. We start with setting up some basic \TEX\
+%D machinery.
+
+\loadmarkfile{syst-ini}
+
+%D Some checking (more primitives are now defined):
+
+\ifdefined\defaultinterface   \else \def\defaultinterface  {english}         \fi
+%ifdefined\messageinterface   \else \let\messageinterface  \defaultinterface \fi
+\ifdefined\defaultlanguagetag \else \def\defaultlanguagetag{en}              \fi
+
+%D We just quit if new functionality is expected.
+
+\ifnum\luatexversion<70 % also change message
+    \writestatus{!!!!}{Your luatex binary is too old, you need at least version 0.70!}
+    \expandafter\end
+\fi
+
+%D There is only this way to pass the version info to \LUA\ (currently). Hm, we could
+%D now put it into the environment.
+
+\newtoks\contextversiontoks \contextversiontoks\expandafter{\contextversion}
+\newtoks\contextkindtoks    \contextkindtoks   \expandafter{\contextkind}
+
+% \normaleverypar{\wait} % uncomment for test of funny injections
+
+%D Now the more fundamental code gets defined.
+
+\loadmarkfile{norm-ctx}
+\loadmarkfile{syst-pln}
+\loadmarkfile{syst-mes}
+
+\loadmarkfile{luat-cod}
+\loadmarkfile{luat-bas}
+\loadmarkfile{luat-lib}
+
+\loadmarkfile{catc-ini}
+\loadmarkfile{catc-act}
+\loadmarkfile{catc-def}
+\loadmarkfile{catc-ctx}
+\loadmarkfile{catc-sym}
+
+\loadmarkfile{cldf-ini}
+
+% From here on we have \unexpanded being \normalprotected, as we already had
+% \unexpanded long before etex came around.
+
+\loadmarkfile{syst-aux}
+\loadmarkfile{syst-lua}
+\loadmarkfile{syst-con}
+
+\loadmarkfile{syst-fnt}
+\loadmarkfile{syst-rtp}
+
+\loadmkvifile{file-ini}
+\loadmkvifile{file-res}
+\loadmkvifile{file-lib}
+
+\loadmarkfile{supp-dir}
+
+\loadmarkfile{char-ini}
+\loadmarkfile{char-utf}
+\loadmarkfile{char-act}
+
+\loadmarkfile{mult-ini}
+\loadmarkfile{mult-sys}
+\loadmarkfile{mult-aux}
+\loadmarkfile{mult-def}
+\loadmarkfile{mult-chk}
+%loadmarkfile{mult-aux} % moved up
+\loadmkvifile{mult-dim}
+
+\loadmarkfile{cldf-int} % interface
+
+\loadmarkfile{luat-ini}
+
+\loadmarkfile{toks-ini}
+
+\loadmarkfile{attr-ini}
+
+\loadmarkfile{core-ini}
+\loadmarkfile{core-env}
+
+\loadmarkfile{layo-ini}
+
+\loadmarkfile{node-ini}
+
+\loadmarkfile{cldf-bas} % basics / depends on nodes
+
+\loadmarkfile{node-fin}
+\loadmarkfile{node-mig}
+\loadmarkfile{typo-bld} % par builders
+%loadmarkfile{node-pag}
+
+\loadmarkfile{back-ini}
+
+\loadmarkfile{attr-col}
+\loadmarkfile{attr-lay}
+\loadmarkfile{attr-neg}
+\loadmarkfile{attr-eff}
+\loadmarkfile{attr-mkr}
+
+\loadmarkfile{trac-tex}
+\loadmarkfile{trac-deb} % will move up
+\loadmarkfile{trac-ctx} % maybe move up
+
+%loadmarkfile{blob-ini} % not to be used, we only use a helper
+
+\loadmarkfile{supp-box}
+
+%loadmarkfile{supp-vis} % replaced by trac-vis
+%loadmarkfile{supp-fun} % mostly replaced
+
+\loadmarkfile{supp-ran}
+\loadmarkfile{supp-mat}
+\loadmarkfile{spac-cha}
+%loadmarkfile{supp-num} % obsolete
+
+\loadmarkfile{typo-ini}
+
+\loadmkvifile{file-syn}
+\loadmkvifile{file-mod}
+
+\loadmarkfile{core-con}
+
+\loadmarkfile{cont-fil}
+
+\loadmarkfile{regi-ini}
+\loadmarkfile{enco-ini}
+\loadmarkfile{hand-ini}
+
+\loadmarkfile{lang-ini}
+\loadmarkfile{lang-lab}
+
+\loadmarkfile{unic-ini}
+
+\loadmarkfile{core-uti}
+\loadmarkfile{core-two}
+\loadmarkfile{core-dat}
+
+\loadmarkfile{colo-ini}
+\loadmarkfile{colo-grp} % optional
+\loadmarkfile{colo-ext}
+
+\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented)
+
+\loadmarkfile{pack-cut} % leftovers from trac-vis
+
+\loadmarkfile{lang-mis}
+\loadmarkfile{lang-url}
+\loadmarkfile{lang-def}
+
+\loadmkvifile{file-job} % why so late?
+
+\loadmarkfile{symb-ini} % brrr depends on fonts
+
+\loadmarkfile{sort-ini}
+
+\loadmkvifile{pack-mis}
+\loadmarkfile{pack-rul}
+\loadmarkfile{pack-mrl}
+\loadmkvifile{pack-bck}
+\loadmarkfile{pack-fen}
+
+\loadmarkfile{lxml-ini}
+\loadmarkfile{lxml-sor}
+
+\loadmkvifile{typo-prc}
+
+\loadmkvifile{strc-ini}
+\loadmarkfile{strc-tag}
+\loadmarkfile{strc-doc}
+\loadmarkfile{strc-num}
+\loadmarkfile{strc-mar}
+\loadmarkfile{strc-sbe}
+\loadmkvifile{strc-lst}
+\loadmarkfile{strc-sec}
+\loadmarkfile{strc-pag} % hm, depends on core-num
+\loadmarkfile{strc-ren}
+\loadmarkfile{strc-xml}
+\loadmarkfile{strc-def} % might happen later
+\loadmkvifile{strc-ref}
+\loadmarkfile{strc-reg}
+\loadmkvifile{strc-lev} % experiment
+
+\loadmarkfile{spac-ali}
+\loadmarkfile{spac-hor}
+\loadmarkfile{spac-flr}
+\loadmarkfile{spac-ver}
+\loadmarkfile{spac-lin}
+\loadmarkfile{spac-pag}
+\loadmarkfile{spac-par}
+%loadmarkfile{spac-adj} % no longer needed
+\loadmarkfile{spac-def}
+\loadmarkfile{spac-grd}
+
+\loadmarkfile{anch-pos}
+
+\loadmkvifile{scrn-ini}
+\loadmkvifile{scrn-ref}
+
+\loadmarkfile{pack-obj}
+
+\loadmkvifile{strc-itm}
+
+\loadmkvifile{strc-con}
+\loadmkvifile{strc-des}
+\loadmkvifile{strc-enu}
+
+\loadmarkfile{strc-ind}
+\loadmarkfile{strc-lab}
+\loadmarkfile{strc-syn}
+
+\loadmarkfile{core-sys}
+
+\loadmarkfile{page-var}
+\loadmkvifile{page-otr}
+\loadmarkfile{page-ini}
+\loadmarkfile{page-ins}
+\loadmarkfile{page-fac}
+\loadmarkfile{page-brk}
+\loadmarkfile{page-col}
+\loadmarkfile{page-inf}
+\loadmarkfile{page-grd}
+\loadmarkfile{page-flt}
+\loadmarkfile{page-bck}
+\loadmarkfile{page-not}
+\loadmarkfile{page-one}
+\loadmarkfile{page-lay}
+\loadmkvifile{page-box}
+\loadmkvifile{page-txt}
+\loadmarkfile{page-sid} % when
+
+\loadmkvifile{strc-flt}
+
+\loadmarkfile{page-pst}
+\loadmkvifile{page-mbk}
+\loadmarkfile{page-mul} % partly overloaded
+\loadmarkfile{page-mix} % new
+\loadmarkfile{page-set}
+\loadmarkfile{pack-lyr}
+\loadmarkfile{pack-pos}
+\loadmkvifile{page-mak}
+
+\loadmarkfile{page-lin}
+\loadmarkfile{page-par}
+\loadmarkfile{typo-pag}
+\loadmarkfile{typo-mar}
+\loadmarkfile{typo-itm}
+
+\loadmarkfile{buff-ini}
+\loadmarkfile{buff-ver}
+\loadmkvifile{buff-par}
+
+\loadmarkfile{buff-imp-tex}        % optional as also runtime if not loaded
+\loadmarkfile{buff-imp-mp}         % optional as also runtime if not loaded
+\loadmarkfile{buff-imp-lua}        % optional as also runtime if not loaded
+\loadmarkfile{buff-imp-xml}        % optional as also runtime if not loaded
+
+\loadmarkfile{buff-imp-parsed-xml} % optional
+%loadmarkfile{buff-imp-parsed-lua} % optional
+
+\loadmarkfile{strc-blk}
+
+\loadmarkfile{page-imp}
+\loadmkvifile{page-sel} % optional
+\loadmkvifile{page-inj} % optional
+
+\loadmkvifile{scrn-pag}
+\loadmkvifile{scrn-wid}
+\loadmkvifile{scrn-but}
+\loadmkvifile{scrn-bar}
+
+\loadmarkfile{page-com} % optional (after scrn-pag)
+
+\loadmarkfile{strc-bkm} % bookmarks
+
+\loadmarkfile{tabl-com}
+\loadmarkfile{tabl-pln}
+
+\loadmarkfile{tabl-tab} % thrd-tab stripped and merged
+
+\loadmarkfile{tabl-tbl}
+\loadmarkfile{tabl-ntb}
+\loadmarkfile{tabl-nte}
+\loadmarkfile{tabl-ltb}
+\loadmarkfile{tabl-tsp}
+\loadmkvifile{tabl-xtb}
+\loadmarkfile{tabl-mis}
+
+\loadmarkfile{java-ini}
+
+\loadmkvifile{scrn-fld}
+\loadmkvifile{scrn-hlp}
+
+\loadmarkfile{char-enc} % will move up
+
+\loadmkvifile{font-lib} % way too late
+\loadmkvifile{font-fil}
+\loadmkvifile{font-var}
+\loadmkvifile{font-fea}
+\loadmkvifile{font-mat}
+\loadmkvifile{font-ini}
+\loadmkvifile{font-sym}
+\loadmkvifile{font-sty}
+\loadmkvifile{font-set}
+\loadmkvifile{font-emp}
+\loadmarkfile{font-pre}
+\loadmarkfile{font-unk}
+\loadmarkfile{font-tra}
+\loadmarkfile{font-chk}
+\loadmarkfile{font-uni}
+\loadmkvifile{font-col}
+\loadmkvifile{font-gds}
+\loadmkvifile{font-aux}
+
+\loadmarkfile{typo-lan}
+
+\loadmarkfile{lxml-css}
+
+\loadmarkfile{spac-chr} % depends on fonts
+
+\loadmarkfile{blob-ini} % not to be used, we only use a helper
+
+\loadmarkfile{trac-vis}
+\loadmarkfile{trac-jus}
+
+\loadmarkfile{typo-cln}
+\loadmarkfile{typo-spa}
+\loadmarkfile{typo-krn}
+\loadmkvifile{typo-itc}
+\loadmarkfile{typo-dir}
+\loadmarkfile{typo-brk}
+\loadmarkfile{typo-cap}
+\loadmarkfile{typo-dig}
+\loadmarkfile{typo-rep}
+\loadmkvifile{typo-txt}
+\loadmarkfile{typo-par}
+
+\loadmkvifile{type-ini}
+\loadmarkfile{type-set}
+
+\loadmarkfile{scrp-ini}
+
+\loadmarkfile{lang-wrd} % can be optional (discussion with mm sideeffect)
+%loadmarkfile{lang-rep} % can be optional (bt 2013 side effect)
+
+\loadmarkfile{prop-ini} % only for downward compatibility
+
+\loadmarkfile{mlib-ctx}
+
+\loadmarkfile{meta-ini}
+\loadmarkfile{meta-tex}
+\loadmarkfile{meta-fun}
+\loadmarkfile{meta-pag}
+\loadmarkfile{meta-grd}
+
+\loadmarkfile{page-mrk} % depends on mp
+
+\loadmarkfile{page-flw}
+\loadmarkfile{page-spr}
+\loadmarkfile{page-plg}
+\loadmarkfile{page-str}
+
+\loadmarkfile{anch-pgr} % can be moved up (nicer for dependencies)
+\loadmkvifile{anch-bck}
+\loadmarkfile{anch-tab} % overloads tabl-tbl
+\loadmarkfile{anch-bar}
+%loadmarkfile{anch-snc} % when needed this one will be redone
+
+\loadmarkfile{math-ini}
+\loadmarkfile{math-pln}
+\loadmarkfile{math-for}
+\loadmarkfile{math-def}
+\loadmarkfile{math-ali}
+%loadmarkfile{math-arr}
+\loadmkvifile{math-stc}
+\loadmarkfile{math-frc}
+\loadmarkfile{math-mis}
+\loadmarkfile{math-scr}
+\loadmarkfile{math-int}
+\loadmarkfile{math-del}
+\loadmarkfile{math-fen}
+\loadmarkfile{math-inl}
+\loadmarkfile{math-dis}
+%loadmarkfile{math-lan}
+
+\loadmarkfile{phys-dim}
+
+\loadmarkfile{strc-mat}
+
+\loadmarkfile{chem-ini}
+\loadmarkfile{chem-str}
+
+\loadmarkfile{typo-scr}
+
+\loadmarkfile{node-rul}
+\loadmkvifile{font-sol} % font solutions
+
+\loadmkvifile{strc-not}
+\loadmkvifile{strc-lnt}
+
+\loadmarkfile{pack-com}
+\loadmarkfile{typo-del}
+
+\loadmarkfile{grph-trf}
+\loadmarkfile{grph-inc}
+\loadmarkfile{grph-fig}
+\loadmarkfile{grph-raw}
+
+\loadmarkfile{pack-box}
+\loadmarkfile{pack-bar}
+\loadmarkfile{page-app}
+\loadmarkfile{meta-fig}
+
+\loadmarkfile{lang-spa} % will become obsolete
+
+\loadmarkfile{bibl-bib}
+\loadmarkfile{bibl-tra}
+
+%loadmarkfile{x-xtag}  % no longer preloaded
+
+\loadmarkfile{meta-xml}
+
+\loadmarkfile{cont-log}
+
+\loadmarkfile{task-ini}
+
+\loadmarkfile{cldf-ver} % verbatim, this can come late
+\loadmarkfile{cldf-com} % commands, this can come late
+
+\loadmarkfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace
+
+\loadmarkfile{core-def}
+
+%usemodule[x][res-04] % xml resource libraries
+%usemodule[x][res-08] % rlx runtime conversion
+%usemodule[x][res-12] % rli external indentification
+
+% now we hook in backend code (needs checking)
+
+\loadmarkfile{back-pdf} % actually, this one should load the next three using document.arguments.backend
+\loadmarkfile{mlib-pdf}
+\loadmarkfile{mlib-pps}
+\loadmarkfile{meta-pdf}
+\loadmarkfile{grph-epd}
+
+\loadmarkfile{back-exp}
+
+\setupcurrentlanguage[\defaultlanguagetag]
+
+\prependtoks
+    \ctxlua{statistics.starttiming(statistics)}%
+\to \everyjob
+
+\appendtoks
+    \ctxlua{statistics.stoptiming(statistics)}%
+\to \everyjob
+
+\appendtoks
+    \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv","\contextkind")}% can become automatic
+\to \everydump
+
+\errorstopmode \dump \endinput
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index 8889d906b..d2d64aa8d 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -74,8 +74,8 @@
 \def\xmlremapname    #1#2#3#4{\ctxlua{xml.remapname(lxml.id("#1"),"#2","#3","#4")}}  % element
 \def\xmlremapnamespace #1#2#3{\ctxlua{xml.renamespace(lxml.id("#1"),"#2","#3")}}    % document
 \def\xmlchecknamespace #1#2#3{\ctxlua{xml.checknamespace(lxml.id("#1"),"#2","#3")}} % element
-\def\xmlsetfunction    #1#2#3{\ctxlxml{setaction("#1","#2",#3)}}
-\def\xmlsetsetup       #1#2#3{\ctxlxml{setsetup("#1","#2","#3")}}
+\def\xmlsetfunction    #1#2#3{\ctxlxml{setaction("#1",\!!bs#2\!!es,#3)}}
+\def\xmlsetsetup       #1#2#3{\ctxlxml{setsetup("#1",\!!bs#2\!!es,"#3")}}
 \def\xmlstrip            #1#2{\ctxlxml{strip("#1","#2")}}
 \def\xmlstripnolines     #1#2{\ctxlxml{strip("#1","#2",true)}}
 \def\xmlstripanywhere    #1#2{\ctxlxml{strip("#1","#2",true,true)}}
diff --git a/tex/context/base/m-sql.mkiv b/tex/context/base/m-sql.mkiv
new file mode 100644
index 000000000..60cbdd1be
--- /dev/null
+++ b/tex/context/base/m-sql.mkiv
@@ -0,0 +1,17 @@
+%D \module
+%D   [       file=m-sql,
+%D        version=2012.07.12,
+%D          title=\CONTEXT\ Extra Modules,
+%D       subtitle=SQL,
+%D         author=Hans Hagen,
+%D           date=\currentdate,
+%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\registerctxluafile{util-tpl}{}
+\registerctxluafile{util-sql}{}
+
+\endinput
diff --git a/tex/context/base/s-sql-tables.lua b/tex/context/base/s-sql-tables.lua
new file mode 100644
index 000000000..434103541
--- /dev/null
+++ b/tex/context/base/s-sql-tables.lua
@@ -0,0 +1,152 @@
+if not modules then modules = { } end modules ['s-languages-counters'] = {
+    version   = 1.001,
+    comment   = "companion to s-languages-counters.mkiv",
+    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+    copyright = "PRAGMA ADE / ConTeXt Development Team",
+    license   = "see context related readme files"
+}
+
+require("util-tpl")
+require("util-sql")
+require("util-sql-tracers")
+
+moduledata            = moduledata            or { }
+moduledata.sql        = moduledata.sql        or { }
+moduledata.sql.tables = moduledata.sql.tables or { }
+
+local context = context
+
+function moduledata.sql.showfields(specification) -- not that sql specific
+    local data = specification.data
+    if data and #data > 0 then
+        local keys = specification.order or table.sortedkeys(data[1])
+        local align = specification.align
+        local template = "|"
+        if type(align) == "table" then
+            for i=1,#keys do
+                template = template .. (align[keys[i]] or "c") .. "|"
+            end
+        else
+            template = template .. string.rep((align or "c").. "|",#keys)
+        end
+        context.starttabulate { template }
+        context.NC()
+        for i=1,#keys do
+            context(keys[i])
+            context.NC()
+        end
+        context.NR()
+        context.HL()
+        for i=specification.first or 1,specification.last or #data do
+            local d = data[i]
+            context.NC()
+            for i=1,#keys do
+                context(d[keys[i]])
+                context.NC()
+            end
+            context.NR()
+        end
+        context.stoptabulate()
+    end
+end
+
+function moduledata.sql.validpresets(presets)
+    local okay = true
+    if presets.database == "" then
+        context("No database given.")
+        context.blank()
+        okay = false
+    end
+    if presets.password == "" then
+        context("No password given")
+        context.blank()
+        okay = false
+    end
+    return okay
+end
+
+function moduledata.sql.tables.showdefined(presets) -- key=value string | { presets = "name" } | { presets }
+
+    if type(presets) == "string" then
+        local specification = interfaces.checkedspecification(presets)
+        if specification.presets then
+            presets = table.load(specification.presets) or { }
+        end
+    end
+
+    if type(presets.presets) == "string" then
+        presets = table.load(presets.presets) or { }
+    end
+
+    if not moduledata.sql.validpresets(presets) then
+        return
+    end
+
+    local sql_tables = utilities.sql.tracers.gettables(presets)
+
+    context.starttitle { title = presets.database }
+
+        for name, fields in table.sortedhash(sql_tables) do
+
+            context.startsubject { title = name }
+
+                context.starttabulate { format = "|l|l|l|l|l|p|" }
+                context.FL()
+                context.NC() context.bold("field")
+                context.NC() context.bold("type")
+                context.NC() context.bold("default")
+                context.NC() context.bold("null")
+                context.NC() context.bold("key")
+                context.NC() context.bold("extra")
+                context.NC() context.NR()
+                context.TL()
+                for i=1,#fields do
+                    local field = fields[i]
+                    context.NC() context(field.field)
+                    context.NC() context(field.type)
+                    context.NC() context(field.default)
+                    context.NC() context(field.null)
+                    context.NC() context(field.key)
+                    context.NC() context(field.extra)
+                    context.NC() context.NR()
+                end
+                context.LL()
+                context.stoptabulate()
+
+            context.stopsubject()
+        end
+
+    context.stoptitle()
+
+end
+
+function moduledata.sql.tables.showconstants(list)
+
+    context.starttitle { title = "Constants" }
+
+        for name, fields in table.sortedhash(list) do
+
+            if type(fields) == "table" and #fields > 0 then
+
+                context.startsubject { title = name }
+
+                    context.starttabulate { format = "|l|l|" }
+                    for i=0,#fields do
+                        local field = fields[i]
+                        if field then
+                            context.NC() context(i)
+                            context.NC() context(field)
+                            context.NC() context.NR()
+                        end
+                    end
+                    context.stoptabulate()
+
+                context.stopsubject()
+
+            end
+
+        end
+
+    context.stoptitle()
+
+end
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index cc3025f3b..097fe5a2d 100644
Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 98d84fc14..f727ca843 100644
Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index c763583ff..443eee60e 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -4360,6 +4360,11 @@ return {
    filename = "s-pre-71",
    status   = "todo",
   },
+  {
+   category = "lua",
+   filename = "s-sql-tables",
+   status   = "okay",
+  },
   {
    category = "lua",
    filename = "scrn-but",
@@ -5362,41 +5367,49 @@ return {
   {
    category = "mkiv",
    filename = "s-fonts-coverage",
+   loading  = "s-fonts-coverage",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-features",
+   loading  = "s-fonts-features",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-goodies",
+   loading  = "s-fonts-goodies",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-missing",
+   loading  = "s-fonts-missing",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-shapes",
+   loading  = "s-fonts-shapes",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-system",
+   loading  = "s-fonts-system",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-tables",
+   loading  = "s-fonts-tables",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-fonts-vectors",
+   loading  = "s-fonts-vectors",
    status   = "okay",
   },
   {
@@ -5422,26 +5435,31 @@ return {
   {
    category = "lua",
    filename = "s-languages-counters",
+   loading  = "s-languages-counters",
    status   = "okay",
   },
   {
    category = "lua",
    filename = "s-languages-frequencies",
+   loading  = "s-languages-frequencies",
    status   = "okay",
   },
   {
    category = "lua",
    filename = "s-languages-hyphenation",
+   loading  = "s-languages-hyphenation",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-languages-sorting",
+   loading  = "s-languages-sorting",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-languages-system",
+   loading  = "s-languages-system",
    status   = "okay",
   },
   {
@@ -5472,26 +5490,31 @@ return {
   {
    category = "mkiv",
    filename = "s-math-characters",
+   loading  = "s-math-characters",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-math-coverage",
+   loading  = "s-math-coverage",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-math-extensibles",
+   loading  = "s-math-extensibles",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-math-parameters",
+   loading  = "s-math-parameters",
    status   = "okay",
   },
   {
    category = "mkiv",
    filename = "s-math-repertoire",
+   loading  = "s-math-repertoire",
    status   = "okay",
   },
   {
@@ -5517,6 +5540,7 @@ return {
   {
    category = "mkiv",
    filename = "s-physics-units",
+   loading  = "s-physics-units",
    status   = "okay",
   },
   {
@@ -5739,6 +5763,12 @@ return {
    filename = "s-syn-01",
    status   = "todo",
   },
+  {
+   category = "mkiv",
+   filename = "s-sql-tables",
+   loading  = "s-sql-tables",
+   status   = "okay",
+  },
   {
    category = "mkiv",
    filename = "x-asciimath",
diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv
index ec1b78b13..57134cb53 100644
--- a/tex/context/base/tabl-ntb.mkiv
+++ b/tex/context/base/tabl-ntb.mkiv
@@ -1706,8 +1706,8 @@
          [\c!frameoffset=.5\linewidth,
           \c!backgroundoffset=\v!frame,
           \c!framecolor=\s!black,
-          \c!width=fit,
-          \c!height=fit,
+          \c!width=\v!fit,
+          \c!height=\v!fit,
           \c!autowidth=\v!yes,
         % \c!rulethickness=\linewidth,
           \c!strut=\v!no,
diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi
index 03c68e603..aba4e5027 100644
--- a/tex/context/base/tabl-xtb.mkvi
+++ b/tex/context/base/tabl-xtb.mkvi
@@ -168,17 +168,17 @@
 % really need them and use the embeddedxtable command when nesting them.
 % Implementing nesting would be slower than not using direct buffers.
 
-\def\tabl_x_process_buffer_directly[#name]%
+\unexpanded\def\tabl_x_process_buffer_directly[#name]%
   {\bgroup
    \let\tabl_x_start_table\tabl_x_process_buffer
    \edef\tabl_x_current_buffer{#name}%
    \tabl_x_get_buffer % pickup settings
    \tabl_x_process}
 
-\def\tabl_x_start_ignore[#settings]%
+\unexpanded\def\tabl_x_start_ignore[#settings]%
   {}
 
-\def\tabl_x_process_buffer[#settings]%
+\unexpanded\def\tabl_x_process_buffer[#settings]%
   {\tabl_x_prepare{#settings}%
    \let\tabl_x_start_table\tabl_x_start_ignore
    \gobbleuntil\stopxtable} % nested xtables are not supported,
@@ -189,7 +189,7 @@
 \unexpanded\def\startembeddedxtable
   {\dosingleempty\tabl_x_embedded_start}
 
-\def\tabl_x_embedded_start[#settings]#content\stopembeddedxtable
+\unexpanded\def\tabl_x_embedded_start[#settings]#content\stopembeddedxtable
   {\tabl_x_prepare{#settings}%
    \ctxcommand{assignbuffer("embedded_x_table",\!!bs\detokenize{#content}\!!es)}%
    \bgroup
@@ -227,7 +227,7 @@
 
 %D Now we come to processing:
 
-\def\tabl_x_check_textwidth
+\unexpanded\def\tabl_x_check_textwidth
   {\edef\p_textwidth{\xtableparameter\c!textwidth}%
    \ifx\p_textwidth\v!local
      \d_tabl_x_textwidth\availablehsize
@@ -235,7 +235,7 @@
      \d_tabl_x_textwidth\p_textwidth
    \fi}
 
-\def\tabl_x_prepare#settings% assumes \iffirstargument to be set
+\unexpanded\def\tabl_x_prepare#settings% assumes \iffirstargument to be set
   {\advance\c_tabl_x_nesting\plusone
    \dostarttagged\t!table\empty
    \iffirstargument
@@ -247,7 +247,12 @@
 \def\tabl_x_get_buffer
   {\ctxcommand{gettexbuffer("\tabl_x_current_buffer")}}
 
-\let\tabl_x_stop_cell\relax
+\let\tabl_x_start_row_yes \relax
+\let\tabl_x_start_row_nop \relax
+\let\tabl_x_stop_row      \relax
+\let\tabl_x_start_cell_yes\relax
+\let\tabl_x_start_cell_nop\relax
+\let\tabl_x_stop_cell     \relax
 
 \unexpanded\def\tabl_x_process
   {\begingroup % *
@@ -322,7 +327,7 @@
 
 \installcorenamespace{xtableflushsplit}
 
-\def\tabl_x_flush_text_checked
+\unexpanded\def\tabl_x_flush_text_checked
   {\expandnamespaceparameter\??xtableflushsplit\xtableparameter\c!split\v!no}
 
 % in text flow: headers and footers only once
@@ -371,10 +376,10 @@
 
 \let\extratxtablesplitheight\zeropoint % might disappear so don't depend on it
 
-\def\tabl_x_flush_float_normal
+\unexpanded\def\tabl_x_flush_float_normal
   {\ctxcommand{x_table_flush{ method = "\v!normal" }}}
 
-\def\tabl_x_flush_float_split
+\unexpanded\def\tabl_x_flush_float_split
   {\resetdirecttsplit
    \edef\extrasplitfloatlines  {\xtableparameter\c!split}%
    \edef\tsplitminimumfreespace{\the\dimexpr\extratxtablesplitheight+\xtableparameter\c!splitoffset\relax}%
@@ -383,7 +388,7 @@
    \let\tsplitdirectwidth   \d_tabl_x_final_width
    \handledirecttsplit}
 
-\def\tabl_x_split_splitter#vsize%
+\unexpanded\def\tabl_x_split_splitter#vsize%
   {\setbox\tsplitresult\vbox
      {\ctxcommand{x_table_flush{ method = "\v!split", vsize = \number\dimexpr#vsize }}}%
    \ifcase\c_tabl_x_state
@@ -396,30 +401,30 @@
   {\begingroup
    \doifnextoptionalelse\tabl_x_start_row_yes\tabl_x_start_row_nop}
 
-\def\tabl_x_start_row_reflow_width_yes[#settings]%
+\unexpanded\def\tabl_x_start_row_reflow_width_yes[#settings]%
   {\setupcurrentxtable[#settings]%
    \ctxcommand{x_table_next_row()}}
 
-\def\tabl_x_start_row_reflow_width_nop
+\unexpanded\def\tabl_x_start_row_reflow_width_nop
   {\ctxcommand{x_table_next_row()}}
 
-\def\tabl_x_stop_row_reflow_width
+\unexpanded\def\tabl_x_stop_row_reflow_width
   {}
 
 \let\tabl_x_start_row_reflow_height_yes\tabl_x_start_row_reflow_width_yes
 \let\tabl_x_start_row_reflow_height_nop\tabl_x_start_row_reflow_width_nop
 \let\tabl_x_stop_row_reflow_height     \tabl_x_stop_row_reflow_width
 
-\def\tabl_x_start_row_construct_yes[#settings]%
+\unexpanded\def\tabl_x_start_row_construct_yes[#settings]%
   {\setupcurrentxtable[#settings]%
    \dostarttagged\t!tablerow\empty
    \ctxcommand{x_table_next_row()}}
 
-\def\tabl_x_start_row_construct_nop
+\unexpanded\def\tabl_x_start_row_construct_nop
   {\dostarttagged\t!tablerow\empty
    \ctxcommand{x_table_next_row()}}
 
-\def\tabl_x_stop_row_construct
+\unexpanded\def\tabl_x_stop_row_construct
   {\dostoptagged}
 
 \unexpanded\def\stopxrow
@@ -432,11 +437,11 @@
 \unexpanded\def\stopxcell
   {\tabl_x_stop_cell}
 
-\def\tabl_x_begin_of_cell
+\unexpanded\def\tabl_x_begin_of_cell
   {\inhibitblank
    \everypar{\delayedbegstrut}}
 
-\def\tabl_x_end_of_cell
+\unexpanded\def\tabl_x_end_of_cell
   {\ifhmode
      \delayedendstrut
      \par
@@ -674,7 +679,7 @@
 \unexpanded\def\stopxgroup
   {\endgroup}
 
-\def\tabl_x_start_group_delayed_one[#tag]%
+\unexpanded\def\tabl_x_start_group_delayed_one[#tag]%
 % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname
   {\ifcsname\??xtablecheck#tag\endcsname
      \expandafter\tabl_x_start_group_delayed_two
@@ -682,7 +687,7 @@
      \expandafter\setupcurrentxtable
    \fi[#tag]}
 
-\def\tabl_x_start_group_delayed_two[#tag]%
+\unexpanded\def\tabl_x_start_group_delayed_two[#tag]%
   {\ifx\currentxtable\empty \else
      \chaintocurrentxtable{#tag}%
    \fi
@@ -700,7 +705,7 @@
   {\begingroup
    \doifnextoptionalelse\tabl_x_start_cell_delayed_one\tabl_x_start_cell_nop}
 
-\def\tabl_x_start_cell_delayed_one[#tag]%
+\unexpanded\def\tabl_x_start_cell_delayed_one[#tag]%
 % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname
   {\ifcsname\??xtablecheck#tag\endcsname
      \expandafter\tabl_x_start_cell_delayed_two
@@ -708,7 +713,7 @@
      \expandafter\tabl_x_start_cell_yes
    \fi[#tag]}
 
-\def\tabl_x_start_cell_delayed_two[#tag]%
+\unexpanded\def\tabl_x_start_cell_delayed_two[#tag]%
   {\ifx\currentxtable\empty \else
      \chaintocurrentxtable{#tag}%
    \fi
@@ -725,7 +730,7 @@
   {\begingroup
    \doifnextoptionalelse\tabl_x_start_row_delayed_one\tabl_x_start_row_nop}
 
-\def\tabl_x_start_row_delayed_one[#tag]%
+\unexpanded\def\tabl_x_start_row_delayed_one[#tag]%
 % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname
   {\ifcsname\??xtablecheck#tag\endcsname
      \expandafter\tabl_x_start_row_delayed_two
@@ -733,7 +738,7 @@
      \expandafter\tabl_x_start_row_yes
    \fi[#tag]}
 
-\def\tabl_x_start_row_delayed_two[#tag]%
+\unexpanded\def\tabl_x_start_row_delayed_two[#tag]%
   {\ifx\currentxtable\empty \else
      \chaintocurrentxtable{#tag}%
    \fi
diff --git a/tex/context/base/x-cals.lua b/tex/context/base/x-cals.lua
index 4051dd157..36bc1aaba 100644
--- a/tex/context/base/x-cals.lua
+++ b/tex/context/base/x-cals.lua
@@ -30,15 +30,15 @@ cals.stretch_widths = false
 -- has to happen at the core-ntb level (todo)
 
 local halignments = {
-    left = "flushleft",
-    right = "flushright",
-    center = "middle",
-    centre = "middle",
+    left    = "flushleft",
+    right   = "flushright",
+    center  = "middle",
+    centre  = "middle",
     justify = "normal",
 }
 
 local valignments = {
-    top = "high",
+    top    = "high",
     bottom = "low",
     middle = "lohi",
 }
diff --git a/tex/context/base/x-cals.mkiv b/tex/context/base/x-cals.mkiv
index 4e68c3400..31ba2d213 100644
--- a/tex/context/base/x-cals.mkiv
+++ b/tex/context/base/x-cals.mkiv
@@ -18,7 +18,7 @@
 \registerctxluafile{x-cals}{}
 
 % \startxmlsetups xml:cals:process
-%     \xmlsetsetup {\xmldocument} {cals:table} {*}
+%     \xmlsetsetup {#1} {cals:table} {*}
 % \stopxmlsetups
 % \startxmlsetups cals:table
 %     \ctxlua{moduledata.cals.table("#1")}
diff --git a/tex/context/base/x-mathml.mkiv b/tex/context/base/x-mathml.mkiv
index 99b9f92af..a4eb09467 100644
--- a/tex/context/base/x-mathml.mkiv
+++ b/tex/context/base/x-mathml.mkiv
@@ -16,6 +16,8 @@
 % This module is under construction and will be cleaned up. We use a funny mix of
 % xml, tex and lua. I could rewrite the lot but it also shows how context evolves.
 %
+% I might en dup with a lua-only implementation some day.
+%
 % no m:text strip (needs checking, maybe nbsp is mandate
 %
 % todo: more will be moved to lua (less hassle)
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 8a041cb91..cf5862ca9 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 05/27/13 19:11:47
+-- merge date  : 05/28/13 00:34:00
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3