* Using command line values in a TeX document; writing a script? @ 2020-04-13 8:29 Gerben Wierda 2020-04-14 7:16 ` Taco Hoekwater 0 siblings, 1 reply; 9+ messages in thread From: Gerben Wierda @ 2020-04-13 8:29 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1248 bytes --] Currently, I process a file like this: mtxrun --autogenerate --script context test12.tex and in the file test12.tex one sees something like this: \input archimate-mp \ctxlua{moduledata.archimate(“myarchimatefile.xml")} The latter parses the xml file and produces a PDF using generated MP code. What I would like to do is not have to edit the .tex file when I want to process another .xml file but just pass the name of the xml file on the command line. And I would like to pass on a second filename with some local overrides settings fr my code. All of this needs to be data that I can use in my programming. E.g. something like: mtxrun --autogenerate --script myscriptname “ myarchimatefile.xml” “myhelper.xml" It is OK that this would produce a fixed name output file (e.g. myparsedxml.pdf), so it is OK to have some generic myparsedxml.tex (instead of test12.tex as per my example) file that produces a .pdf and more in the current working directory but resides somewhere in a generic place. But preferably, this would produce myarchimatefile.pdf I’ve read the manual on mtxrun scripts to see if I can make my own, but I’m utterly failing to understand what is written in a way that let me write my own. G [-- Attachment #1.2: Type: text/html, Size: 2640 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-13 8:29 Using command line values in a TeX document; writing a script? Gerben Wierda @ 2020-04-14 7:16 ` Taco Hoekwater 2020-04-14 9:25 ` Gerben Wierda 0 siblings, 1 reply; 9+ messages in thread From: Taco Hoekwater @ 2020-04-14 7:16 UTC (permalink / raw) To: mailing list for ConTeXt users Hi Gerben, What you want is quite easy to do since you are using lua already. Try this: % context --whatever=green test with test.tex: \starttext \startluacode table.print(environment.arguments) \stopluacode \stoptext everything from the command line ends up in environment.arguments. Best wishes, Taco ___________________________________________________________________________________ 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-14 7:16 ` Taco Hoekwater @ 2020-04-14 9:25 ` Gerben Wierda 2020-04-14 9:52 ` Taco Hoekwater 2020-04-14 10:05 ` Hans Hagen 0 siblings, 2 replies; 9+ messages in thread From: Gerben Wierda @ 2020-04-14 9:25 UTC (permalink / raw) To: mailing list for ConTeXt users This helps for adding information to my processing. What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). G > On 14 Apr 2020, at 09:16, Taco Hoekwater <taco@elvenkind.com> wrote: > > Hi Gerben, > > What you want is quite easy to do since you are using lua already. Try this: > > % context --whatever=green test > > with test.tex: > > \starttext > \startluacode > table.print(environment.arguments) > \stopluacode > \stoptext > > everything from the command line ends up in environment.arguments. > > Best wishes, > Taco > ___________________________________________________________________________________ > 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-14 9:25 ` Gerben Wierda @ 2020-04-14 9:52 ` Taco Hoekwater 2020-04-15 10:19 ` Gerben Wierda 2020-04-14 10:05 ` Hans Hagen 1 sibling, 1 reply; 9+ messages in thread From: Taco Hoekwater @ 2020-04-14 9:52 UTC (permalink / raw) To: mailing list for ConTeXt users > On 14 Apr 2020, at 11:25, Gerben Wierda <gerben.wierda@rna.nl> wrote: > > This helps for adding information to my processing. > > What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. > > So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). When processing XML, I normally use context —environment=whatever.tex file.xml with whatever.tex being a mix of tex and lua to setup and process the XML directly, perhaps including other XML files as needed. But when you need to extract stuff and rename files, a Makefile or shell script comes more naturally (at least for me). Taco ___________________________________________________________________________________ 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-14 9:52 ` Taco Hoekwater @ 2020-04-15 10:19 ` Gerben Wierda 2020-04-15 11:54 ` Wolfgang Schuster 0 siblings, 1 reply; 9+ messages in thread From: Gerben Wierda @ 2020-04-15 10:19 UTC (permalink / raw) To: mailing list for ConTeXt users > On 14 Apr 2020, at 11:52, Taco Hoekwater <taco@elvenkind.com> wrote: > > > >> On 14 Apr 2020, at 11:25, Gerben Wierda <gerben.wierda@rna.nl> wrote: >> >> This helps for adding information to my processing. >> >> What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. >> >> So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). > > When processing XML, I normally use > > context —environment=whatever.tex file.xml > > with whatever.tex being a mix of tex and lua to setup and process the XML directly, > perhaps including other XML files as needed. But this means that the whatever.tex file needs to exist beforehand and the result is whatever.pdf I want the actual PDF to be produced have a name that comes from the XML I am processing and thus the whatever.tex file be created by lua. There is no whatever.tex file before I run the command. Pre-command: XML: contains file name “foo” there is no .tex file Command: produces foo.tex (gets the name from the XML) and “foo.pdf" G > > But when you need to extract stuff and rename files, a Makefile or shell script > comes more naturally (at least for me). > > Taco > ___________________________________________________________________________________ > 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-15 10:19 ` Gerben Wierda @ 2020-04-15 11:54 ` Wolfgang Schuster 2020-04-15 12:13 ` Gerben Wierda 0 siblings, 1 reply; 9+ messages in thread From: Wolfgang Schuster @ 2020-04-15 11:54 UTC (permalink / raw) To: mailing list for ConTeXt users, Gerben Wierda Gerben Wierda schrieb am 15.04.2020 um 12:19: >> On 14 Apr 2020, at 11:52, Taco Hoekwater <taco@elvenkind.com> wrote: >>> On 14 Apr 2020, at 11:25, Gerben Wierda <gerben.wierda@rna.nl> wrote: >>> >>> This helps for adding information to my processing. >>> >>> What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. >>> >>> So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). >> When processing XML, I normally use >> >> context —environment=whatever.tex file.xml >> >> with whatever.tex being a mix of tex and lua to setup and process the XML directly, >> perhaps including other XML files as needed. > But this means that the whatever.tex file needs to exist beforehand and the result is whatever.pdf > > I want the actual PDF to be produced have a name that comes from the XML I am processing and thus the whatever.tex file be created by lua. There is no whatever.tex file before I run the command. > > Pre-command: > XML: > contains file name “foo” > there is no .tex file > > Command: > produces foo.tex (gets the name from the XML) and “foo.pdf" The TeX file in Tacos example contains the xmlsetup entries which are used to map the XML tags to ConTeXt commands and environment, the resulting PDF file has the same name as the XML file. 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-15 11:54 ` Wolfgang Schuster @ 2020-04-15 12:13 ` Gerben Wierda 2020-04-15 12:43 ` r.ermers 0 siblings, 1 reply; 9+ messages in thread From: Gerben Wierda @ 2020-04-15 12:13 UTC (permalink / raw) To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1954 bytes --] > On 15 Apr 2020, at 13:54, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote: > > Gerben Wierda schrieb am 15.04.2020 um 12:19: >>> On 14 Apr 2020, at 11:52, Taco Hoekwater <taco@elvenkind.com> wrote: >>>> On 14 Apr 2020, at 11:25, Gerben Wierda <gerben.wierda@rna.nl> wrote: >>>> >>>> This helps for adding information to my processing. >>>> >>>> What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. >>>> >>>> So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). >>> When processing XML, I normally use >>> >>> context —environment=whatever.tex file.xml >>> >>> with whatever.tex being a mix of tex and lua to setup and process the XML directly, >>> perhaps including other XML files as needed. >> But this means that the whatever.tex file needs to exist beforehand and the result is whatever.pdf >> >> I want the actual PDF to be produced have a name that comes from the XML I am processing and thus the whatever.tex file be created by lua. There is no whatever.tex file before I run the command. >> >> Pre-command: >> XML: >> contains file name “foo” >> there is no .tex file >> >> Command: >> produces foo.tex (gets the name from the XML) and “foo.pdf" > > The TeX file in Tacos example contains the xmlsetup entries which are used > to map the XML tags to ConTeXt commands and environment, the resulting > PDF file has the same name as the XML file. That is different from the resulting PDF file has the name of an entry/field in the XML file. So, what I am looking for is: command foo.xml which results in bar.pdf where ‘bar’ is text in foo.xml G > > Wolfgang > [-- Attachment #1.2: Type: text/html, Size: 3770 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-15 12:13 ` Gerben Wierda @ 2020-04-15 12:43 ` r.ermers 0 siblings, 0 replies; 9+ messages in thread From: r.ermers @ 2020-04-15 12:43 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 4222 bytes --] Gerben, I do not know if it is possible with Context. But this definitely works with an xsl operation. You will need an xsl file like this: myxslfile.xsl: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="contacts"> <xsl:for-each-group select="contact" group-by=“contact/@ad"> <xsl:result-document href="groep-{current-grouping-key()}.xml"> <contacts> <xsl:copy-of select="current-group()"/> </contacts> </xsl:result-document> </xsl:for-each-group> </xsl:template> <!-- alleen met Saxon, xslt: versie 2 --> </xsl:stylesheet> myxmlfile.xml <contacts> <contact> <name ad=“BAR">John</name> </contact> <contact> <name ad=“BAR”>Gerben</name> </contact> </contacts> Use it like this with saxon (xsl version 2). saxon -xsl:myxslfile.xsl -s:myxmlfile.xml -o:dummy.xml This program will generate an empty dummyfile.xml but also xml files, (e.g. BAR.xml) in which it will collect al contact that have @ad=‘BAR', and there will be as many files as you have different values of @ad in your xml file. I am very far from being a specalist on xsl, please refer for further information to xsl forums. Have fun experimenting! I do this myself and then have a script generate the pdfs. Hope this helps. Robert > Op 15 apr. 2020, om 14:13 heeft Gerben Wierda <gerben.wierda@rna.nl> het volgende geschreven: > > > >> On 15 Apr 2020, at 13:54, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com <mailto:wolfgang.schuster.lists@gmail.com>> wrote: >> >> Gerben Wierda schrieb am 15.04.2020 um 12:19: >>>> On 14 Apr 2020, at 11:52, Taco Hoekwater <taco@elvenkind.com <mailto:taco@elvenkind.com>> wrote: >>>>> On 14 Apr 2020, at 11:25, Gerben Wierda <gerben.wierda@rna.nl <mailto:gerben.wierda@rna.nl>> wrote: >>>>> >>>>> This helps for adding information to my processing. >>>>> >>>>> What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. >>>>> >>>>> So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). >>>> When processing XML, I normally use >>>> >>>> context —environment=whatever.tex file.xml >>>> >>>> with whatever.tex being a mix of tex and lua to setup and process the XML directly, >>>> perhaps including other XML files as needed. >>> But this means that the whatever.tex file needs to exist beforehand and the result is whatever.pdf >>> >>> I want the actual PDF to be produced have a name that comes from the XML I am processing and thus the whatever.tex file be created by lua. There is no whatever.tex file before I run the command. >>> >>> Pre-command: >>> XML: >>> contains file name “foo” >>> there is no .tex file >>> >>> Command: >>> produces foo.tex (gets the name from the XML) and “foo.pdf" >> >> The TeX file in Tacos example contains the xmlsetup entries which are used >> to map the XML tags to ConTeXt commands and environment, the resulting >> PDF file has the same name as the XML file. > > That is different from > > the resulting PDF file has the name of an entry/field in the XML file. > > So, what I am looking for is: > > command foo.xml > > which results in > > bar.pdf > > where ‘bar’ is text in foo.xml > > G > >> >> 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 > ___________________________________________________________________________________ [-- Attachment #1.2: Type: text/html, Size: 8379 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] 9+ messages in thread
* Re: Using command line values in a TeX document; writing a script? 2020-04-14 9:25 ` Gerben Wierda 2020-04-14 9:52 ` Taco Hoekwater @ 2020-04-14 10:05 ` Hans Hagen 1 sibling, 0 replies; 9+ messages in thread From: Hans Hagen @ 2020-04-14 10:05 UTC (permalink / raw) To: mailing list for ConTeXt users, Gerben Wierda On 4/14/2020 11:25 AM, Gerben Wierda wrote: > This helps for adding information to my processing. > > What I was also looking for is that I don’t have a test.tex anymore, just the XML file I am parsing and a command line action. > > So, I use mtxrun, give it the name of an XML. lua code (using a ’script’ somewhere?) reads the XML, extracts a name (e.g. ‘foo’) from it, creates a .tex file (e.g. ‘foo.tex’), produces a .pdf file from that .tex file (e.g. ‘foo.pdf'). > > G > >> On 14 Apr 2020, at 09:16, Taco Hoekwater <taco@elvenkind.com> wrote: >> >> Hi Gerben, >> >> What you want is quite easy to do since you are using lua already. Try this: >> >> % context --whatever=green test >> >> with test.tex: >> >> \starttext >> \startluacode >> table.print(environment.arguments) >> \stopluacode >> \stoptext >> >> everything from the command line ends up in environment.arguments. \doifdocumentargument {whatever} { ... \getdocumentargument{whatever} ... } ----------------------------------------------------------------- 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] 9+ messages in thread
end of thread, other threads:[~2020-04-15 12:43 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-13 8:29 Using command line values in a TeX document; writing a script? Gerben Wierda 2020-04-14 7:16 ` Taco Hoekwater 2020-04-14 9:25 ` Gerben Wierda 2020-04-14 9:52 ` Taco Hoekwater 2020-04-15 10:19 ` Gerben Wierda 2020-04-15 11:54 ` Wolfgang Schuster 2020-04-15 12:13 ` Gerben Wierda 2020-04-15 12:43 ` r.ermers 2020-04-14 10:05 ` Hans Hagen
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).