ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* wildcard selection in xmlfilter
@ 2018-09-12 11:03 Hans van der Meer
  2018-09-12 11:23 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Hans van der Meer @ 2018-09-12 11:03 UTC (permalink / raw)
  To: NTG ConTeXt


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

There is a difference of behaviour in \xmlfilter between 
(1) \xmlfilter{#1}{node/command(xmlsetup)} and
(2) \xmlfilter{#1}{*/command(xmlsetup)}
(3) \xmlfilter{#1}{*/*/command(xmlsetup)}

In case (1) the lpath ‘node’ results in processing of the <wildcard> nodes in all child nodes.
In case (2) and (3) no more than the corresponding level is searched.

Thus there is a difference in behaviour between node and * as an lpath.
Very unfortunate for me, because I need to process all nodes regardless of theeir node name, but selected on the basis of an attribute: \xmlfilter{#1}{*[@attribute==“yes”]. 
The difference in behaviour makes this impossible, because a general proceudre is impossible and doing a search with * and */* and */*/* etc. always will be one level too short, I expect.

Is this intended behaviour, and if so, is there a general solution?

dr. Hans van der Meer


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

[-- Attachment #1.2.2: test.pdf --]
[-- Type: application/pdf, Size: 15694 bytes --]

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

[-- Attachment #1.2.4: test.tex --]
[-- Type: application/octet-stream, Size: 1208 bytes --]

\startxmlsetups xml:testsetups
	\xmlsetsetup{test}{test|subnode}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:testsetups}

\startxmlsetups xml:shownamed
	<\xmltag{#1}> from <\xmltext{#1}{../tag()}> \type{wildcard[@selector=="yes"]}: \xmlflush{#1}\crlf
\stopxmlsetups
\startxmlsetups xml:showstarred
	<\xmltag{#1}> from <\xmltext{#1}{../tag()}> \type{*[@selector=="yes"]}: \xmlflush{#1}\crlf
\stopxmlsetups
\startxmlsetups xml:showdoublestarred
	<\xmltag{#1}> from <\xmltext{#1}{../tag()}> \type{*/*[@selector=="yes"]}: \xmlflush{#1}\crlf
\stopxmlsetups

\startxmlsetups xml:test
	\xmlfilter{#1}{wildcard[@selector=="yes"]/command(xml:shownamed)}\crlf
	\xmlfilter{#1}{*[@selector=="yes"]/command(xml:showstarred)}\crlf
	\xmlfilter{#1}{*/*[@selector=="yes"]/command(xml:showdoublestarred)}\crlf
\stopxmlsetups

\startxmlsetups xml:subnode
	Inside \xmltag{#1}\space\xmlflush{#1}
\stopxmlsetups

\startbuffer[test]
<test>
	<wildcard selector="yes">WILDCARD-1</wildcard>
	<subnode>
		<wildcard selector="yes">WILDCARD-2</wildcard>
	</subnode>
</test>
\stopbuffer

\starttext
\currentdate-\currenttime\quad\ConTeXt-version=\contextversion\blank
{\bf Testing wildcard}\par
\xmlprocessbuffer{test}{test}{}

\stoptext

[-- Attachment #1.2.5: Type: text/html, Size: 226 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: wildcard selection in xmlfilter
  2018-09-12 11:03 wildcard selection in xmlfilter Hans van der Meer
@ 2018-09-12 11:23 ` Hans Hagen
  2018-09-12 11:27   ` Hans van der Meer
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2018-09-12 11:23 UTC (permalink / raw)
  To: Hans van der Meer,
	ntg-context@ntg.nl >> mailing list for ConTeXt users

On 9/12/2018 1:03 PM, Hans van der Meer wrote:
> There is a difference of behaviour in \xmlfilter between
> (1) \xmlfilter{#1}{node/command(xmlsetup)} and
> (2) \xmlfilter{#1}{*/command(xmlsetup)}
> (3) \xmlfilter{#1}{*/*/command(xmlsetup)}
> 
> In case (1) the lpath ‘node’ results in processing of the <wildcard> 
> nodes in all child nodes.
> In case (2) and (3) no more than the corresponding level is searched.
> 
> Thus there is a difference in behaviour between node and * as an lpath.
> Very unfortunate for me, because I need to process all nodes regardless 
> of theeir node name, but selected on the basis of an attribute: 
> \xmlfilter{#1}{*[@attribute==“yes”].
> The difference in behaviour makes this impossible, because a general 
> proceudre is impossible and doing a search with * and */* and */*/* etc. 
> always will be one level too short, I expect.
> 
> Is this intended behaviour, and if so, is there a general solution?

did you try **

-----------------------------------------------------------------
                                           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 / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: wildcard selection in xmlfilter
  2018-09-12 11:23 ` Hans Hagen
@ 2018-09-12 11:27   ` Hans van der Meer
  0 siblings, 0 replies; 3+ messages in thread
From: Hans van der Meer @ 2018-09-12 11:27 UTC (permalink / raw)
  To: Hans Hagen; +Cc: NTG ConTeXt


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

No, never thought of ** instead of *. Also not in my printout of the manual, but that might be fairly outdated.
Thanks.

By the way, did you see my post on \xmllastatt from yesterday?

> On 12 Sep 2018, at 13:23, Hans Hagen <j.hagen@xs4all.nl> wrote:
> 
> On 9/12/2018 1:03 PM, Hans van der Meer wrote:
>> There is a difference of behaviour in \xmlfilter between
>> (1) \xmlfilter{#1}{node/command(xmlsetup)} and
>> (2) \xmlfilter{#1}{*/command(xmlsetup)}
>> (3) \xmlfilter{#1}{*/*/command(xmlsetup)}
>> In case (1) the lpath ‘node’ results in processing of the <wildcard> nodes in all child nodes.
>> In case (2) and (3) no more than the corresponding level is searched.
>> Thus there is a difference in behaviour between node and * as an lpath.
>> Very unfortunate for me, because I need to process all nodes regardless of theeir node name, but selected on the basis of an attribute: \xmlfilter{#1}{*[@attribute==“yes”].
>> The difference in behaviour makes this impossible, because a general proceudre is impossible and doing a search with * and */* and */*/* etc. always will be one level too short, I expect.
>> Is this intended behaviour, and if so, is there a general solution?
> 
> did you try **
> 
> -----------------------------------------------------------------
>                                          Hans Hagen | PRAGMA ADE
>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------

dr. Hans van der Meer



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

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2018-09-12 11:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 11:03 wildcard selection in xmlfilter Hans van der Meer
2018-09-12 11:23 ` Hans Hagen
2018-09-12 11:27   ` Hans van der Meer

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