Adam Lindsay wrote:
h h extern said this at Fri, 10 Dec 2004 22:38:27 +0100:


Also, what's the status of contml? I like the idea of it as a simple,
structural, basic markup that ConTeXt handles with zero effort, but is
anyone actually using it?

we sometimes mix it into other xml docs; i have no problem with

extending it;


actualy, (see mag-0008.pdf), i want to map most context directly onto xml so that we have a rather complete xml input syntax


Yes, indeed. I took a look at the magazine again last night, and it was
put in an entirely new light. I'm very curious to work with x-fx now...

see below

I've been working on a general-ish conversion script from a new Mac
application. I'd like to offer most of ContML as basic level constructs,
but it should be possible for a user to add their own tags. If they can
tap into fx:anything tags, it should make people (hi, Bruce!) fairly happy.

My first reaction/critique of the approach was: why not fix at least one
of the problems of TeX: that it's "a mixture between typesetting and
programming features" as you say?

indeed, but, it al depends on the 'to be written' manuals then:

- code in xml and then
- use xslt to generate an (structured) instance that
- calls templates that implement typographical solutions
- using the xml interface to context

in practice it means trading in some context funtionality by xslt functionality

the interesting thing is that the whole machinery is still there

What I propose is clearly a debatable XML-design issue, but it seemed
strange that fx:definelayout and fx:p were put into the same namespace.
Why do the formatting definitions share the same (theoretical) schema as
markup? Your documents keep these categories separate, as one would
expect. Why not encourage people to put them in separate files, as with
"normal" ConTeXt workflows? The designer and author are more clearly
divorced when you don't assume an XSLT-centric flow, right?
(or, is this already planned with this tidbit from foxet: fs = setup)

sure, definitions should become 'styles' but that's hard to demo in a magazine -)

in principle it could also mean that one could predefine page masters and have multiple variants instead of the five-area-fo-thing

I'm curious about how the namespacing would work, though, because I want
to use (and enable the use of) these nice fs:setuphead -like
configurations with my hybrid ContML++ documents. Will:

context\high{fx}

 <fs:setuphead label='section' />
correctly (in my mind) affect a ContML element like this?
 <context:section>something</context:section>

indeed, or

<context:head label='section'>something</context:head>

a matter of taste; i'm open to any suggestion (more a discussion for the foxet list)

Curious,

well, here 's an <experimental/> version of x-fx. It demonstrates that it's relaively easy to map the context interface to xml; actually, if things get dirty i can provide a more low level context support which then makes the mapping clean -)


%D \module
%D   [      file=x-fx,
%D        version=2004.11.12,
%D          title=\FOXET,
%D       subtitle=Style Processor,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\chardef\XMLtokensreduction = 2
\chardef\XMLcdatamethod     = 2

\usemodule[mathml]

\setupcolors[state=start]

% these will be speed up by few step expansion

\def\foxarguments {\theXMLarguments{fox}}
\def\initializefox{\expanded{\getrawparameters[fox][\theXMLarguments{fox}]}}
\def\foxaction  #1{\expanded{#1[\theXMLarguments{fox}]}}

% layers

\defineXMLcommand
  [fx:definelayer] [fox] [label=default]
  {\initializefox
   \expanded{\definelayer[\foxlabel]}%
   \expanded{\setuplayer[\foxlabel][\foxarguments]}}

\defineXMLcommand
  [fx:setuplayer] [fox] [label=default]
  {\initializefox
   \expanded{\setuplayer[\foxlabel][\foxarguments]}}

\defineXMLenvironment
  [fx:setlayer] [fox] [label=default]
  {\initializefox
   \expanded{\setlayer[\foxlabel][\foxarguments]}\bgroup\ignorespaces}
  {\removeunwantedspaces\egroup}

\defineXMLcommand
  [fx:flushlayer] [fox] [label=default]
  {\initializefox
   \tightlayer[\foxlabel]}

% framed

\defineXMLenvironment
  [fx:framed] [fox] []
  {\initializefox
   \expanded{\framed[\foxarguments]}\bgroup\ignorespaces}
  {\removeunwantedspaces\egroup}

% layout

\defineXMLcommand
  [fx:definelayout] [fox] [label=default]
  {\initializefox
   \expanded{\definelayout[\foxlabel][\foxarguments]}}

\defineXMLcommand
  [fx:setuplayout] [fox] [label=default]
  {\initializefox
   \expanded{\setuplayout[\foxlabel][\foxarguments]}
   }% \expanded{\setuplayout[\foxlabel]}} % todo: only when no further arguments

