ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* XML xmldoif struggle!
@ 2019-04-30 19:58 Geert Verhaag
  2019-05-01 11:20 ` Pablo Rodriguez
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Verhaag @ 2019-04-30 19:58 UTC (permalink / raw)
  To: ntg-context

Hi,

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

<invoice number="194-002" client="RPMB-0012">
   <currency>EURO</currency>
.....

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
___________________________________________________________________________________

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

* Re: XML xmldoif struggle!
  2019-04-30 19:58 XML xmldoif struggle! Geert Verhaag
@ 2019-05-01 11:20 ` Pablo Rodriguez
  2019-05-01 19:28   ` Geert Verhaag
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2019-05-01 11:20 UTC (permalink / raw)
  To: ntg-context

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]
  <doc>
    <invoice number="194-002" client="RPMB-0012">
      <currency>DOLLAR</currency>
      <currency>EURO</currency>
    </invoice>
  </doc>
  \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
___________________________________________________________________________________

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

* Re: XML xmldoif struggle!
  2019-05-01 11:20 ` Pablo Rodriguez
@ 2019-05-01 19:28   ` Geert Verhaag
  2019-05-02 12:47     ` Pablo Rodriguez
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Verhaag @ 2019-05-01 19:28 UTC (permalink / raw)
  To: ntg-context

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]
>    <doc>
>      <invoice number="194-002" client="RPMB-0012">
>        <currency>DOLLAR</currency>
>        <currency>EURO</currency>
>      </invoice>
>    </doc>
>    \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
___________________________________________________________________________________

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

* Re: XML xmldoif struggle!
  2019-05-01 19:28   ` Geert Verhaag
@ 2019-05-02 12:47     ` Pablo Rodriguez
  2019-05-02 19:38       ` Geert Verhaag
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2019-05-02 12:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

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

* Re: XML xmldoif struggle!
  2019-05-02 12:47     ` Pablo Rodriguez
@ 2019-05-02 19:38       ` Geert Verhaag
  2019-05-02 22:51         ` Aditya Mahajan
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Verhaag @ 2019-05-02 19:38 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

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

* Re: XML xmldoif struggle!
  2019-05-02 19:38       ` Geert Verhaag
@ 2019-05-02 22:51         ` Aditya Mahajan
  2019-05-03 17:41           ` Geert Verhaag
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2019-05-02 22:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

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

* Re: XML xmldoif struggle!
  2019-05-02 22:51         ` Aditya Mahajan
@ 2019-05-03 17:41           ` Geert Verhaag
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Verhaag @ 2019-05-03 17:41 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

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

end of thread, other threads:[~2019-05-03 17:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 19:58 XML xmldoif struggle! Geert Verhaag
2019-05-01 11:20 ` Pablo Rodriguez
2019-05-01 19:28   ` Geert Verhaag
2019-05-02 12:47     ` Pablo Rodriguez
2019-05-02 19:38       ` Geert Verhaag
2019-05-02 22:51         ` Aditya Mahajan
2019-05-03 17:41           ` Geert Verhaag

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