From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/81049 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: processing xml with lua Date: Tue, 05 Mar 2013 11:11:42 +0100 Message-ID: <5135C4DE.50306@wxs.nl> References: <04D0A21F-FEAB-4F86-8317-6ED044B41619@uni-bonn.de> <512CB06E.8020206@wxs.nl> <92A8729E-7338-4EE3-8835-BE8A66DE748B@uni-bonn.de> <5135B134.10900@uni-bonn.de> <5135B3B3.8030407@wxs.nl> <5135B805.9010805@uni-bonn.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1362478314 4516 80.91.229.3 (5 Mar 2013 10:11:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Mar 2013 10:11:54 +0000 (UTC) Cc: mailing list for ConTeXt users To: "Thomas A. Schmitz" Original-X-From: ntg-context-bounces@ntg.nl Tue Mar 05 11:12:17 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UCor2-0003Dk-Ns for gctc-ntg-context-518@m.gmane.org; Tue, 05 Mar 2013 11:12:16 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E8E8F101FE; Tue, 5 Mar 2013 11:11:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IODzzpT6qDRS; Tue, 5 Mar 2013 11:11:51 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 3DC64101E8; Tue, 5 Mar 2013 11:11:51 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6B053101E8 for ; Tue, 5 Mar 2013 11:11:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id soNU2RngXcOB for ; Tue, 5 Mar 2013 11:11:44 +0100 (CET) Original-Received: from filter1-til.mf.surf.net (filter1-til.mf.surf.net [194.171.167.217]) by balder.ntg.nl (Postfix) with ESMTP id AC37A101E6 for ; Tue, 5 Mar 2013 11:11:44 +0100 (CET) Original-Received: from smtp.ziggozakelijk.nl (D57D1DA2.static.ziggozakelijk.nl [213.125.29.162]) by filter1-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r25ABhkn006825 for ; Tue, 5 Mar 2013 11:11:44 +0100 X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.100; Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by pragma-net.nl (SurgeMail 6.1c) with ESMTP (TLS) id 10049-1713362 for multiple; Tue, 05 Mar 2013 11:11:42 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.2; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: <5135B805.9010805@uni-bonn.de> X-Authenticated-User: hagen@controller-9 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=213.125.29.162; country=NL; latitude=52.5000; longitude=5.7500; http://maps.google.com/maps?q=52.5000,5.7500&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0RJ7KbHyS - 2337e8286d03 - 20130305 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.217 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:81049 Archived-At: On 3/5/2013 10:16 AM, Thomas A. Schmitz wrote: > On 03/05/2013 09:58 AM, Hans Hagen wrote: >> lookuptable[mytype] = mytype .. " = " .. myvalue >> inspect(lookuptable) >> >> the .. triggers a tostring on myvalue which in turn serializes the xml >> >> lookuptable[mytype] = { mytype = myvalue } >> >> would keep myvalue as xml node > > Hans, thanks a lot, the explanation makes sense, but your suggestion is > not yet clear enough for me: how would I then process the node? > > context(lookuptable[mytype]["mytype"]) > > gives again the serialized xml. \startluacode local lookuptable = { } function xml.functions.lookup(t) local mytype = xml.text(t, "c") local myvalue = lookuptable[mytype] if not myvalue then myvalue = xml.first(t, "d") lookuptable[mytype] = myvalue context("registered: ") else context("reused: ") end -- each found node gets an id lxml.flush(lxml.id(myvalue)) context(" or ") -- in tex mode a to-tex serializer is the default xml.cprint(myvalue) end \stopluacode One place to look for tricks is in x-mathml.mkiv / lua (I know, I should finish that manual). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ 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 ___________________________________________________________________________________