From: WN <wneimeijer@tiscali.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: luatex and xml
Date: Sun, 18 May 2008 02:20:00 +0200 [thread overview]
Message-ID: <482F7630.70401@tiscali.nl> (raw)
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
<?xml version='1.0 standalone='yes' ?>
<factuur>
<nummer>123456789</nummer>
<datum>1 januari 2008</datum>
<medewerker></medewerker>
<regels>
<omschrijving>Omschrijving geleverde dienst a</omschrijving>
<bedrag>1500,00</bedrag>
<omschrijving>Omschrijving geleverde dienst b</omschrijving>
<bedrag>200,00</bedrag>
</regels>
</factuur>
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
___________________________________________________________________________________
next reply other threads:[~2008-05-18 0:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-18 0:20 WN [this message]
2008-05-18 8:21 ` Wolfgang Schuster
2008-05-18 13:23 ` WN
2008-05-18 14:23 ` 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=482F7630.70401@tiscali.nl \
--to=wneimeijer@tiscali.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).