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: Wed, 16 Nov 2022 18:33:07 +0100 [thread overview]
Message-ID: <FAB9230D-FE0E-4CBE-A98F-F4F403A50D67@uni-bonn.de> (raw)
In-Reply-To: <CAN8fp9UmyUDf798zNXKeagsPmUe+hPAPnaCz-mb7bJwMYTWw5Q@mail.gmail.com>
Hi Duncan,
Thank you for pointing this out! I knew this was true inside the xmlns namespace, so you can’t have identical xml:id tags, but you’re probably right that it’s better to avoid this confusion altogether. Alas, this doesn’t help with my problem. Since there was a type in my minimal example from my experimentations, I include a corrected version, avoiding the identical tags
All best
Thomas
\startbuffer[test]
<document>
<topics>
<topic t:id="test1">
<title>This is the first test</title>
<date>22/11/16</date>
</topic>
<topic t:id="test2">
<title>This is the second test</title>
<date>22/11/17</date>
</topic>
</topics>
<chapters>
<chapter ch:id="test1">
<content>
This will be the content of the <emph>first</emph> chapter.
</content>
</chapter>
<chapter ch:id="test2">
<content>
This will be the content of the <emph>second</emph> chapter.
</content>
</chapter>
</chapters>
</document>
\stopbuffer
\startxmlsetups xml:testsetups
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{document|chapters|chapter|content|emph}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:testsetups}
\startxmlsetups xml:document
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:chapters
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:chapter
\xmlfunction {#1} {chapter}
\xmlflush {#1}
\stopxmlsetups
\startxmlsetups xml:chapter:content
\xmltext {#1} {content}
\stopxmlsetups
\startxmlsetups xml:emph
{\em \xmlflush {#1}}
\stopxmlsetups
\startluacode
function xml.functions.chapter (t)
local ch_id = t.at.ch:id
local metadata = xml.filter (t, '../../topics/topic[@t:id=="%s"]', ch_id)
print (inspect(metadata))
lxml.command(t, ".", "xml:chapter:content")
context.par ()
context (ch_id)
context.par ()
end
\stopluacode
> On 16. Nov 2022, at 17:18, Duncan Hothersall via ntg-context <ntg-context@ntg.nl> wrote:
>
> I'm not sure about the code, sorry, but I do know that an XML document can't have two IDs of the same value. Typically you would use a linkend attribute on the element which is referencing an id (in this case the topics, I think).
>
> Probably doesn't help with your problem, but it's likely a prerequisite for it to work.
>
> Bests,
>
> Duncan
___________________________________________________________________________________
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-16 17:33 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 [this message]
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
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=FAB9230D-FE0E-4CBE-A98F-F4F403A50D67@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).