Re: [NTG-context] issue with lpath
> On 4 Aug 2022, at 18:39, Pablo Rodriguez via ntg-context > wrote: > > On 8/4/22 17:32, Taco Hoekwater via ntg-context wrote: >> [...] >> PS This sort of confusing filtering is why I do most of my xml >> processing from the lua end, where it is much clearer to me what is >> what. > Many thanks for clarifying the issue, Taco. > > BTW, according to the last slide from > https://meeting.contextgarden.net/2019/talks/02-xmlprocessing/02-xmlprocessing.pdf, > you had plans to document how to deal with XML in proper Lua. > > I wonder whether you are still interested in adding this information to > the manual. In theory, yes. In reality, life is too short, and it is on the bottom of an ever rising pile of things to do. :sadface Best wishes, Taco Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ 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] issue with lpath
On 8/4/22 17:32, Taco Hoekwater via ntg-context wrote: > [...] > PS This sort of confusing filtering is why I do most of my xml > processing from the lua end, where it is much clearer to me what is > what. Many thanks for clarifying the issue, Taco. BTW, according to the last slide from https://meeting.contextgarden.net/2019/talks/02-xmlprocessing/02-xmlprocessing.pdf, you had plans to document how to deal with XML in proper Lua. I wonder whether you are still interested in adding this information to the manual. Many thanks for your help, Pablo ___ 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] issue with lpath
> On 4 Aug 2022, at 16:07, Hans Hagen wrote: > > On 8/4/2022 12:22 PM, Taco Hoekwater via ntg-context wrote: >>> On 3 Aug 2022, at 15:54, Pablo Rodriguez via ntg-context >>> wrote: >>> >>> BTW, is there any way to rephrase "{h3 + blockquote}" in proper Lua? >> I was wondering about that as well, and I really had no clue how to do that. >> Some >> reading and studying later, I realised that there is a preceding-sibling:: >> axis. >> That is not documented in xml-mkiv.pdf I think, but it inherited from xpath, >> and that means this works: >> \xmlsetsetup{#1}{blockquote/preceding-sibling::h3[-1]/} {xml:section} >> “Take all blockquotes, then tests their immediate preceding siblings (index >> [-1]) that are h3." >> But the CSS version is nicer. Still, both solutions fail on generic input. >> Sorry, out of clues > \startbuffer[demo] > ... That puts the whole content inside the \section, and I don’t think that was the intent. I understood that Pablo only wants the “h3” node. In the original request, the CSS “{h3 + blockquote}” matches a “blockquote” anyplace where it is immediately preceded by a “h3” (and nowhere else). After that, some trickery was needed to try and get back to the actual “h3”. My trick above with preceding-sibling above also gets the “h3” that is immediately followed by a “blockquote”, but it got easily confused if there were multiple “h3” or “blockquote” objects in the input. Best wishes, Taco PS This sort of confusing filtering is why I do most of my xml processing from the lua end, where it is much clearer to me what is what. — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ 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] issue with lpath
On 8/4/22 12:22, Taco Hoekwater via ntg-context wrote: >> On 3 Aug 2022, at 15:54, Pablo Rodriguez via ntg-context >> wrote: >> BTW, is there any way to rephrase "{h3 + blockquote}" in proper Lua? > > I was wondering about that as well, and I really had no clue how to > do that. Some reading and studying later, I realised that there is a > preceding-sibling:: axis. > > That is not documented in xml-mkiv.pdf I think, but it inherited > from xpath, and that means this works:> > \xmlsetsetup{#1}{blockquote/preceding-sibling::h3[-1]/} {xml:section} > > “Take all blockquotes, then tests their immediate preceding siblings > (index [-1]) that are h3." Many thanks for your reply, Taco. It isn’t documented, but I have just discovered that it is used inside a function: https://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#search=sibling > But the CSS version is nicer. I agree. But using CSS for LPaths feels like cheating to me. Many thanks for your help again, Pablo ___ 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] issue with lpath
On 8/4/2022 12:22 PM, Taco Hoekwater via ntg-context wrote: On 3 Aug 2022, at 15:54, Pablo Rodriguez via ntg-context wrote: BTW, is there any way to rephrase "{h3 + blockquote}" in proper Lua? I was wondering about that as well, and I really had no clue how to do that. Some reading and studying later, I realised that there is a preceding-sibling:: axis. That is not documented in xml-mkiv.pdf I think, but it inherited from xpath, and that means this works: \xmlsetsetup{#1}{blockquote/preceding-sibling::h3[-1]/} {xml:section} “Take all blockquotes, then tests their immediate preceding siblings (index [-1]) that are h3." But the CSS version is nicer. Still, both solutions fail on generic input. Sorry, out of clues \startbuffer[demo] One Standard paragraph Quoted text Two Direct quote \stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1} {xml|p|blockquote|div} {xml:*} \xmlsetsetup{#1} {/xml/div[contains(@class,'level3')]} {xml:section:level3} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:xml \xmlall{#1}{/div} \stopxmlsetups \startxmlsetups xml:p \startpar\xmlflush{#1}\stoppar \stopxmlsetups \startxmlsetups xml:blockquote \startblockquote\xmlflush{#1}\stopblockquote \stopxmlsetups \startxmlsetups xml:section:level3 \xmldoif{#1}{/blockquote} { \xmldoifnot{#1}{/p} { \section{\xmlflush{#1}} } } \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext - 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 ___
Re: [NTG-context] issue with lpath
> On 3 Aug 2022, at 15:54, Pablo Rodriguez via ntg-context > wrote: > > BTW, is there any way to rephrase "{h3 + blockquote}" in proper Lua? I was wondering about that as well, and I really had no clue how to do that. Some reading and studying later, I realised that there is a preceding-sibling:: axis. That is not documented in xml-mkiv.pdf I think, but it inherited from xpath, and that means this works: \xmlsetsetup{#1}{blockquote/preceding-sibling::h3[-1]/} {xml:section} “Take all blockquotes, then tests their immediate preceding siblings (index [-1]) that are h3." But the CSS version is nicer. Still, both solutions fail on generic input. Sorry, out of clues Best wishes,Taco — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ 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] issue with lpath
On 8/3/22 09:09, Taco Hoekwater via ntg-context wrote: >> On 2 Aug 2022, at 21:14, Pablo Rodriguez via ntg-context >> wrote: >> [...] >> I need an lpath to select the h3 node above, but only the one with "h3 + >> blockquote" as a CSS selector (which could be added the lpath "../h3" >> after). > > Lpath supports CSS selectors between curly braces as parts, so simply: > > \xmlsetsetup{#1}{{h3 + blockquote}/../h3} {xml:section} Taco, I knew that, but I wasn’t sure how to mix both. I’d say yesterday I tried something similar to: \xmlsetsetup{#1}{{h3 + blockquote}../h3} {xml:section} Which, of course, couldn’t work. > The xml-mkiv.pdf manual has lots of other lpath examples as well. I know, I have read them many times. And I read them from time to time. But I’m not smart enough to understand them. BTW, is there any way to rephrase "{h3 + blockquote}" in proper Lua? Something like "/h3/../!p/../blockquote" selected both "h3 + p" (which I didn’t want and "h3 + blockquote" (the one intended). Many thanks for your help, Pablo ___ 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] issue with lpath
> On 2 Aug 2022, at 21:14, Pablo Rodriguez via ntg-context > wrote: > > Dear list, > > > I need an lpath to select the h3 node above, but only the one with "h3 + > blockquote" as a CSS selector (which could be added the lpath "../h3" > after). Lpath supports CSS selectors between curly braces as parts, so simply: \xmlsetsetup{#1}{{h3 + blockquote}/../h3} {xml:section} should do. The xml-mkiv.pdf manual has lots of other lpath examples as well. Best wishes, Taco — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ 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] issue with lpath containing a hyphen
On 11/20/2016 8:47 PM, Pablo Rodriguez wrote: On 11/20/2016 12:13 PM, Hans Hagen wrote: On 11/18/2016 11:32 PM, Pablo Rodriguez wrote: [...] The only way to get the Knuth in the quote is to remove "\letterpercent" in the lpath. so why do you use the \letterpercent then It was a minimal sample taken from from a larger project. I have just discovered that the compilation error has nothing to do with the hyphen. Then I have the question about lpaths: do I have to remove all instances of \letterpercent? They seem to work fine, but I had the impression that \letterpercent was mandatory and now I don’t know whether it is allowed or simply forbidden. afaiks they are not needed unless you use lua function that use find or gsub - 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 ___
Re: [NTG-context] issue with lpath containing a hyphen
On 11/20/2016 12:13 PM, Hans Hagen wrote: > On 11/18/2016 11:32 PM, Pablo Rodriguez wrote: >> [...] >> The only way to get the Knuth in the quote is to remove "\letterpercent" >> in the lpath. > > so why do you use the \letterpercent then It was a minimal sample taken from from a larger project. I have just discovered that the compilation error has nothing to do with the hyphen. Then I have the question about lpaths: do I have to remove all instances of \letterpercent? They seem to work fine, but I had the impression that \letterpercent was mandatory and now I don’t know whether it is allowed or simply forbidden. 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] issue with lpath containing a hyphen
On 11/18/2016 11:32 PM, Pablo Rodriguez wrote: Hans, I have the following sample: \startbuffer[demo] is it working \stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1}{doc}{xml:*} \xmlsetsetup{#1} {div[@id='a\letterpercent-b']} {xml:a:b} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:a:b \input knuth \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext The only way to get the Knuth in the quote is to remove "\letterpercent" in the lpath. so why do you use the \letterpercent then I guess I must be doing something wrong in this sample. In my real document, I cannot simply remove it, I get an error. As a general consideration, houw about making not mandatory to escape characters in lpaths? This would ease the traslation from XML code to lpaths. Many thanks for your help, Pablo -- - 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 ___