ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] ifxmlselfempty
@ 2023-09-03 12:11 Hans van der Meer via ntg-context
  2023-09-04  8:05 ` [NTG-context] ifxmlselfempty denis.maier
  0 siblings, 1 reply; 4+ messages in thread
From: Hans van der Meer via ntg-context @ 2023-09-03 12:11 UTC (permalink / raw)
  To: NTG ConTeXt; +Cc: Hans van der Meer


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

Is it possible that  the new \ifxmlselfempty has reversed its outcome? Or did I something wrong in this MWE?
Here an MWE.

yours sincerely
dr. Hans van der Meer




\startbuffer[test]
<what>
<emptynode value="!empty node!"/>
<notemptynode>!not empty node!</notemptynode>
</what>
\stopbuffer

\startxmlsetups xml:mysetups
   \xmlsetsetup{\xmldocument}{something|emptynode|notemptynode}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:mysetups}

\startxmlsetups xml:emptynode
node=\xmltag{#1}:\crlf
ifxmlselfempty-else-fi:\space
\ifxmlselfempty{#1}
	attribute = \xmlatt{#1}{value}
\else
	content = \xmlflush{#1}
\fi
\crlf
ifxmlselfempty-else-fi reversed:\space
\ifxmlselfempty{#1}
	content = \xmlflush{#1}
\else
	attribute = \xmlatt{#1}{value}
\fi
\blank
\stopxmlsetups

\startxmlsetups xml:notemptynode
node=\xmltag{#1}:\crlf
ifxmlselfempty-else-fi:\space
\ifxmlselfempty{#1}
	attribute = \xmlatt{#1}{value}
\else
	content = \xmlflush{#1}
\fi
\crlf
ifxmlselfempty-else-fi reversed:\space
\ifxmlselfempty{#1}
	content = \xmlflush{#1}
\else
	attribute = \xmlatt{#1}{value}
\fi
\blank
\stopxmlsetups

\startxmlsetups xml:something
\xmlall{#1}{./emptynode}\blank
\xmlall{#1}{./notemptynode}\blank
\stopxmlsetups

\starttext
\ConTeXt\ \contextversion\blank
   \xmlprocessbuffer{main}{test}{}
\stoptext


[-- Attachment #1.2.1: Type: text/html, Size: 763 bytes --]

[-- Attachment #1.2.2: xmlsetup-template.pdf --]
[-- Type: application/pdf, Size: 8866 bytes --]

[-- Attachment #1.2.3: Type: text/html, Size: 4371 bytes --]

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

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

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

* [NTG-context] Re: ifxmlselfempty
  2023-09-03 12:11 [NTG-context] ifxmlselfempty Hans van der Meer via ntg-context
@ 2023-09-04  8:05 ` denis.maier
  2023-09-04 18:20   ` Hans van der Meer via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: denis.maier @ 2023-09-04  8:05 UTC (permalink / raw)
  To: ntg-context


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

IDK. But why do have a setup for <something>, which does not appear in your xml source (shouldn't it be <what>?)?


Von: Hans van der Meer via ntg-context <ntg-context@ntg.nl>
Gesendet: Sonntag, 3. September 2023 14:11
An: NTG ConTeXt <ntg-context@ntg.nl>
Cc: Hans van der Meer <havdmeer@ziggo.nl>
Betreff: [NTG-context] ifxmlselfempty

Is it possible that  the new \ifxmlselfempty has reversed its outcome? Or did I something wrong in this MWE?
Here an MWE.

yours sincerely
dr. Hans van der Meer



\startbuffer[test]
<what>
<emptynode value="!empty node!"/>
<notemptynode>!not empty node!</notemptynode>
</what>
\stopbuffer

\startxmlsetups xml:mysetups
   \xmlsetsetup{\xmldocument}{something|emptynode|notemptynode}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:mysetups}

\startxmlsetups xml:emptynode
node=\xmltag{#1}:\crlf
ifxmlselfempty-else-fi:\space
\ifxmlselfempty{#1}
attribute = \xmlatt{#1}{value}
\else
content = \xmlflush{#1}
\fi
\crlf
ifxmlselfempty-else-fi reversed:\space
\ifxmlselfempty{#1}
content = \xmlflush{#1}
\else
attribute = \xmlatt{#1}{value}
\fi
\blank
\stopxmlsetups

\startxmlsetups xml:notemptynode
node=\xmltag{#1}:\crlf
ifxmlselfempty-else-fi:\space
\ifxmlselfempty{#1}
attribute = \xmlatt{#1}{value}
\else
content = \xmlflush{#1}
\fi
\crlf
ifxmlselfempty-else-fi reversed:\space
\ifxmlselfempty{#1}
content = \xmlflush{#1}
\else
attribute = \xmlatt{#1}{value}
\fi
\blank
\stopxmlsetups

\startxmlsetups xml:something
\xmlall{#1}{./emptynode}\blank
\xmlall{#1}{./notemptynode}\blank
\stopxmlsetups

\starttext
\ConTeXt\ \contextversion\blank
   \xmlprocessbuffer{main}{test}{}
\stoptext


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

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

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

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

* [NTG-context] Re: ifxmlselfempty
  2023-09-04  8:05 ` [NTG-context] ifxmlselfempty denis.maier
