[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-25 Thread Hans Hagen

On 8/25/2023 1:45 PM, denis.ma...@unibe.ch wrote:

-Ursprüngliche Nachricht-
Von: Hans Hagen 
Gesendet: Freitag, 25. August 2023 09:06
An: Maier, Denis Christian (UB) ; mailing list for
ConTeXt users 
Betreff: Re: [NTG-context] Re: xmldoif: checking for contents of attribute

On 8/25/2023 8:22 AM, denis.ma...@unibe.ch wrote:


Thanks for your help. I can use that, but why is this sort of double-checking

necessary here?

because containsa in a function that has checking while find is just the lua 
find
.. so i've added a check in that one too now but no upload



So, that would mean that the double checking is only necessary for find, not 
for contains. And indeed the example below works.
Is that correct or are there any unwanted side-effects?

correct and in the next upload i'll also catch the find

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

[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-25 Thread denis.maier
> -Ursprüngliche Nachricht-
> Von: Hans Hagen 
> Gesendet: Freitag, 25. August 2023 09:06
> An: Maier, Denis Christian (UB) ; mailing list for
> ConTeXt users 
> Betreff: Re: [NTG-context] Re: xmldoif: checking for contents of attribute
> 
> On 8/25/2023 8:22 AM, denis.ma...@unibe.ch wrote:
> 
> > Thanks for your help. I can use that, but why is this sort of 
> > double-checking
> necessary here?
> 
> because containsa in a function that has checking while find is just the lua 
> find
> .. so i've added a check in that one too now but no upload
> 

So, that would mean that the double checking is only necessary for find, not 
for contains. And indeed the example below works.
Is that correct or are there any unwanted side-effects?

\startxmlsetups xml:test
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{doc|element}{xml:*}
\stopxmlsetups

\xmlregisterdocumentsetup{test}{xml:test}

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

\startxmlsetups xml:element
1 \xmldoifelse{#1}{.[contains(@class,'abc')]}{Yes}{No} \par
2 \xmldoifelse{#1}{.[@class and find(@class,'abc')]}{Yes}{No} \par % runs, but 
no match

\stopxmlsetups

\startxmlsetups xml:whatever
Yes
\stopxmlsetups

\startbuffer[test]


Yes
No

\stopbuffer

\starttext

\xmlprocessbuffer{test}{test}{}

\stoptext


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


[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-25 Thread Hans Hagen

On 8/25/2023 8:22 AM, denis.ma...@unibe.ch wrote:


Thanks for your help. I can use that, but why is this sort of double-checking 
necessary here?


because containsa in a function that has checking while find is just the 
lua find .. so i've added a check in that one too now but no upload


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
___


[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-25 Thread denis.maier
> -Ursprüngliche Nachricht-
> Von: Thomas A. Schmitz 
> Gesendet: Donnerstag, 24. August 2023 16:35
> An: mailing list for ConTeXt users 
> Betreff: [NTG-context] Re: xmldoif: checking for contents of attribute
> 
> 
> One way would be to do the search in Lua; when you have multiple searches
> to perform, that may be the easiest way to go. For example:
> 
...
> 
> Hope that gets you started.
> 
> Thomas

Thank you, Thomas. Yes, that get's me started. But same question applies this 
solution too: Why do you need to double check? (I guess the answer will 
probably be the same.)

Anyway, it looks like I should really look more into Lua as this will probably 
make a few things much easier.

Best,
Denis
___
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
___


[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-25 Thread denis.maier
> -Ursprüngliche Nachricht-
> Von: Hans Hagen 
> Gesendet: Donnerstag, 24. August 2023 16:54
> An: ntg-context@ntg.nl
> Betreff: [NTG-context] Re: xmldoif: checking for contents of attribute
> 
> On 8/24/2023 4:11 PM, denis.ma...@unibe.ch wrote:
> > Hi,
> >
> > I'm trying to check whether an attribute contains (or, actually starts 
> > with) a
> given string.


> \xmldoifelse{#1}{.[@class and contains(@class,'abc')]}{Yes}{No}
> \xmldoifelse{#1}{.[@class and find(@class,"abc")]}{Yes}{No}

Thanks for your help. I can use that, but why is this sort of double-checking 
necessary here?

\startxmlsetups xml:test
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{doc|element}{xml:*}
\stopxmlsetups

\xmlregisterdocumentsetup{test}{xml:test}

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

\startxmlsetups xml:element
1 \xmldoifelse{#1}{.[@class and contains(@class,'abc')]}{Yes}{No} \par
2 \xmldoifelse{#1}{.[@class and find(@class,"abc")]}{Yes}{No} \par
3 \xmldoifelse{#1}{.[True and contains(@class,'abc')]}{Yes}{No} \par % runs, 
but no match
4 \xmldoifelse{#1}{.[True and find(@class,"abc")]}{Yes}{No} \par % run, but no 
match
% 5 \xmldoifelse{#1}{.[contains(@class,'abc')]}{Yes}{No} \par % causes an error
% 6 \xmldoifelse{#1}{.[find(@class,"abc")]}{Yes}{No} \par % causes an error

\stopxmlsetups

\startxmlsetups xml:whatever
Yes
\stopxmlsetups

\startbuffer[test]


Yes
No

\stopbuffer

\starttext

\xmlprocessbuffer{test}{test}{}

\stoptext
___
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
___


[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-24 Thread Hans Hagen

On 8/24/2023 4:11 PM, denis.ma...@unibe.ch wrote:

Hi,

I'm trying to check whether an attribute contains (or, actually starts with) a 
given string.
I've tried a whole bunch of different combinations, but I've had no luck so 
far. Minimal example below. Anyone has a hint?

Best,
Denis


%
\startxmlsetups xml:test
 \xmlsetsetup{#1}{*}{-}
 \xmlsetsetup{#1}{doc|element}{xml:*}
\stopxmlsetups

\xmlregisterdocumentsetup{test}{xml:test}


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

\startxmlsetups xml:element
\xmlfilter{#1}{./find(attribute('class'), 'abc')/command(xml:whatever)}

\xmldoifelse{#1}{./attribute('class')/contains('abc')} {Yes}{No}
\stopxmlsetups

\startxmlsetups xml:whatever
Yes
\stopxmlsetups

\startbuffer[test]


Yes
No

\stopbuffer

\starttext

\xmlprocessbuffer{test}{test}{}

\stoptext

\xmldoifelse{#1}{.[@class and contains(@class,'abc')]}{Yes}{No}
\xmldoifelse{#1}{.[@class and find(@class,"abc")]}{Yes}{No}


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


[NTG-context] Re: xmldoif: checking for contents of attribute

2023-08-24 Thread Thomas A. Schmitz
One way would be to do the search in Lua; when you have multiple searches to 
perform, that may be the easiest way to go. For example:

\startxmlsetups xml:test
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{doc|element}{xml:*}
\stopxmlsetups
 
\xmlregisterdocumentsetup{test}{xml:test}
 
\startxmlsetups xml:doc
\xmlflush{#1}
\stopxmlsetups
 
\startxmlsetups xml:element
 \xmlfunction {#1} {element}
\stopxmlsetups
 
\startluacode
function xml.functions.element (t)
 if t.at.class and t.at.class:find ("abc") then
context.startcolor { "blue" }
lxml.flush (t)
context.stopcolor ()
 else
context.startcolor { "red" }
lxml.flush (t)
context.stopcolor ()
 end
end
\stopluacode 
 
\startbuffer[test]


Yes
No

\stopbuffer
 
\starttext
 
\xmlprocessbuffer{test}{test}{}
 
\stoptext

Hope that gets you started.

Thomas

> On 24. Aug 2023, at 16:11, denis.ma...@unibe.ch wrote:
> 
> Hi,
>  I’m trying to check whether an attribute contains (or, actually starts with) 
> a given string.
> I’ve tried a whole bunch of different combinations, but I’ve had no luck so 
> far. Minimal example below. Anyone has a hint?
>  Best,
> Denis
>   %
> \startxmlsetups xml:test
> \xmlsetsetup{#1}{*}{-}
> \xmlsetsetup{#1}{doc|element}{xml:*} \stopxmlsetups
>  \xmlregisterdocumentsetup{test}{xml:test}
>   \startxmlsetups xml:doc
> \xmlflush{#1}
> \stopxmlsetups
>  \startxmlsetups xml:element
> \xmlfilter{#1}{./find(attribute('class'), 'abc')/command(xml:whatever)}
>  \xmldoifelse{#1}{./attribute('class')/contains('abc')} {Yes}{No}
> \stopxmlsetups
>  \startxmlsetups xml:whatever
> Yes
> \stopxmlsetups
>  \startbuffer[test]
> 
> 
> Yes
> No
> 
> \stopbuffer
>  \starttext
>  \xmlprocessbuffer{test}{test}{}
>  \stoptext


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

[NTG-context] xmldoif: checking for contents of attribute

2023-08-24 Thread denis.maier
Hi,

I'm trying to check whether an attribute contains (or, actually starts with) a 
given string.
I've tried a whole bunch of different combinations, but I've had no luck so 
far. Minimal example below. Anyone has a hint?

Best,
Denis


%
\startxmlsetups xml:test
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{doc|element}{xml:*}
\stopxmlsetups

\xmlregisterdocumentsetup{test}{xml:test}


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

\startxmlsetups xml:element
\xmlfilter{#1}{./find(attribute('class'), 'abc')/command(xml:whatever)}

\xmldoifelse{#1}{./attribute('class')/contains('abc')} {Yes}{No}
\stopxmlsetups

\startxmlsetups xml:whatever
Yes
\stopxmlsetups

\startbuffer[test]


Yes
No

\stopbuffer

\starttext

\xmlprocessbuffer{test}{test}{}

\stoptext
___
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
___

Re: [NTG-context] xmldoif, \startSECTION ... \stopSECTION and \setuphead

2019-05-16 Thread Pablo Rodriguez
On 5/16/19 8:45 PM, Wolfgang Schuster wrote:
> Pablo Rodriguez schrieb am 16.05.2019 um 18:43:
>> [...]
>> After checking i-context, the options for the second pair of brackets are:
>>
>>KEY = VALUE
>>
>> Well, I think this is the standard case. Aren’t values inherited from
>> \setuphead? What would be the valid keys for this case?
>
> The second argument is for userdata, i.e. you can use your own keys to
> store information for a section (e.g. the author or a subtitle).

Many thanks for your reply, Wolfgang.

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] xmldoif, \startSECTION ... \stopSECTION and \setuphead

2019-05-16 Thread Wolfgang Schuster

Pablo Rodriguez schrieb am 16.05.2019 um 18:43:

Dear list,

I have the following sample:

 \setuphead[chapter]
 [beforesection=\TeX,
  aftersection=\TeX]
 \starttext
 \startchapter[title=Chapter,
 beforesection=\ConTeXt,
 aftersection=\ConTeXt]
 This is my chapter.
 \stopchapter
 \stoptext

After checking i-context, the options for the second pair of brackets are:

   KEY = VALUE

Well, I think this is the standard case. Aren’t values inherited from
\setuphead? What would be the valid keys for this case?
The second argument is for userdata, i.e. you can use your own keys to 
store information for a section (e.g. the author or a subtitle).


Wolfgang

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


Re: [NTG-context] xmldoif, \startSECTION ... \stopSECTION and \setuphead

2019-05-16 Thread Pablo Rodriguez
On 5/16/19 6:43 PM, Pablo Rodriguez wrote:
> [...]
> What would be my approach to deal with "\xmldoif{#1}{.[@id='topic' and
> contains(@class,'hidden')]}" in beforesection?
>
> I realize that "\definehead[specialchapter][chapter]" would be a
> workaround, but I would like to find a more proper solution.

It would be a workaround for the sample I submitted, but not for "\xmldoif".

Pablo
--
http://www.ousia.tk
___
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
___


[NTG-context] xmldoif, \startSECTION ... \stopSECTION and \setuphead

2019-05-16 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\setuphead[chapter]
[beforesection=\TeX,
 aftersection=\TeX]
\starttext
\startchapter[title=Chapter,
beforesection=\ConTeXt,
aftersection=\ConTeXt]
This is my chapter.
\stopchapter
\stoptext

After checking i-context, the options for the second pair of brackets are:

  KEY = VALUE

Well, I think this is the standard case. Aren’t values inherited from
\setuphead? What would be the valid keys for this case?

I need to use \xmldoif in beforesection and aftersection. As far as I
can see, it doesn’t work inside \setuphead.

What would be my approach to deal with "\xmldoif{#1}{.[@id='topic' and
contains(@class,'hidden')]}" in beforesection?

I realize that "\definehead[specialchapter][chapter]" would be a
workaround, but I would like to find a more proper solution.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-03 Thread Geert Verhaag

Hi Aditya,

The ConTeXt team did a great job in writing the manual xml-mkiv.pdf, but 
I think it is not meant for a beginner.


Its contents is rather overwhelming when trying it for the first time.

For me, I don't use luatex a lot, so that adds to the difficulty of 
trying it out.


Regards,
Gerard

On 03-05-19 00:51, Aditya Mahajan wrote:

On Thu, 2 May 2019, Geert Verhaag wrote:


Yes, I got it working!

It is somewhat tricky.

Trying to understanding the concepts behind all this isn't easy for 
me, but I'm bashing on.


I also find understanding XML processing rules to be complicated. I 
simply convert the XML to a lua table, and then use all the processing 
in lua using CLD (context lua documents).


Aditya
___ 

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
___ 




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


Re: [NTG-context] XML xmldoif struggle!

2019-05-02 Thread Aditya Mahajan

On Thu, 2 May 2019, Geert Verhaag wrote:


Yes, I got it working!

It is somewhat tricky.

Trying to understanding the concepts behind all this isn't easy for me, 
but I'm bashing on.


I also find understanding XML processing rules to be complicated. I simply 
convert the XML to a lua table, and then use all the processing in lua 
using CLD (context lua documents).


Aditya
___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-02 Thread Geert Verhaag

Hi Pablo,

Yes, I got it working!

It is somewhat tricky.

Trying to understanding the concepts behind all this isn't easy for me, 
but I'm bashing on.


Thanks!

Regards,
Gerard

On 02-05-19 14:47, Pablo Rodriguez wrote:

On 5/1/19 9:28 PM, Geert Verhaag wrote:

Hoi Pablo,

Thanks for your prompt reply!

The output Euro set! is printed always, it doesn't matter whether I put
EURO or DOLLAR first?!

Hi Geert,

my fault, the conditional should read:

 \xmldoif{#1}{currency[position()==1 and contains(text(),'EURO')]}
 {Euro set!}

I hope it works fine now.

Pablo
--
http://www.ousia.tk
___
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
___

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


Re: [NTG-context] XML xmldoif struggle!

2019-05-02 Thread Pablo Rodriguez
On 5/1/19 9:28 PM, Geert Verhaag wrote:
> Hoi Pablo,
>
> Thanks for your prompt reply!
>
> The output Euro set! is printed always, it doesn't matter whether I put
> EURO or DOLLAR first?!

Hi Geert,

my fault, the conditional should read:

\xmldoif{#1}{currency[position()==1 and contains(text(),'EURO')]}
{Euro set!}

I hope it works fine now.

Pablo
--
http://www.ousia.tk
___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-01 Thread Geert Verhaag

Hoi Pablo,

Thanks for your prompt reply!

The output Euro set! is printed always, it doesn't matter whether I put 
EURO or DOLLAR first?!


Also I can't find any clue on the suggested page 49 of xml-mkiv.pdf 
manual, sorry!


By the way, in my document it still doesn't seem to work!

I'm afraid all this is far too complex for me! The documentation simply 
isn't meant for beginners like me, sorry!


Regards,
Gerard


On 01-05-19 13:20, Pablo Rodriguez wrote:

On 4/30/19 9:58 PM, Geert Verhaag wrote:

[...]
\startxmlsetups xml:invoice:invoice
    \xmlfirst{#1}{currency} \par
    \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} {
   Euro set! \par
    }
[...]
But the xmldoif command doesn't cause the Euro set be printed?!

What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on
how to make this work!

Hi Geert,

the syntax reads \xmldoif{#1}{lpath}{action}. So your conditional may read:

 \xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
 {Euro set!}

In a complete sample (with dollar set first [it won’t show the result
unless you set EURO first]):

   \startbuffer[demo]
   
 
   DOLLAR
   EURO
 
   
   \stopbuffer

   \startxmlsetups xml:initialize
  \xmlsetsetup{#1}{doc}{xml:*}
   \stopxmlsetups

   \xmlregistersetup{xml:initialize}

   \startxmlsetups xml:doc
 \xmlfirst{#1}{currency} \par
 \xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
 {Euro set!}
   \stopxmlsetups

   \setuppapersize[A8]

   \starttext
  \xmlprocessbuffer{main}{demo}{}
   \stoptext

It is all in xml-mkiv.pdf
(http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#page=49). I have
just discovered it .

Just in case it helps,

Pablo
--
http://www.ousia.tk
___
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
___

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


Re: [NTG-context] XML xmldoif struggle!

2019-05-01 Thread Pablo Rodriguez
On 4/30/19 9:58 PM, Geert Verhaag wrote:
> [...]
> \startxmlsetups xml:invoice:invoice
>    \xmlfirst{#1}{currency} \par
>    \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} {
>   Euro set! \par
>    }
> [...]
> But the xmldoif command doesn't cause the Euro set be printed?!
>
> What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on
> how to make this work!

Hi Geert,

the syntax reads \xmldoif{#1}{lpath}{action}. So your conditional may read:

\xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
{Euro set!}

In a complete sample (with dollar set first [it won’t show the result
unless you set EURO first]):

  \startbuffer[demo]
  

  DOLLAR
  EURO

  
  \stopbuffer

  \startxmlsetups xml:initialize
 \xmlsetsetup{#1}{doc}{xml:*}
  \stopxmlsetups

  \xmlregistersetup{xml:initialize}

  \startxmlsetups xml:doc
\xmlfirst{#1}{currency} \par
\xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
{Euro set!}
  \stopxmlsetups

  \setuppapersize[A8]

  \starttext
 \xmlprocessbuffer{main}{demo}{}
  \stoptext

It is all in xml-mkiv.pdf
(http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#page=49). I have
just discovered it .

Just in case it helps,

Pablo
--
http://www.ousia.tk
___
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
___


[NTG-context] XML xmldoif struggle!

2019-04-30 Thread Geert Verhaag

Hi,

I've the following XML tag in my XML file:


  EURO
.

with invoice being the root tag!

Now I have a setup defined as below (only part!):

\startxmlsetups xml:invoice:invoice
  \xmlfirst{#1}{currency} \par
  \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} {
 Euro set! \par
  }
.

The \xmlfirst{#1}{currency} command prints EURO as expected.

But the xmldoif command doesn't cause the Euro set be printed?!

What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on 
how to make this work!


Regards,

Gerard

--


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