* Best way to store text for later use [not found] <6660b3e6-42d5-a829-8a1d-3d8411719d7e@mailbox.org> @ 2020-09-18 13:36 ` Denis Maier 2020-09-18 16:18 ` Hans van der Meer 2020-09-18 17:02 ` Hans Hagen 0 siblings, 2 replies; 7+ messages in thread From: Denis Maier @ 2020-09-18 13:36 UTC (permalink / raw) To: ntg-context Hi, For typesetting XML I'm wondering how to best store text for later use: I've tried using buffers, but this here doesn't work: ================== \startxmlsetups xml:article-meta \setupdocument [ pub-year=\xmlfilter{#1}{/pub-date/year/command(xml:article-meta:pubdate:year)}, volume=\xmlfilter{#1}{/volume/command(xml:article-meta:volume)}, doi=\xmlfilter{#1}{/article-id[@pub-id-type='doi']/command(xml:article-meta:doi)}, elocation-id=\xmlfilter{#1}{/elocation-id/command(xml:article-meta:elocation-id)}, title=\xmlfilter{#1}{/title-group/article-title/command(xml:article-meta:title-group:article-title)}, author={\AuthorList}, ] \startbuffer[abstract] \xmlfilter{#1}{/abstract/command(xml:article-meta:abstract)} \stopbuffer \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:article-meta:abstract \xmlflush{#1} \stopxmlsetups =================== This here works: ================== \startxmlsetups xml:article-meta \setupdocument [ pub-year=\xmlfilter{#1}{/pub-date/year/command(xml:article-meta:pubdate:year)}, volume=\xmlfilter{#1}{/volume/command(xml:article-meta:volume)}, doi=\xmlfilter{#1}{/article-id[@pub-id-type='doi']/command(xml:article-meta:doi)}, elocation-id=\xmlfilter{#1}{/elocation-id/command(xml:article-meta:elocation-id)}, title=\xmlfilter{#1}{/title-group/article-title/command(xml:article-meta:title-group:article-title)}, author={\AuthorList}, abstract=\xmlfilter{#1}{/abstract/command(xml:article-meta:abstract)}, ] \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:article-meta:abstract \xmlflush{#1} \stopxmlsetups =================== But has using a variable for the abstract any drawbacks? (The abstract might contain multiple paragraphs.) Best, Denis ___________________________________________________________________________________ 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: Best way to store text for later use 2020-09-18 13:36 ` Best way to store text for later use Denis Maier @ 2020-09-18 16:18 ` Hans van der Meer 2020-10-02 10:57 ` Denis Maier 2020-09-18 17:02 ` Hans Hagen 1 sibling, 1 reply; 7+ messages in thread From: Hans van der Meer @ 2020-09-18 16:18 UTC (permalink / raw) To: NTG ConTeXt [-- Attachment #1.1: Type: text/plain, Size: 2698 bytes --] A possibility is saving the data as text in a Lua-table. If you are not afraid to use some Lua, I can send my code for saving files and data for repeated use. dr. Hans van der Meer > On 18 Sep 2020, at 15:36, Denis Maier <denis.maier.lists@mailbox.org> wrote: > > Hi, > > For typesetting XML I'm wondering how to best store text for later use: > > I've tried using buffers, but this here doesn't work: > > ================== > \startxmlsetups xml:article-meta > \setupdocument [ > pub-year=\xmlfilter{#1}{/pub-date/year/command(xml:article-meta:pubdate:year)}, > volume=\xmlfilter{#1}{/volume/command(xml:article-meta:volume)}, > doi=\xmlfilter{#1}{/article-id[@pub-id-type='doi']/command(xml:article-meta:doi)}, > elocation-id=\xmlfilter{#1}{/elocation-id/command(xml:article-meta:elocation-id)}, > title=\xmlfilter{#1}{/title-group/article-title/command(xml:article-meta:title-group:article-title)}, > author={\AuthorList}, > ] > \startbuffer[abstract] > \xmlfilter{#1}{/abstract/command(xml:article-meta:abstract)} > \stopbuffer > \xmlflush{#1} > \stopxmlsetups > > \startxmlsetups xml:article-meta:abstract > \xmlflush{#1} > \stopxmlsetups > =================== > > This here works: > > ================== > \startxmlsetups xml:article-meta > \setupdocument [ > pub-year=\xmlfilter{#1}{/pub-date/year/command(xml:article-meta:pubdate:year)}, > volume=\xmlfilter{#1}{/volume/command(xml:article-meta:volume)}, > doi=\xmlfilter{#1}{/article-id[@pub-id-type='doi']/command(xml:article-meta:doi)}, > elocation-id=\xmlfilter{#1}{/elocation-id/command(xml:article-meta:elocation-id)}, > title=\xmlfilter{#1}{/title-group/article-title/command(xml:article-meta:title-group:article-title)}, > author={\AuthorList}, > abstract=\xmlfilter{#1}{/abstract/command(xml:article-meta:abstract)}, > ] > \xmlflush{#1} > \stopxmlsetups > > \startxmlsetups xml:article-meta:abstract > \xmlflush{#1} > \stopxmlsetups > =================== > > But has using a variable for the abstract any drawbacks? (The abstract might contain multiple paragraphs.) > > Best, > Denis > ___________________________________________________________________________________ > 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 > ___________________________________________________________________________________ [-- Attachment #1.2: Type: text/html, Size: 5151 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 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] 7+ messages in thread
* Re: Best way to store text for later use 2020-09-18 16:18 ` Hans van der Meer @ 2020-10-02 10:57 ` Denis Maier 0 siblings, 0 replies; 7+ messages in thread From: Denis Maier @ 2020-10-02 10:57 UTC (permalink / raw) To: mailing list for ConTeXt users, Hans van der Meer Am 18.09.2020 um 18:18 schrieb Hans van der Meer: > A possibility is saving the data as text in a Lua-table. If you are not > afraid to use some Lua, I can send my code for saving files and data for > repeated use. > Sorry, for answering only now. I've missed your response. That sounds interesting, and I'd be happy if you could send me your code. Best, Denis ___________________________________________________________________________________ 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: Best way to store text for later use 2020-09-18 13:36 ` Best way to store text for later use Denis Maier 2020-09-18 16:18 ` Hans van der Meer @ 2020-09-18 17:02 ` Hans Hagen 2020-09-18 18:59 ` Denis Maier 1 sibling, 1 reply; 7+ messages in thread From: Hans Hagen @ 2020-09-18 17:02 UTC (permalink / raw) To: mailing list for ConTeXt users, Denis Maier On 9/18/2020 3:36 PM, Denis Maier wrote: > I've tried using buffers, but this here doesn't work: Why not just fetch it when needed. There is no gain in storing it and fetching from the xml tree is fast. 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 / 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: Best way to store text for later use 2020-09-18 17:02 ` Hans Hagen @ 2020-09-18 18:59 ` Denis Maier 2020-09-19 9:59 ` Hans Hagen 0 siblings, 1 reply; 7+ messages in thread From: Denis Maier @ 2020-09-18 18:59 UTC (permalink / raw) To: Hans Hagen, mailing list for ConTeXt users Am 18.09.2020 um 19:02 schrieb Hans Hagen: > On 9/18/2020 3:36 PM, Denis Maier wrote: > >> I've tried using buffers, but this here doesn't work: > Why not just fetch it when needed. There is no gain in storing it and > fetching from the xml tree is fast. > Most likely due to my limited understanding of how these things work. I thought storing the text and retrieving it later would be the easiest way to get rid of the constraints of linar processing of the XML file. The layout itself is determined by setups such as this one: \startsetups abstract \startabstract \documentvariable{abstract} \stopabstract \stopsetups \setuphead [chapter][ alternative=middle, page=yes, indentnext=no, style=\tfa\setupinterlinespace, after={\directsetup{placeauthors}\directsetup{abstract}}, footer=chapterfooter, ] How could I fetch the xml node from here so I don't need a variable, buffer or the like? Denis ___________________________________________________________________________________ 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: Best way to store text for later use 2020-09-18 18:59 ` Denis Maier @ 2020-09-19 9:59 ` Hans Hagen 2020-09-19 14:31 ` Denis Maier 0 siblings, 1 reply; 7+ messages in thread From: Hans Hagen @ 2020-09-19 9:59 UTC (permalink / raw) To: Denis Maier, mailing list for ConTeXt users On 9/18/2020 8:59 PM, Denis Maier wrote: > > > Am 18.09.2020 um 19:02 schrieb Hans Hagen: >> On 9/18/2020 3:36 PM, Denis Maier wrote: >> >>> I've tried using buffers, but this here doesn't work: >> Why not just fetch it when needed. There is no gain in storing it and >> fetching from the xml tree is fast. >> > Most likely due to my limited understanding of how these things work. I > thought storing the text and retrieving it later would be the easiest > way to get rid of the constraints of linar processing of the XML file. > The layout itself is determined by setups such as this one: there is no linear processing, you just start someplace and recursively deal with the tree (which often looks like linear when you start at the root but basically you can access everything everywhere) > \startsetups abstract > \startabstract > \documentvariable{abstract} > \stopabstract > \stopsetups > > \setuphead [chapter][ > alternative=middle, > page=yes, > indentnext=no, > style=\tfa\setupinterlinespace, > after={\directsetup{placeauthors}\directsetup{abstract}}, > footer=chapterfooter, > ] > > How could I fetch the xml node from here so I don't need a variable, > buffer or the like? just pass the root element i.e. instead of #1 in \xmlfilter{#1}{/abstract/command(xml:article-meta:abstract)} as #1 is just an abstraction for the current element; you pass the name you used when loading the tree (often \xmldocument works too) there are plenty examples in the documentation and test suite and in some styles 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 / 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: Best way to store text for later use 2020-09-19 9:59 ` Hans Hagen @ 2020-09-19 14:31 ` Denis Maier 0 siblings, 0 replies; 7+ messages in thread From: Denis Maier @ 2020-09-19 14:31 UTC (permalink / raw) To: Hans Hagen, mailing list for ConTeXt users Am 19.09.2020 um 11:59 schrieb Hans Hagen: > On 9/18/2020 8:59 PM, Denis Maier wrote: >> >> >> Am 18.09.2020 um 19:02 schrieb Hans Hagen: >>> On 9/18/2020 3:36 PM, Denis Maier wrote: >>> >>>> I've tried using buffers, but this here doesn't work: >>> Why not just fetch it when needed. There is no gain in storing it >>> and fetching from the xml tree is fast. >>> >> Most likely due to my limited understanding of how these things work. >> I thought storing the text and retrieving it later would be the >> easiest way to get rid of the constraints of linar processing of the >> XML file. The layout itself is determined by setups such as this one: > > there is no linear processing, you just start someplace and > recursively deal with the tree (which often looks like linear when you > start at the root but basically you can access everything everywhere) > >> \startsetups abstract >> \startabstract >> \documentvariable{abstract} >> \stopabstract >> \stopsetups >> >> \setuphead [chapter][ >> alternative=middle, >> page=yes, >> indentnext=no, >> style=\tfa\setupinterlinespace, >> after={\directsetup{placeauthors}\directsetup{abstract}}, >> footer=chapterfooter, >> ] >> >> How could I fetch the xml node from here so I don't need a variable, >> buffer or the like? > just pass the root element i.e. instead of #1 in > > \xmlfilter{#1}{/abstract/command(xml:article-meta:abstract)} > > as #1 is just an abstraction for the current element; you pass the > name you used when loading the tree (often \xmldocument works too) > Thanks. That is very helpful. And indeed, that makes things much easier! Denis ___________________________________________________________________________________ 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:[~2020-10-02 10:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <6660b3e6-42d5-a829-8a1d-3d8411719d7e@mailbox.org> 2020-09-18 13:36 ` Best way to store text for later use Denis Maier 2020-09-18 16:18 ` Hans van der Meer 2020-10-02 10:57 ` Denis Maier 2020-09-18 17:02 ` Hans Hagen 2020-09-18 18:59 ` Denis Maier 2020-09-19 9:59 ` Hans Hagen 2020-09-19 14:31 ` Denis Maier
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).