From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/41091 Path: news.gmane.org!not-for-mail From: WN Newsgroups: gmane.comp.tex.context Subject: Re: luatex and xml Date: Sun, 18 May 2008 15:23:10 +0200 Message-ID: <48302DBE.3040901@tiscali.nl> References: <482F7630.70401@tiscali.nl> <20080518102149.a3ef04a5.schuster.wolfgang@googlemail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1211116983 24823 80.91.229.12 (18 May 2008 13:23:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 May 2008 13:23:03 +0000 (UTC) Cc: mailing list for ConTeXt users To: schuster.wolfgang@googlemail.com Original-X-From: ntg-context-bounces@ntg.nl Sun May 18 15:23:40 2008 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1JxirQ-0003d8-MP for gctc-ntg-context-518@m.gmane.org; Sun, 18 May 2008 15:23:36 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 6B95A1FC90; Sun, 18 May 2008 15:22:50 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25881-02-6; Sun, 18 May 2008 15:22:12 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 76EDE1FC82; Sun, 18 May 2008 15:22:09 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 7F6D01FC71 for ; Sun, 18 May 2008 15:22:03 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25881-02-5 for ; Sun, 18 May 2008 15:21:24 +0200 (CEST) Original-Received: from smtp-out3.tiscali.nl (smtp-out3.tiscali.nl [195.241.79.178]) by ronja.ntg.nl (Postfix) with ESMTP id D0BCB1FC98 for ; Sun, 18 May 2008 15:20:13 +0200 (CEST) Original-Received: from [212.123.161.245] (helo=[192.168.1.36]) by smtp-out3.tiscali.nl with esmtp id 1Jxio9-0000fG-NL; Sun, 18 May 2008 15:20:13 +0200 User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: <20080518102149.a3ef04a5.schuster.wolfgang@googlemail.com> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:41091 Archived-At: Thanks Wolfgang for your time and the attachments you send me. I don't want to sound ungrateful for the hard work and for the nice module you send me, but I was looking for another solution where I don't have to use Context macro's and setups. I want to use a little bit of lua code to get to the data I want. I think I will have greater control independent of the xml macro's (to be honest I find them difficult to understand). The solution I am looking for, is to use the function xml.filter (defined in l-xml.lua) and to assign the outcome to local variables. Kind regards Wim > Hi, > > take a look into invoice.tex in my attachment. > > Wolfgang > > On Sun, 18 May 2008 02:20:00 +0200 > WN wrote: > >> Hi, >> >> I am trying to parse a xml file with mkiv to process a list of invoices >> (factuur in dutch). >> >> The xml file looks like this >> >> >> >> 123456789 >> 1 januari 2008 >> >> >> Omschrijving geleverde dienst a >> 1500,00 >> Omschrijving geleverde dienst b >> 200,00 >> >> >> >> I want to extract and sum the invoices (regels). I managed to get things >> working (printing) >> but don't know how to assign these values into lua variables for the >> summing. >> The test code looks like this >> >> % engine=luatex >> \starttext >> >> \startluacode >> document.xml = document.xml or { } -- define namespace >> document.xml = xml.load("factuur.xml") -- load the file >> n = xml.count(document.xml, "/factuur/regels/omschrijving") >> >> for i = 1, n do >> -- >> -- here I want to assign the values returned by xml.filter into local >> variable amount >> -- >> >> xml.sprint(xml.filter(document.xml, "/factuur/regels/bedrag/position(" >> .. i .. ")" )) >> >> end >> \stopluacode >> \stoptext >> >> Kind regards >> WN >> ___________________________________________________________________________________ >> 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 : https://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 : https://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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________