From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: NTG ConTeXt <ntg-context@ntg.nl>
Subject: [NTG-context] Re: expanded doif's
Date: Mon, 17 Jun 2024 16:52:36 +0200 [thread overview]
Message-ID: <70c27b56-aeae-9f99-80db-94eb06fb0410@gmail.com> (raw)
In-Reply-To: <45BCE2B3-7B0E-4D7B-B164-BB610C5DF23F@ziggo.nl>
Hans van der Meer schrieb am 17.06.2024 um 09:01:
> I want to show an errormessage when the macro is undefined. It requires
> expansion of \xmlatt{#1}{name}.
> \ifdefined\xmlatt{#1}{name} didn't worked nor \expandafter\ifdefined
> I thought of the expanding \doif's.
>
> See the attached output of this xmlsetup attached.
>
> \startxmlsetups hvdm:system:macrocall
> %
> \doifelsedefined{\xmlatt{#1}{name}}
> {
> %
> %macro without argument
> %
> \ifxmlattempty{#1}{arg}
> \begincsname\xmlatt{#1}{name}\endcsname
> %
> %macro with argument
> %
> \else
> \begincsname\xmlatt{#1}{name}\endcsname{\xmlatt{#1}{arg}}
> \fi
> }
> {
> \ERROR{macro \xmlatt{#1}{name} is not defined}
> }
> \stopxmlsetups
I have no idea what's wrong in your code without a proper minimal
example. As the example below shows you can use \doifelsedefined in
combination with \xmlatt.
\startbuffer[ifdefined]
<document>
<macro name="bold" arg="text"/>
<macro name="hvdm" arg="text"/>
</document>
\stopbuffer
\startxmlsetups xml:document
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:macro
\doifelsedefined{\xmlatt{#1}{name}}
{\texdefinition{\xmlatt{#1}{name}}{\xmlatt{#1}{arg}}}
{{\tttf macro \tex{\xmlatt{#1}{name}} not defined}}
% \ifcsname\xmlatt{#1}{name}\endcsname
% \lastnamedcs{\xmlatt{#1}{arg}}
% \else
% %
% \fi
\stopxmlsetups
\startxmlsetups xml:hvdm
\xmlsetsetup{\xmldocument}{document|macro}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:hvdm}
\starttext
\xmlprocessbuffer{hvdm}{ifdefined}{}
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2024-06-17 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-16 20:29 [NTG-context] " Hans van der Meer via ntg-context
2024-06-16 22:03 ` [NTG-context] " Wolfgang Schuster
[not found] ` <45BCE2B3-7B0E-4D7B-B164-BB610C5DF23F@ziggo.nl>
2024-06-17 14:52 ` Wolfgang Schuster [this message]
2024-06-17 16:55 ` Pablo Rodriguez via ntg-context
2024-06-18 9:38 ` Hans van der Meer 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=70c27b56-aeae-9f99-80db-94eb06fb0410@gmail.com \
--to=wolfgang.schuster.lists@gmail.com \
--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).