ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Peter Rolf <indiego@gmx.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
Subject: Re: xml and lua again
Date: Sun, 23 Oct 2011 20:15:10 +0200	[thread overview]
Message-ID: <4EA459AE.9010704@gmx.net> (raw)
In-Reply-To: <4EA2F34E.6080202@uni-bonn.de>

Am 22.10.2011 18:46, schrieb Thomas A. Schmitz:
> Hi all,
> 
> again, I'm playing a bit with processing my xml in lua. I want a simple
> interface for processing tables (I don't need all the power and
> complexity of cals tables and want to learn something in the process).
> And I thought that collecting the setups in lua might be the easiest
> way, but so far, I haven't been successful. Here's an example:
> 
> \startbuffer[test]
> <a>
>   <nattable frame="on">
>     <tr>
>       <td>1</td>
>       <td>2</td>
>       <td>3</td>
>       <td>4</td>
>     </tr>
>     <tr>
>       <td>5</td>
>       <td>6</td>
>       <td>7</td>
>       <td>8</td>
>     </tr>
>   </nattable>
> </a>
> \stopbuffer
> 
> \startxmlsetups xml:testsetups
>     \xmlsetsetup{main}{a|nattable|tr|td|}{xml:*}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:testsetups}
> 
> \startxmlsetups xml:a
>     \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:nattable
>     \startluacode
>       framestate = lxml.att("#1", "frame")

context(type(framestate))

Here is the problem. The function lxml.att() only prints the attribute,
but returns nothing (framestate = nil). I looked into an old example of
mine where I played with attributes, but it's totally outdated (uses
xml.filters, now mkii only).

Sorry, no solution (goat milk was out).

Peter


[lxml-tex.lua]

function lxml.attribute(id,pattern,a,default)
    local collected = xmlapplylpath(getid(id),pattern)
    if collected then
        attribute(collected,a,default)
    end
end

local function attribute(collected,a,default)
    if collected and #collected > 0 then
        local at = collected[1].at
        local str = (at and at[a]) or default
        if str and str ~= "" then
            contextsprint(notcatcodes,str)
        end
    elseif default then
        contextsprint(notcatcodes,default)
    end
end


>       context(framestate)

does nothing


>       context(true)
>       context.placefigure( { "here" }, "none" , function()
>         context.setupTABLE( { "frame=on" } )
>         context.bTABLE()
>          context.xmlflush("#1")
>         context.eTABLE()
>       end)
>     \stopluacode
> \stopxmlsetups
> 
> \startxmlsetups xml:tr
>     \startluacode
>       context.bTR()
>         context.xmlflush("#1")
>       context.eTR()
>     \stopluacode
> \stopxmlsetups
> 
> \startxmlsetups xml:td
>     \startluacode
>       context.bTD()
>         context.xmlflush("#1")
>       context.eTD()
>     \stopluacode
> \stopxmlsetups
> 
> \starttext
> \xmlprocessbuffer{main}{test}{}
> \stoptext
> 
> question: I have the value "on" in the lua variable "framestate." But
> how can I pass this on to the line
> context.setupTABLE( { "frame=on" } )?
> I tried something like
> context.setupTABLE( { "frame=" .. framestate } )
> but that doesn't work. Any suggestions?
> 
> Thomas
> ___________________________________________________________________________________
> 
> 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
> ___________________________________________________________________________________
> 
> 

___________________________________________________________________________________
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
___________________________________________________________________________________


  parent reply	other threads:[~2011-10-23 18:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-22 16:46 Thomas A. Schmitz
2011-10-23 14:04 ` Peter Rolf
2011-10-23 14:37   ` Thomas A. Schmitz
2011-10-23 15:25     ` Peter Rolf
2011-10-23 18:15 ` Peter Rolf [this message]
2011-10-24 10:17 ` Hans Hagen
2011-10-24 12:18   ` Thomas A. Schmitz
2011-10-24 12:26     ` Hans Hagen
2011-10-24 17:00       ` Thomas A. Schmitz
2011-10-24 18:48         ` Hans Hagen
2011-10-25  9:43           ` Thomas A. Schmitz
2011-10-25 10:10             ` Wolfgang Schuster
2011-10-25 10:17             ` Hans Hagen
2011-10-25 10:27               ` Thomas A. Schmitz
2011-10-27  9:23                 ` Thomas A. Schmitz
2011-10-27  9:53                   ` Wolfgang Schuster
2011-10-27 10:32                     ` Thomas A. Schmitz
2011-10-27 11:05                       ` Hans Hagen
2011-10-28  6:23                         ` Thomas A. Schmitz
2011-10-28  6:37                           ` luigi scarso
2011-10-28  6:43                             ` luigi scarso
2011-10-28  6:44                           ` Patrick Gundlach
2011-10-28  6:55                             ` Thomas A. Schmitz
2011-10-28  8:35                               ` Wolfgang Schuster
2011-10-28  8:59                                 ` Hans Hagen
2011-10-28  8:56                               ` Hans Hagen
2011-10-28 10:48                                 ` Thomas A. Schmitz
2011-10-28 11:23                                 ` luigi scarso
2011-10-28 11:42                                   ` Hans Hagen

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=4EA459AE.9010704@gmx.net \
    --to=indiego@gmx.net \
    --cc=ntg-context@ntg.nl \
    --cc=thomas.schmitz@uni-bonn.de \
    /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).