From oinos@gmx.es Sun Aug 16 11:02:55 2020 From: Pablo Rodriguez To: ntg-context@ntg.nl Subject: [NTG-context] reading a single element from XML Date: Sun, 16 Aug 2020 11:02:50 +0200 Message-ID: <8c7e070c-40b2-be30-d369-711c4db982a6@gmx.es> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3558671040005854447==" --===============3558671040005854447== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Dear list, I have the following sample: \startbuffer[demo]

This is Only a paragraph.

This is another paragraph.

This is another paragraph.

This is another paragraph.

This is another paragraph.

\stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1}{*}{-} \xmlsetsetup{#1} {html|body|div|p} {xml:flush} \xmlsetsetup{#1} {html/**/span[@class='special']} {xml:special} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:flush \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:special \bgroup\bfd\ssd\xmlflush{#1}\egroup \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext How can I select only ? I mean, how can I have "Only" and nothing more in the output PDF document? I thought that lpath "html/**/span[@class='special']" would work, but I don’t know what I’m missing. Many thanks for your help, Pablo -- http://www.ousia.tk --===============3558671040005854447==-- From taco@elvenkind.com Sun Aug 16 11:47:03 2020 From: Taco Hoekwater To: ntg-context@ntg.nl Subject: Re: [NTG-context] reading a single element from XML Date: Sun, 16 Aug 2020 11:46:57 +0200 Message-ID: <6DECC20E-88FC-4917-90AD-93F7F230E5E0@elvenkind.com> In-Reply-To: <8c7e070c-40b2-be30-d369-711c4db982a6@gmx.es> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8179842570845048165==" --===============8179842570845048165== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable \xmlfilter is your friend: \startxmlsetups xml:initialize \xmlsetsetup{#1}{html}{xml:gen} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:gen \xmlfilter{#1}{/**/span[@class=3D'special']/command(xml:special)} \stopxmlsetups =20 \startxmlsetups xml:special \bgroup\bfd\ssd\xmlflush{#1}\egroup \stopxmlsetups Best wishes, Taco > On 16 Aug 2020, at 11:02, Pablo Rodriguez wrote: >=20 > Dear list, >=20 > I have the following sample: >=20 > \startbuffer[demo] > > >
>

This is Only a paragraph.

>

This is another paragraph.

>

This is another paragraph.

>

This is another paragraph.

>

This is another paragraph.

>
> > > \stopbuffer >=20 > \startxmlsetups xml:initialize > \xmlsetsetup{#1}{*}{-} >=20 > \xmlsetsetup{#1} > {html|body|div|p} > {xml:flush} >=20 > \xmlsetsetup{#1} > {html/**/span[@class=3D'special']} > {xml:special} > \stopxmlsetups >=20 > \xmlregistersetup{xml:initialize} >=20 > \startxmlsetups xml:flush > \xmlflush{#1} > \stopxmlsetups >=20 > \startxmlsetups xml:special > \bgroup\bfd\ssd\xmlflush{#1}\egroup > \stopxmlsetups >=20 > \starttext > \xmlprocessbuffer{main}{demo}{} > \stoptext >=20 > How can I select only ? I mean, how can I have > "Only" and nothing more in the output PDF document? >=20 > I thought that lpath "html/**/span[@class=3D'special']" would work, but I > don=E2=80=99t know what I=E2=80=99m missing. >=20 > Many thanks for your help, >=20 > Pablo > -- > http://www.ousia.tk > ___________________________________________________________________________= ________ > If your question is of interest to others as well, please add an entry to t= he Wiki! >=20 > maillist : ntg-context(a)ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___________________________________________________________________________= ________ Taco Hoekwater Elvenkind BV --===============8179842570845048165==-- From oinos@gmx.es Sun Aug 16 14:04:55 2020 From: Pablo Rodriguez To: ntg-context@ntg.nl Subject: Re: [NTG-context] reading a single element from XML Date: Sun, 16 Aug 2020 14:04:50 +0200 Message-ID: <832482dc-d8f3-f4fb-6036-0cfb0f9e9eed@gmx.es> In-Reply-To: <6DECC20E-88FC-4917-90AD-93F7F230E5E0@elvenkind.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3034547095603661579==" --===============3034547095603661579== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 8/16/20 11:46 AM, Taco Hoekwater wrote: > \xmlfilter is your friend: > > \startxmlsetups xml:initialize > \xmlsetsetup{#1}{html}{xml:gen} > \stopxmlsetups > > \xmlregistersetup{xml:initialize} > > \startxmlsetups xml:gen > \xmlfilter{#1}{/**/span[@class='special']/command(xml:special)} > \stopxmlsetups > > \startxmlsetups xml:special > \bgroup\bfd\ssd\xmlflush{#1}\egroup > \stopxmlsetups Many thanks for your reply, Taco. This was extremely handy and helpful (it is also the first time I understand what \xmlfilter is used for). My final solution required nesting filters, which worked perfectly fine (included below). Many thanks for your help, Pablo Just for the record: \startbuffer[demo]

This is One a paragraph.

This is another paragraph.

This is another Two paragraph.

This is another Three paragraph.

This is another Four paragraph.

This is A a paragraph.

This is another paragraph.

This is another B paragraph.

This is another C paragraph.

This is another D paragraph.

\stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1}{html}{xml:gen} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:gen \xmlfilter{#1}{/**/div/command(xml:chapter)} \stopxmlsetups \startxmlsetups xml:chapter \startsection[title=\xmlatt{#1}{id}] \startitemize[packed] \xmlfilter{#1}{**/span[@class='special']/command(xml:special)} \stopitemize \stopsection \stopxmlsetups \startxmlsetups xml:special \startitem\xmlflush{#1}\stopitem \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext -- http://www.ousia.tk --===============3034547095603661579==--