\defineXMLcommand
  [fx:enablelayout] [fox] [label=default]
  {\initializefox
   \expanded{\setuplayout[\foxlabel]}}

% heads / we need a stupid, not list/ref variant

\defineXMLcommand
  [fx:definehead] [fox] [label=default,level=1]
  {\initializefox

\expanded{\definehead[fx:head:\foxlabel][section=section-\foxlevel,incrementnumber=no]}%
   \expanded{\setuphead[fx:head:\foxlabel][\foxarguments,alternative=command]}}

\defineXMLcommand
  [fx:setuphead] [fox] [label=default]
  {\initializefox
   \expanded{\setuphead[fx:head:\foxlabel][\foxarguments,alternative=command]}}

\defineXMLenvironmentsave
  [fx:head] [fox] [label=default]
  {\bgroup}
  {\initializefox
   \expanded{\setuphead[fx:head:\foxlabel][\foxarguments,alternative=command]}%
   \getvalue{fx:head:\foxlabel}{\vbox{\forgetall\XMLflush{fx:head}}}%
   \egroup}

% page

\defineXMLcommand
  [fx:page] [fox] [command=yes]
  {\initializefox
   \expanded{\page[\foxcommand]}}

% tabulate / todo: in context preamble also definable this way, then direct map

\setuptabulate[before=,after=]

\startsetups fox:tabulate

    \defineXMLenvironment
        [fx:preamble]
        {\scratchtoks\emptytoks}
        {\appendetoks|\to\scratchtoks}

    \defineXMLpickup
        [fx:tbody]
        {\expanded{\starttabulate[\the\scratchtoks]}}
        {\stoptabulate}

\defineXMLcommand
[fx:e] [fox] [width=,align=,type=line,style=] % line|paragraph
{\initializefox
\appendetoks|\to\scratchtoks
\doifelse{\foxtype}{paragraph}{\appendetoks p\to\scratchtoks}{\appendetoks w\to\scratchtoks}%
\doifsomething{\foxwidth}{\appendetoks(\foxwidth)\to\scratchtoks}%
\appendetoks\XMLval{fox:tab:style}{\foxstyle}{}\to\scratchtoks
\appendetoks\XMLval{fox:tab:align}{\foxalign}{}\to\scratchtoks}


    \defineXMLenvironment [fx:r]  {}    {\NC \NR}
    \defineXMLenvironment [fx:c]  {\NC} {}
    \defineXMLenvironment [fx:tr] {}    {\NC \NR}
    \defineXMLenvironment [fx:td] {\NC} {}

\stopsetups

\mapXMLvalue {fox:tab:align} {flushleft}  {l}
\mapXMLvalue {fox:tab:align} {flushright} {r}
\mapXMLvalue {fox:tab:align} {center}     {c}

\mapXMLvalue {fox:tab:style} {italic}     {I}
\mapXMLvalue {fox:tab:style} {bold}       {B}
\mapXMLvalue {fox:tab:style} {slanted}    {S}

\defineXMLenvironment
  [fx:tabulate] [fox] []
  {}
  {}

\defineXMLenvironment
  [fx:tabulate] [fox] []
  {\bgroup
   \directsetup{fox:tabulate}}
  {\egroup}

% itemize

\defineXMLcommand
  [fx:defineitemize] [fox] [label=default] % maybe also \defineitemgroup as 
synonym
  {\initializefox
   \expanded{\defineitemgroup[\foxlabel]}%
   \expanded{\setupitemgroup[\foxlabel][\foxarguments]}}

\defineXMLcommand
  [fx:setupitemize] [fox] [label=default]
  {\initializefox
   \expanded{\setupitemgroup[\foxlabel][\foxarguments]}}

\defineXMLenvironment
  [fx:itemize] [fox] [label=default]
  {\initializefox
   \expanded{\startitemgroup[\foxlabel]}\ignorespaces}
  {\stopitemgroup}

\defineXMLenvironment
  [fx:item] [fox] [type=normal,symbol=]
  {\initializefox
   \XMLval{fox:item:type}{\foxtype}{normal}}
  {\par}

\mapXMLvalue {fox:item:type} {normal} {\item}
\mapXMLvalue {fox:item:type} {margin} {\mar{\foxsymbol}}
\mapXMLvalue {fox:item:type} {symbol} {\sym{\foxsymbol}}

