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: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
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
___________________________________________________________________________________
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-contextwebpage :
http://www.pragma-ade.nl /
http://context.aanhet.netarchive :
https://bitbucket.org/phg/context-mirror/commits/wiki :
http://contextgarden.net___________________________________________________________________________________