From: "Thomas A. Schmitz via ntg-context" <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
Subject: Re: Xml filtering in Lua
Date: Sun, 20 Nov 2022 19:19:18 +0100 [thread overview]
Message-ID: <e7d0bcfe-2351-1a36-79bd-85dd81dbf6b0@uni-bonn.de> (raw)
In-Reply-To: <d70eb400-e843-3ddc-86ec-c4b4c6665200@xs4all.nl>
On 11/17/22 11:04, Hans Hagen via ntg-context wrote:
>
> so, basically you collect data and use it later ... for huge datasets
> that saves some time
>
> if you have only chapters to process you can even decide to flush in
> that function
Alright, I'm making very good progress here, but right now I'm stumbling
upon a problem I can't solve. It's difficult to make a minimal example,
so bear with some snippets.
I load data from an external xml file (not the one I'm processing) and
store some of it in a lua table.
local examples = lxml.load ("my_examples", "examples.xml")
local sets = lxml.load ("my_sets", "example_sets.xml")
for e in xml.collected (examples, "/examples/chapter/example") do
local ex_id = e.at.id
all_examples [ex_id] = e
end
This works as expected, with print (inspect (all_examples)), I can see
that the table looks the way I expect.
I then retrieve some entries of the table by their key:
local current_example = all_examples [key]
Again, this appears to work; when I have a
lxml.displayverbatim (current_example)
in my file, the xml is typeset and looks like I would expect it to look.
However, whatever I try, I get the serialized xml typeset, with all
<tags> verbatim, instead of processed. Here's what I've tried:
\startxmlsetups xml:chapter:example
\xmlfirst {#1} {.} \par
\stopxmlsetups
lxml.command (current_example, ".", "xml:chapter:example")
or
xml.sprint (lxml.id (current_example))
or
local problem = xml.text (lxml.id (current_example), "./[text()]")
xml.sprint (problem)
I was expecting at least the last version to retrieve the pure text, but
it typesets again with the tags included.
So I guess my question is: how can I tell ConTeXt to parse my xml as xml
and apply the proper setups instead of serializing it?
All best wishes
Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2022-11-20 18:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 16:10 Thomas A. Schmitz via ntg-context
2022-11-16 16:18 ` Duncan Hothersall via ntg-context
2022-11-16 17:33 ` Thomas A. Schmitz via ntg-context
2022-11-16 18:56 ` mf via ntg-context
2022-11-16 19:55 ` Thomas A. Schmitz via ntg-context
2022-11-16 20:51 ` Denis Maier via ntg-context
2022-11-16 21:09 ` Thomas A. Schmitz via ntg-context
2022-11-16 22:19 ` Hans Hagen via ntg-context
2022-11-16 19:56 ` mf via ntg-context
2022-11-17 10:04 ` Hans Hagen via ntg-context
2022-11-17 10:56 ` Thomas A. Schmitz via ntg-context
2022-11-20 18:19 ` Thomas A. Schmitz via ntg-context [this message]
2022-11-21 8:23 ` Thomas A. Schmitz via ntg-context
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=e7d0bcfe-2351-1a36-79bd-85dd81dbf6b0@uni-bonn.de \
--to=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).