% table

% first last odd even row column header each <n> <m>

\startsetups fox:table

    \defineXMLprocess
        [fx:preamble]

    \defineXMLcommand [fx:c] [fox] [r=each]
        {\initializefox\expanded{\setupTABLE[r][\foxr][\foxarguments]}}

    \defineXMLcommand
        [fx:r] [fox] [c=each]
        {\initializefox\expanded{\setupTABLE[c][\foxc][\foxarguments]}}

    \defineXMLcommand
        [fx:h] [fox] [c=each]
        {\initializefox\expanded{\setupTABLE[header][\foxc][\foxarguments]}}

    \defineXMLcommand
        [fx:e] [fox] [type=,c=each,r=each]
        {\initializefox
         \doifelse{\foxtype}{row}
           {\expanded{\setupTABLE[r][\foxr][\foxarguments]}}
           {\doifelse{\foxtype}{column}
              {\expanded{\setupTABLE[c][\foxc][\foxarguments]}}
              {\expanded{\setupTABLE[\foxc][\foxr][\foxarguments]}}}}

\defineXMLnested [fx:thead] [fox] [] {\expanded{\bTABLEhead[\foxarguments]}} {\eTABLEhead}
\defineXMLnested [fx:tfoot] [fox] [] {\expanded{\bTABLEfoot[\foxarguments]}} {\eTABLEfoot}
\defineXMLnested [fx:tnext] [fox] [] {\expanded{\bTABLEnext[\foxarguments]}} {\eTABLEnext}
\defineXMLnested [fx:tbody] [fox] [] {\expanded{\bTABLEbody[\foxarguments]}} {\eTABLEbody}
\defineXMLnested [fx:tr] [fox] [] {\expanded{\bTR[\foxarguments]}} {\eTR}
\defineXMLnested [fx:td] [fox] [] {\expanded{\bTD[\foxarguments]}} {\eTD}


\stopsetups

\defineXMLnested
  [fx:table] [fox] []
  {\bgroup
   \directsetup{fox:table}
   \expanded{\bTABLE[\foxarguments]}}
  {\eTABLE
   \egroup}

% misc

\defineXMLenvironment
  [fx:narrower] [fox] [left=0em,right=0em]
  {\expanded{\setupnarrower[\foxarguments]}%
   \startnarrower[middle]}
  {\stopnarrower}

\defineXMLenvironment
  [fx:text] [fox] []
  {\starttext}
  {\stoptext}

% paragraphs

\newcount \paragraphdepth

\defineXMLenvironment
    [fx:p] [fox] [strut=no]
    {\advance\paragraphdepth\plusone
     \initializefox
     \doifelse{\foxstrut}{yes}
       {\setvalue{fx:p:strut:\the\paragraphdepth}{1}}
       {\setvalue{fx:p:strut:\the\paragraphdepth}{0}}%
     \ifcase\getvalue{fx:p:strut:\the\paragraphdepth}\or\begstrut\fi}
    {\ifcase\getvalue{fx:p:strut:\the\paragraphdepth}\or\endstrut\fi
     \endgraf
     \advance\paragraphdepth\minusone}

% fonts

