From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106867 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: r.ermers@hccnet.nl Newsgroups: gmane.comp.tex.context Subject: Re: Using command line values in a TeX document; writing a script? Date: Wed, 15 Apr 2020 14:43:32 +0200 Message-ID: <4F734AF3-9EF8-4B71-B7EF-B81D6F3FA0F1@hccnet.nl> References: <21EE30E7-D8C9-4797-8526-0BBC23AB68E2@rna.nl> <593CDD5F-DBA7-4A5F-8236-09BEC3B5F356@rna.nl> <8FADCC5E-830B-4442-BA00-967A86257890@rna.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Content-Type: multipart/mixed; boundary="===============2439403886971696728==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="36009"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Apr 15 15:21:06 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOhyT-0009HE-PT for gctc-ntg-context-518@m.gmane-mx.org; Wed, 15 Apr 2020 15:21:05 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id BF039181B44; Wed, 15 Apr 2020 15:20:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id liyp4WI0CgdU; Wed, 15 Apr 2020 15:20:26 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 81181181A9B; Wed, 15 Apr 2020 15:20:26 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 36D80181A9B for ; Wed, 15 Apr 2020 15:20:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aOEAk_m0ua6o for ; Wed, 15 Apr 2020 15:20:24 +0200 (CEST) Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=136.144.141.119; helo=mailhost-1.trined.nl; envelope-from=r.ermers@hccnet.nl; receiver= X-Greylist: delayed 2206 seconds by postgrey-1.36 at zapf.ntg.nl; Wed, 15 Apr 2020 15:20:24 CEST Original-Received: from mailhost-1.trined.nl (mailhost-1.trined.nl [136.144.141.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 55916180990 for ; Wed, 15 Apr 2020 15:20:24 +0200 (CEST) Original-Received: from [62.212.142.196] (helo=imac-van-robert.fritz.box) by mailhost-1.trined.nl with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jOhOB-00027W-LX for ntg-context@ntg.nl; Wed, 15 Apr 2020 14:43:38 +0200 In-Reply-To: <8FADCC5E-830B-4442-BA00-967A86257890@rna.nl> X-Mailer: Apple Mail (2.3445.5.20) X-Originating-IP: 62.212.142.196 X-SpamExperts-Domain: smtp.trined.nl X-SpamExperts-Username: 62.212.142.196 Authentication-Results: trined.nl; auth=pass smtp.auth=62.212.142.196@smtp.trined.nl X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.03) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0UBz61CMCjtXLJgk4EZr3/upSDasLI4SayDByyq9LIhVpoZp01Jpq3xG cka+9MjOIETNWdUk1Ol2OGx3IfrIJKywOmJyM1qr8uRnWBrbSAGDh1q8JufB4LHLD3SFaN00KJbR wRM/pkZhq7RBdFcw5O4P5SCFc0KZUiHG/V2MkQf4UZq99/v+OWrp+SY7iSuea8EuNfnjQsRqWXYP fdewBkdPR9o014ICOs9pIWX8OtLJfHpIFrX1BAJ4oa6lUv3IDkWcjr/GL4msDw+0flcVtDEZmL0k TGIVN3DthM1B8FVxMEM4B92VJbZIHVTKWs4TQz48H2gdqxP0tgYUAZMJStGQVyADaS6UpCBADjTx teudrmOQu6qzIFFXr1QlKPkEFT5dWtmUIvhjaEA8G9RzRMgrTC2AuwB7SJcPYbx65uRf1NRsUdzW awx6dX0NJ8Bzt99fxN2oReTDHAyOynaY0Ckcz9qVW8jvTNhLgSdygoEbPfzGbGd3/nQjCjJGMyxm MrXTnONsqyI++u9UMf5U2lFyXMWcv2ZlvSNZcmGO3E8wIzvpj9IzyBpc10ZJwnPg5eQ3AUAJ8ruJ 817UA5G1KryKEti6i6ftQDSvbpSMVVduF9lKzYyWKfM9HUpmEOxsCzKR6RgQ6scM/oDJnhhySxnA VV3cOYGYf1woE9wWD32BgM5yDzctcfgaSyAJ9MhDntZcYflIMbaTJGx1xg/L1K367TMvIuiCw/GB ZdeqzyEOtJj+0vCKh1LwpSOwtQQT2XIbk0xMjexrzxlUEO4GucaCQXVFMjGtEtz5zCJo9qmpLZWI 5XoMmmjXsNGEJGmnfMOpyKA69LF1G X-Report-Abuse-To: spam@mailhost-1.trined.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:106867 Archived-At: --===============2439403886971696728== Content-Type: multipart/alternative; boundary="Apple-Mail=_E527F081-4B17-435C-A0D2-2A9B7D10F633" --Apple-Mail=_E527F081-4B17-435C-A0D2-2A9B7D10F633 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Gerben, I do not know if it is possible with Context.=20 But this definitely works with an xsl operation.=20 You will need an xsl file like this: myxslfile.xsl: = myxmlfile.xml John Gerben 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=3D=E2=80=98BAR', 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 = het volgende geschreven: >=20 >=20 >=20 >> On 15 Apr 2020, at 13:54, Wolfgang Schuster = > wrote: >>=20 >> Gerben Wierda schrieb am 15.04.2020 um 12:19: >>>> On 14 Apr 2020, at 11:52, Taco Hoekwater > wrote: >>>>> On 14 Apr 2020, at 11:25, Gerben Wierda > wrote: >>>>>=20 >>>>> This helps for adding information to my processing. >>>>>=20 >>>>> What I was also looking for is that I don=E2=80=99t have a = test.tex anymore, just the XML file I am parsing and a command line = action. >>>>>=20 >>>>> So, I use mtxrun, give it the name of an XML. lua code (using a = =E2=80=99script=E2=80=99 somewhere?) reads the XML, extracts a name = (e.g. =E2=80=98foo=E2=80=99) from it, creates a .tex file (e.g. = =E2=80=98foo.tex=E2=80=99), produces a .pdf file from that .tex file = (e.g. =E2=80=98foo.pdf'). >>>> When processing XML, I normally use >>>>=20 >>>> context =E2=80=94environment=3Dwhatever.tex file.xml >>>>=20 >>>> 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 >>>=20 >>> 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. >>>=20 >>> Pre-command: >>> XML: >>> contains file name =E2=80=9Cfoo=E2=80=9D >>> there is no .tex file >>>=20 >>> Command: >>> produces foo.tex (gets the name from the XML) and =E2=80=9Cfoo.pdf= " >>=20 >> 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. >=20 > That is different from >=20 > the resulting PDF file has the name of an entry/field in the = XML file. >=20 > So, what I am looking for is: >=20 > command foo.xml >=20 > which results in=20 >=20 > bar.pdf >=20 > where =E2=80=98bar=E2=80=99 is text in foo.xml >=20 > G >=20 >>=20 >> Wolfgang >>=20 >=20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_E527F081-4B17-435C-A0D2-2A9B7D10F633 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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=3D"1.0" encoding=3D"UTF-8"?>
<xsl:stylesheet version=3D"2.0" = xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform">

