ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] expanded doif's
@ 2024-06-16 20:29 Hans van der Meer via ntg-context
  2024-06-16 22:03 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Hans van der Meer via ntg-context @ 2024-06-16 20:29 UTC (permalink / raw)
  To: NTG ConTeXt; +Cc: Hans van der Meer


[-- Attachment #1.1: Type: text/plain, Size: 264 bytes --]

I  remember there was an incantation to work with expanded doif's etc. 
In this case I need \doifelsedefined{ARG} with ARG expanded.
I lost the exact spelling of the command and dldn't find it in the garden. 
What was it?

yours sincerely
dr. Hans van der Meer




[-- Attachment #1.2: Type: text/html, Size: 897 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: expanded doif's
  2024-06-16 20:29 [NTG-context] expanded doif's Hans van der Meer via ntg-context
@ 2024-06-16 22:03 ` Wolfgang Schuster
       [not found]   ` <45BCE2B3-7B0E-4D7B-B164-BB610C5DF23F@ziggo.nl>
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2024-06-16 22:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans van der Meer via ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 382 bytes --]

Hans van der Meer via ntg-context schrieb am 16.06.2024 um 22:29:
> I  remember there was an incantation to work with expanded doif's etc.
> In this case I need \doifelsedefined{ARG} with ARG expanded.
> I lost the exact spelling of the command and dldn't find it in the 
> garden.
> What was it?

Can you provide a example where you have problems with \doifdefined etc.

Wolfgang


[-- Attachment #1.2: Type: text/html, Size: 890 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: expanded doif's
       [not found]   ` <45BCE2B3-7B0E-4D7B-B164-BB610C5DF23F@ziggo.nl>
@ 2024-06-17 14:52     ` Wolfgang Schuster
  2024-06-17 16:55       ` Pablo Rodriguez via ntg-context
  2024-06-18  9:38       ` Hans van der Meer via ntg-context
  0 siblings, 2 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2024-06-17 14:52 UTC (permalink / raw)
  To: NTG ConTeXt

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: expanded doif's
  2024-06-17 14:52     ` Wolfgang Schuster
@ 2024-06-17 16:55       ` Pablo Rodriguez via ntg-context
  2024-06-18  9:38       ` Hans van der Meer via ntg-context
  1 sibling, 0 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-06-17 16:55 UTC (permalink / raw)
  To: ntg-context; +Cc: Pablo Rodriguez

On 6/17/24 16:52, Wolfgang Schuster wrote:
> 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}.

dr. van der Meer,

\xmldoifatt (with ifnot and ifelse variants) should cover that case
(https://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#search=xmldoifatt).

But I cannot make any of these conditionals work (I‘m afraid there may
be an issue with their definition).

  \startbuffer[ifdefined]
  <document>
    <macro name="bold" arg="text"/>
    <macro name="hvdm" arg="text"/>
  </document>
  \stopbuffer

  \startxmlsetups xml:hvdm
    \xmlsetsetup{#1}{*}{xml:*}
  \stopxmlsetups

  \xmlregistersetup{xml:hvdm}

  \startxmlsetups xml:document
    \xmlflush{#1}
  \stopxmlsetups

  \startxmlsetups xml:macro
    \xmlatt{#1}{name}\\
    \xmlatt{#1}{arg}\\
    \xmldoifelseatt{#1}
    {name}{yes}{no}\\
    \xmldoifelseatt{#1}
    {names}{yes}{no}\\
  \stopxmlsetups

  \starttext
  \xmlprocessbuffer{hvdm}{ifdefined}{}
  \stoptext

As a workaround \doifelsetext{\xmlatt{#1}{name}}{yes}{no} may do the
trick here.

I hope it helps,

Pablo
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: expanded doif's
  2024-06-17 14:52     ` Wolfgang Schuster
  2024-06-17 16:55       ` Pablo Rodriguez via ntg-context
@ 2024-06-18  9:38       ` Hans van der Meer via ntg-context
  1 sibling, 0 replies; 5+ messages in thread
From: Hans van der Meer via ntg-context @ 2024-06-18  9:38 UTC (permalink / raw)
  To: NTG ConTeXt; +Cc: Hans van der Meer


[-- Attachment #1.1: Type: text/plain, Size: 2539 bytes --]

Finally found the culprit. Macro call to restart reporting errors in the printed output residing at the wrong point in the code.
Again thanks for pointing out where it was not.

yours sincerely
dr. Hans van der Meer



> On 17 Jun 2024, at 16:52, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
> 
> 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
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 3406 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-18  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-16 20:29 [NTG-context] expanded doif's 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
2024-06-17 16:55       ` Pablo Rodriguez via ntg-context
2024-06-18  9:38       ` Hans van der Meer via ntg-context

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).