ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Meer, H. van der" <H.vanderMeer@uva.nl>
To: NTG ConTeXt <ntg-context@ntg.nl>
Subject: Re: embeddedxtable
Date: Sun, 24 May 2015 19:33:13 +0000	[thread overview]
Message-ID: <9B18EC0F-CCBF-483F-875E-5F097EBD8908@uva.nl> (raw)
In-Reply-To: <A20EF219-25A7-4AC0-B7EF-AE89F683CE50@gmail.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 5551 bytes --]

In this case you have to provide a working minimal example.

Wolfgang

Here an example as minimal as I could construct.
Hans van der Meer

The following example outputs show what happens with and without the \unskip's in the code.
[cid:E7DC008D-E8CB-4F0A-BC45-9E8E4969C8DB]
[cid:8A14737A-52AE-4B90-A03B-FA36FFF321E0]

Also I am adding two other examples made by the same code, one in 2012 and one just now. Note the extensions to the right of each row. They are absent in the older version.

[cid:1110D708-ADD3-46B8-A49B-143200704DA7][cid:539F8473-CC40-4CDB-AFC6-48AF306DD3F5]
The example code follows here:

% Switching on attribute being present (even if empty) or absent.
\def\doifexistattribute#1#2{\doifnot{\xmlattdef{#1}{#2}{__NOT__}}{__NOT__}}%{#3}
% Translate attribute: #1 = node, #2 = category #3 = attribute #4 = default value.
\def\xlat#1#2#3#4{\xmlvalue{#2}{\xmlatt{#1}{#3}}{#4}}
% Setup parameter to attribute.
% #1 = node, #2 = setup, #3 = param, #4 = attrib, #5 = category, #6 = default.
\def\setupToAttribute#1#2#3#4#5#6{%
% Only executed if attribute is present.
\doifexistattribute{#1}{#4}%
% Attribute is present but category can be empty.
{\doifelse{#5}{\empty}%
{\doifelse{\xmlatt{#1}{#4}}{\empty}%
{#2[#3=#6]}% attribute present but empty then take default
{#2[#3=\xmlatt{#1}{#4}]}% attribute has content
}%
{#2[#3=\xlat{#1}{#5}{#4}{#6}]}% translate from category
}%
}
% Setup flag (an TeX-if) from attribute values on,off,no,yes,true,false.
% #1=node #2=flag: execute \attributetrue or \attributefalse
\def\setFlagToAttribute#1#2{%
\doifexistattribute{#1}{#2}%
{%
\doifinset{\xmlatt{#1}{#2}}{on,yes,true}{\csname#2true\endcsname}%
\doifinset{\xmlatt{#1}{#2}}{off,no,false}{\csname#2false\endcsname}%
}%
}
\startxmlsetups xmlcommon
\xmlsetsetup{\xmldocument}{error|store|restore|include
|table|tr|td|tbody
}{xmlcommon:*}
\stopxmlsetups
\xmlregistersetup{xmlcommon}
% Place at top/middle(default)/bottom location.
\def\startlocationbox#1{%
\let\templocation\relax
\doif{\xmlatt{#1}{location}}{top}{\def\templocation{\vtop}}%
\doif{\xmlatt{#1}{location}}{middle}{\def\templocation{\vcenter}}%
\doif{\xmlatt{#1}{location}}{center}{\def\templocation{\vcenter}}%
\doif{\xmlatt{#1}{location}}{bottom}{\def\templocation{\vbox}}%
\templocation\bgroup\ifx\templocation\relax\else\vss\fi
}
\let\stoplocationbox\egroup
\def\setupframeparameters#1#2{%
% color
% Always set background to color if backgroundcolor is set.
\doifnot{\xmlatt{#1}{bgcolor}}{\empty}{#2[background=color]}%
% But it can be overridden.
\doifnot{\xmlatt{#1}{background}}{\empty}{#2[background=\xmlatt{#1}{background}]}%
\setupToAttribute{#1}{#2}{foregroundcolor}{color}{}{darkblue}%
\setupToAttribute{#1}{#2}{backgroundcolor}{bgcolor}{}{green}%
% frame
\doifnot{\xmlatt{#1}{frame}}{\empty}%
{#2[frame=off]\setframeparts{\xmlatt{#1}{frame}}{#2}}%
\setupToAttribute{#1}{#2}{framecolor}{framecolor}{}{black}%
\setupToAttribute{#1}{#2}{corner}{corner}{}{rectangular}%
\setupToAttribute{#1}{#2}{radius}{radius}{}{0.5ex}%
\setupToAttribute{#1}{#2}{backgroundcorner}{bgcorner}{}{rectangular}%
\setupToAttribute{#1}{#2}{backgroundradius}{bgradius}{}{0.5ex}%
% dimensions
\setupToAttribute{#1}{#2}{rulethickness}{rulethickness}{}{3pt}%
\doifnot{\xmlatt{#1}{height}}{\empty}%
{#2[height=\NumberCollect{"\xmlattdef{#1}{height}{fit}","\the\makeupheight"}]}%
\doifnot{\xmlatt{#1}{width}}{\empty}%
{#2[width=\NumberCollect{"\xmlattdef{#1}{width}{fit}","\the\textwidth"}]}%
% alignment
\setupToAttribute{#1}{#2}{strut}{strut}{}{on}%
\setupToAttribute{#1}{#2}{align}{align}{html}{normal}%
\setupToAttribute{#1}{#2}{align}{valign}{html}{lohi}%
}
% Setups for tables with xtable.
\def\setupxtableparameters#1{%
\setupframeparameters{#1}{\setupxtable}%
\setupToAttribute{#1}{\setupxtable}{foregroundstyle}{style}{style}{\tf}%
\setupToAttribute{#1}{\setupxtable}{offset}{cellpadding}{}{0pt}%
\setupToAttribute{#1}{\setupxtable}{columndistance}{cellspacing}{}{0pt}%
\setupToAttribute{#1}{\setupxtable}{spaceinbetween}{rowspacing}{}{0pt}%
\setupToAttribute{#1}{\setupxtable}{option}{option}{}{}%
}
\startxmlsetups xmlcommon:table
\bgroup
\xmlstripanywhere{#1}{.}
\setupxtable[% Setup defaults
leftmargindistance=0pt,rightmargindistance=0pt,
offset=2pt,height=fit,width=fit,
align={center,lohi},columndistance=0pt]
\setupxtableparameters{#1}
\startlocationbox{#1}
\startembeddedxtable\xmlflush{#1}\stopembeddedxtable
\stoplocationbox
\egroup
\stopxmlsetups
\startxmlsetups xmlcommon:tbody
\xmlstripanywhere{#1}{.}
\bgroup
\setupxtableparameters{#1}
\startxtablebody
\xmlflush{#1}
\stopxtablebody
\egroup
\stopxmlsetups
\startxmlsetups xmlcommon:tr
\unskip
\xmlstripanywhere{#1}{.}
\unskip
\bgroup
\unskip
\setupxtableparameters{#1}
\unskip
\startxrow
\unskip
=\xmlflush{#1}
\stopxrow
\egroup
\unskip
\stopxmlsetups

\startxmlsetups xmlcommon:td
\unskip
\xmlstrip{#1}{.}
\bgroup
\setupxtableparameters{#1}
\startxcell[nc=\xmlattdef{#1}{colspan}{1},nr=\xmlattdef{#1}{rowspan}{1}]
\xmlflush{#1}
\stopxcell
\egroup
\stopxmlsetups

\starttext
\startbuffer[the-table]
<?xml version="1.0" encoding="UTF-8"?>
<root>
<table>
<tbody>
<tr><td>A</td></tr>
<tr><td>B</td></tr>
<tr><td>C</td></tr>
<tr><td>D</td></tr>
</tbody>
</table>
</root>
\stopbuffer
\midaligned{\xmlprocessbuffer{root}{the-table}{}}
\blank
The equalsign (=) is added to \type{\startxmlsetups xmlcommon:tr} in order to show the spurious whitespace injected.
\stoptext


[-- Attachment #1.1.2: Type: text/html, Size: 25851 bytes --]

[-- Attachment #1.2: without-unskips.jpg --]
[-- Type: image/jpeg, Size: 12763 bytes --]

[-- Attachment #1.3: with-unskips.jpg --]
[-- Type: image/jpeg, Size: 10191 bytes --]

[-- Attachment #1.4: created 2012-7-11.jpg --]
[-- Type: image/jpeg, Size: 11711 bytes --]

[-- Attachment #1.5: created 2015-5-24.jpg --]
[-- Type: image/jpeg, Size: 10729 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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	other threads:[~2015-05-24 19:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-24 10:18 embeddedxtable Meer, H. van der
2015-05-24 10:36 ` embeddedxtable Meer, H. van der
2015-05-24 11:49   ` embeddedxtable Meer, H. van der
2015-05-24 13:06     ` embeddedxtable Meer, H. van der
2015-05-24 13:32       ` embeddedxtable Meer, H. van der
2015-05-24 15:31         ` embeddedxtable Wolfgang Schuster
2015-05-24 16:01           ` embeddedxtable Meer, H. van der
2015-05-24 18:16             ` embeddedxtable Wolfgang Schuster
2015-05-24 19:33               ` Meer, H. van der [this message]
2015-05-24 20:53                 ` embeddedxtable Wolfgang Schuster
2015-05-25  8:35                   ` embeddedxtable Meer, H. van der
2015-05-25  9:26                     ` embeddedxtable Meer, H. van der
2015-05-25 10:59                       ` embeddedxtable Wolfgang Schuster
2015-05-25 10:55                     ` embeddedxtable Wolfgang Schuster
2015-05-25  9:06                   ` embeddedxtable Meer, H. van der
2015-05-25 10:08                   ` embeddedxtable Meer, H. van der
2015-05-25 11:05                     ` embeddedxtable Wolfgang Schuster
2015-05-25 13:50                       ` embeddedxtable Meer, H. van der

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9B18EC0F-CCBF-483F-875E-5F097EBD8908@uva.nl \
    --to=h.vandermeer@uva.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).