<xsl:output = method=3D"xml" indent=3D"yes" omit-xml-declaration=3D"yes"/>

  <xsl:template = match=3D"contacts">
  = <xsl:for-each-group select=3D"contact" = group-by=3D=E2=80=9Ccontact/@ad">
    = <xsl:result-document = href=3D"groep-{current-grouping-key()}.xml">
       <contacts>
         <xsl:copy-of = select=3D"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=3D=E2=80=9CBAR">John</name>
</contact>
<contact>
<name ad=3D=E2=80=9CBAR=E2=80=9D>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=3D=E2=80=98BAR', 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> 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=E2=80=99= 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 =E2=80=99script=E2=80=99 somewhere?) = reads the XML, extracts a name (e.g. =E2=80=98foo=E2=80=99) from it, = creates a .tex file (e.g. =E2=80=98foo.tex=E2=80=99), produces a .pdf = file from that .tex file (e.g. =E2=80=98foo.pdf').
When processing XML, I normally use

  context = =E2=80=94environment=3Dwhatever.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 =E2=80=9Cfoo=E2=80= =9D
there is no .tex file

Command:
produces = foo.tex (gets the name from the XML) and =E2=80=9Cfoo.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 =E2=80=98bar=E2=80=99 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
_______________________________________________________________= ____________________

= --Apple-Mail=_E527F081-4B17-435C-A0D2-2A9B7D10F633-- --===============2439403886971696728== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2439403886971696728==--