One option is to load your document at the beginning with different setups where you only process the language information. Another option is to put the language dependent options in a setups block and load them when you process the XML file. \startbuffer[test] <document language="de"> test </document> \stopbuffer \startxmlsetups [xml:testsetups] \xmlsetsetup{\xmldocument}{document}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups [xml:document] \mainlanguage[\xmlatt{#1}{language}] \startdocument \xmlflush{#1} \stopdocument \stopxmlsetups % The “document:start” setup is used by default with % the before key of the \startdocument command \startsetups [document:start] \startmodeset [**de] {This document is in german.\par} [**en] {This document is in english.\par} [default] {This document uses the default language.\par} \stopmodeset \stopsetups \starttext \xmlprocessbuffer{main}{test}{} \stoptext Wolfgang
Thomas A. Schmitz mailto:thomas.schmitz@uni-bonn.de 17. Juni 2018 um 19:52 Hi,
I have a conceptual problem integrating btx into my xml workflow. There are too many files involved, so no minimal example, but a minimal description. Root of my xml document:
<document language="en"> ... </document>
I have two files with btx definitions:
publ-imp-deutsch.mkvi
publ-imp-english.mkvi
Loading one of these two should depend on the main language:
\doifelse {\currentlanguage} {en} {\usebtxdefinitions [english]} {\usebtxdefinitions [deutsch]}
My problem: the main language is set within the processing rules for the root of my xml document:
\startxmlsetups xml:document \mainlanguage[\xmlatt{#1}{language}] \stopxmlsetups
However, this implies a \starttext. And the btxdefinitions need to be loaded before \starttext, or so it seems. Which means: the processing rules for \usebtxdefinitions need to be set outside of the xml setups. But at this moment, the main language is not set yet, and the \doifelse fails. Any hints how to get out of this conundrum?
Thanks, and all best
Thomas ___________________________________________________________________________________
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 ___________________________________________________________________________________ Pablo Rodriguez mailto:oinos@gmx.es 17. Juni 2018 um 21:37
Hi Thomas,
this may work in your case:
\startxmlsetups xml:document \mainlanguage[\xmlatt{#1}{language}] \doifmodeelse{**en} {\usebtxdefinitions [english]} {\usebtxdefinitions [deutsch]} \stopxmlsetups
I have just checked in with another document and it worked as expected.
Of course, "\doifelse{\currentmainlanguage}{en}" also works fine for me.
I hope it helps,
Pablo Thomas A. Schmitz mailto:thomas.schmitz@uni-bonn.de 17. Juni 2018 um 22:10
Thank you for your suggestion, Pablo, but this is just a slightly different syntax to express the same test, this doesn't change anything. Maybe this document is clearer in explaining my problem (and results are identical with the \doifmodeelse syntax):
\startbuffer[test] <document language="de"> test </document> \stopbuffer
\startxmlsetups xml:testsetups \xmlsetsetup{\xmldocument}{document}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:testsetups}
\startxmlsetups xml:document \mainlanguage[\xmlatt{#1}{language}] Language settings work correctly here:
\doifelse {\currentmainlanguage} {de} {\color [blue] {Deutsch}} {\color [red] {English}}\par \xmlflush{#1} \stopxmlsetups
\starttext This is where the btx set has to be loaded, and language settings do not work as needed:
\doifelse {\currentmainlanguage} {de} {\color [blue] {Deutsch}} {\color [red] {English}}\par
\xmlprocessbuffer{main}{test}{}
\stoptext
Is there any way to set the language before the <document> element is processed? I experimented with this
\startxmlsetups xml:language:initiate \mainlanguage[\xmlattribute{\xmldocument}{root::/document}{language}] \stopxmlsetups
\xmlbeforedocumentsetup{\xmldocument}{xml:language:initiate}{xml:testsetups}
but this doesn't work, and I'm not sure I'm using it the right way.
All best
Thomas ___________________________________________________________________________________
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 ___________________________________________________________________________________