@ 2023-09-04 18:20   ` Hans van der Meer via ntg-context
  2023-09-04 18:28     ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Hans van der Meer via ntg-context @ 2023-09-04 18:20 UTC (permalink / raw)
  To: NTG ConTeXt; +Cc: Hans van der Meer


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

I changed this in the source of lxml-ini.lua (line 225). It seems the 'not' has been accidentally crept in (from  copying that line in ifxmlempty, the item above?)
Anyway, remade the format and now the result is as I expected it to be. See below in the output of the MWE from my first post on this subject. I added the relevant portion of the code for clarity.

I am sure the next update will reflect it in the source ;-)

dr. Hans van der Meer

   implement {
        name      = "ifxmlselfempty",
        public    = true,
        usage     = "condition",
        arguments = "argument",
        actions   = function(id)
--            return boolean_code, not checkedempty(getid(id)) and true
            return boolean_code, checkedempty(getid(id)) and true
        end
    }



> On 4 Sep 2023, at 10:05, denis.maier@unibe.ch wrote:
> 
> IDK. But why do have a setup for <something>, which does not appear in your xml source (shouldn’t it be <what>?)?
>  
>  
> Von: Hans van der Meer via ntg-context <ntg-context@ntg.nl <mailto:ntg-context@ntg.nl>> 
> Gesendet: Sonntag, 3. September 2023 14:11
> An: NTG ConTeXt <ntg-context@ntg.nl <mailto:ntg-context@ntg.nl>>
> Cc: Hans van der Meer <havdmeer@ziggo.nl <mailto:havdmeer@ziggo.nl>>
> Betreff: [NTG-context] ifxmlselfempty
>  
> Is it possible that  the new \ifxmlselfempty has reversed its outcome? Or did I something wrong in this MWE?
> Here an MWE.
>  
> yours sincerely
> dr. Hans van der Meer
>  
>  
>  
> \startbuffer[test]
> <what>
> <emptynode value="!empty node!"/>
> <notemptynode>!not empty node!</notemptynode>
> </what>
> \stopbuffer
>  
> \startxmlsetups xml:mysetups
>    \xmlsetsetup{\xmldocument}{something|emptynode|notemptynode}{xml:*}
> \stopxmlsetups
>  
> \xmlregistersetup{xml:mysetups}
>  
> \startxmlsetups xml:emptynode
> node=\xmltag{#1}:\crlf
> ifxmlselfempty-else-fi:\space
> \ifxmlselfempty{#1}
> attribute = \xmlatt{#1}{value}
> \else
> content = \xmlflush{#1}
> \fi
> \crlf
> ifxmlselfempty-else-fi reversed:\space
> \ifxmlselfempty{#1}
> content = \xmlflush{#1}
> \else
> attribute = \xmlatt{#1}{value}
> \fi
> \blank
> \stopxmlsetups
>  
> \startxmlsetups xml:notemptynode
> node=\xmltag{#1}:\crlf
> ifxmlselfempty-else-fi:\space
> \ifxmlselfempty{#1}
> attribute = \xmlatt{#1}{value}
> \else
> content = \xmlflush{#1}
> \fi
> \crlf
> ifxmlselfempty-else-fi reversed:\space
> \ifxmlselfempty{#1}
> content = \xmlflush{#1}
> \else
> attribute = \xmlatt{#1}{value}
> \fi
> \blank
> \stopxmlsetups
>  
> \startxmlsetups xml:something
> \xmlall{#1}{./emptynode}\blank
> \xmlall{#1}{./notemptynode}\blank
> \stopxmlsetups
>  
> \starttext
> \ConTeXt\ \contextversion\blank
>    \xmlprocessbuffer{main}{test}{}
> \stoptext


[-- Attachment #1.2.1: Type: text/html, Size: 1438 bytes --]

[-- Attachment #1.2.2: xmlsetup-template.pdf --]
[-- Type: application/pdf, Size: 13788 bytes --]

[-- Attachment #1.2.3: Type: text/html, Size: 14001 bytes --]

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

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

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

* [NTG-context] Re: ifxmlselfempty
  2023-09-04 18:20   ` Hans van der Meer via ntg-context
@ 2023-09-04 18:28     ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2023-09-04 18:28 UTC (permalink / raw)
  To: Hans van der Meer, NTG ConTeXt

On 9/4/2023 8:20 PM, Hans van der Meer wrote:
> I changed this in the source of lxml-ini.lua (line 225). It seems the 'not' has been accidentally crept in (from  copying that line in ifxmlempty, the item above?)
> Anyway, remade the format and now the result is as I expected it to be. See below in the output of the MWE from my first post on this subject. I added the relevant portion of the code for clarity.
> 
> I am sure the next update will reflect it in the source ;-)

only if you also test ifxmlempty as it has similar code

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

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

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

end of thread, other threads:[~2023-09-04 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-03 12:11 [NTG-context] ifxmlselfempty Hans van der Meer via ntg-context
2023-09-04  8:05 ` [NTG-context] ifxmlselfempty denis.maier
2023-09-04 18:20   ` Hans van der Meer via ntg-context
2023-09-04 18:28     ` Hans Hagen

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