\def\startfont[#1]{\bgroup\getvalue{#1}}
\def\stopfont     {\egroup}

\defineXMLcommand
[fx:definefont] [fox]
[label=fallbackfont,spec=lmtt10] % todo: more efficient (no spec/label in third arg)
{\initializefox
\expanded{\definefont[fx:font:\foxlabel][\foxspec][spec=,label=,\foxarguments]}}


\defineXMLnested
  [fx:font] [fox]
  [label=fallbackfont]
  {\initializefox
   \startfont[fx:font:\foxlabel]}
  {\stopfont}

% color

\defineXMLcommand
  [fx:definecolor] [fox]
  [label=fallbackcolor]
  {\initializefox
   \expanded{\definecolor[fx:color:\foxlabel][\foxarguments]}}

\defineXMLnested
  [fx:color] [fox]
  [label=fallbackfont]
  {\initializefox
   \startcolor[fx:color:\foxlabel]}
  {\stopcolor}

% margin things

\setupinmargin[style=,color=]

\defineXMLargument
  [fx:margintext] [fox] [label=default]
  {\margintext}

% so far

\doifnotmode{demo}{\endinput}

% test

\startbuffer[demo]
<fx:definelayout label='main' backspace='2cm' cutspace='2cm' topspace='2cm' bottomspace='2cm'/>


<fx:enablelayout label='main'/>

<fx:defineitemize label='mine'/>

<!-- test layer -->

<fx:definelayer label='test'/>

<fx:setuplayer label='test' width='10cm' height='10cm'/>

<fx:setlayer label='test' preset='lefttop'>
    <fx:framed width='4cm' height='5cm'>
        Left Top
    </fx:framed>
</fx:setlayer>

<fx:setlayer label='test' preset='rightbottom'>
    <fx:framed width='3cm' height='4cm'>
        Right Bottom
    </fx:framed>
</fx:setlayer>

<fx:flushlayer label='test'/>

<fx:narrower>
A bit of text!
    <fx:narrower left='1em'>
    A bit of text!
        <fx:narrower left='3em'>
            A bit of text!
            <fx:narrower right='1em'>
                A bit of text!
            </fx:narrower>
        </fx:narrower>
    </fx:narrower>
</fx:narrower>

<!-- chapter head -->

<fx:definehead label='chapter'/>

<fx:definelayer label='chapter' width='10cm' method='fit'/>

<fx:page command='yes'/>

<fx:head label='chapter'>
    <fx:setlayer label='chapter' preset='lefttop' hoffset='0cm'>
        <fx:framed>12</fx:framed>
    </fx:setlayer>
    <fx:setlayer label='chapter' preset='lefttop' hoffset='2cm'>
        <fx:framed>The Title</fx:framed>
    </fx:setlayer>
    <fx:flushlayer label='chapter'/>
</fx:head>

<p>Some text!</p>

<fx:tabulate>
<fx:preamble>
<fx:e width='1cm' align='flushleft'/>
<fx:e width='2cm' align='flushright'/>
<fx:e width='3cm' align='center'/>
<fx:e width='4cm'/>
</fx:preamble>
<fx:body>
<fx:tr><fx:td>test 1</fx:td><fx:td>test 2</fx:td><fx:td>test 3</fx:td><fx:td>test 4</fx:td></fx:tr>
<fx:tr><fx:td>test 11</fx:td><fx:td>test 22</fx:td><fx:td>test 33</fx:td><fx:td>test 44</fx:td></fx:tr>
<fx:tr><fx:td>test 111</fx:td><fx:td>test 222</fx:td><fx:td>test 333</fx:td><fx:td>test 444</fx:td></fx:tr>
</fx:body>
</fx:tabulate>


<fx:tabulate>
<fx:preamble>
<fx:e style='bold'/>
<fx:e type='paragraph' style='normal'/>
<fx:e style='italic'/>
<fx:e type='paragraph' style='slanted'/>
</fx:preamble>
<fx:tbody>
<fx:tr><fx:td>test 1</fx:td><fx:td>test 2</fx:td><fx:td>test 3</fx:td><fx:td>test 4</fx:td></fx:tr>
<fx:tr><fx:td>test 11</fx:td><fx:td>test 22</fx:td><fx:td>test 33</fx:td><fx:td>test 44</fx:td></fx:tr>
<fx:tr><fx:td>test 111</fx:td><fx:td>test 222</fx:td><fx:td>test 333</fx:td><fx:td>test 444</fx:td></fx:tr>
</fx:body>
</fx:tabulate>


<fx:itemize>
    <fx:item>first</fx:item>
    <fx:itemize>
        <fx:item>first</fx:item>
        <fx:item type='symbol' symbol='+'>second</fx:item>
        <fx:item>third</fx:item>
    </fx:itemize>
    <fx:item type='margin' symbol='+'>second</fx:item>
    <fx:item>third</fx:item>
</fx:itemize>

<fx:table>
    <fx:preamble>
        <fx:r           c='2' background='color' backgroundcolor='red'   />
        <fx:h           c='3' background='color' backgroundcolor='yellow'/>
        <fx:c r='odd'         background='color' backgroundcolor='green' />
        <fx:c r='last'        background='color' backgroundcolor='green' />
        <fx:e r='3'     c='2' background='color' backgroundcolor='blue'  />
    </fx:preamble>
    <fx:thead>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
    </fx:thead>
    <fx:tbody>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
        <fx:tr> <fx:td>a</fx:td> <fx:td>b</fx:td> <fx:td>c</fx:td> </fx:tr>
    </fx:tbody>
</fx:table>
\stopbuffer

\starttext

\showframe

\typebuffer[demo]

\processXMLbuffer[demo]

\relax

\stoptext



-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

_______________________________________________
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to