Re: [NTG-context] xml, language, btx problems

2018-06-18 Thread Pablo Rodriguez
On 06/17/2018 10:10 PM, Thomas A. Schmitz wrote:
> On 06/17/2018 09:37 PM, Pablo Rodriguez wrote:
> [...]
> 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):
> [...]
> Is there any way to set the language before the  element is 
> processed?

Sorry, Thomas, I never used bibliographies and I didn’t realize that
your requirements were different than language-based page sizes (which
was my actual test handling XML sources).

Pablo
-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] xml, language, btx problems

2018-06-18 Thread Thomas A. Schmitz



sometimes you need to do

\starttexcode
   ...
\stoptexcode

when inside some special caocode regime (which happens in xml)

Hans


Hans, thank you - that was the golden hint! It works now as I've always 
wanted! And I realize once again that I know far less about ConTeXt than 
I wished and thought...


Wolfgang: thanks for your suggestions, too! I had thought about loading 
the xml document twice, the first time just for extracting the 
"language" information, but felt it was less than elegant and maybe not 
quite efficient (my lecture course xmls tend to have more thah 25,000 
lines). But I didn't provide enough information for you to see the 
easiest solution.


Thanks, I'm a happy camper again (I have to prepare the handout for a 
talk I'm giving next week in Israel...)


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
___

Re: [NTG-context] xml, language, btx problems

2018-06-18 Thread Hans Hagen

On 6/18/2018 12:19 PM, Thomas A. Schmitz wrote:

Hi Alan,

thanks for joining the discussion! Just to answer your two queries about 
my setup:


On 06/18/2018 12:58 AM, Alan Braslau wrote:

Thomas,

Why would the definitions need to be loaded before \starttext?
The bibliographic data can be loaded independent of any rendering or
use definitions.


That's what I deduced from my experiments. When I load the definitions 
in the xml setup of the root element, they are not loaded, but printed 
verbatim to the pdf file. My deduction may be wrong - this is a pretty 
complex setup, in which I produce slides, manuscript (in different 
formats), handout, and bibliography all from the same xml source. So it 
may be some interference/interaction of these complex parts that I don't 
quite understand. I'll continue experimenting...

sometimes you need to do

\starttexcode
  ...
\stoptexcode

when inside some special caocode regime (which happens in xml)

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
___

Re: [NTG-context] xml, language, btx problems

2018-06-18 Thread Thomas A. Schmitz

Hi Alan,

thanks for joining the discussion! Just to answer your two queries about 
my setup:


On 06/18/2018 12:58 AM, Alan Braslau wrote:

Thomas,

Why would the definitions need to be loaded before \starttext?
The bibliographic data can be loaded independent of any rendering or
use definitions.


That's what I deduced from my experiments. When I load the definitions 
in the xml setup of the root element, they are not loaded, but printed 
verbatim to the pdf file. My deduction may be wrong - this is a pretty 
complex setup, in which I produce slides, manuscript (in different 
formats), handout, and bibliography all from the same xml source. So it 
may be some interference/interaction of these complex parts that I don't 
quite understand. I'll continue experimenting...


Also, why don't you write your custom definitions to

handle languages, rather than writing new definition sets based on
language?

There is one stumbling block that made me think I had to have two 
separate setups (in addition to the fact that it makes the source 
cleaner and easier to maintain): I copied publ-imp-apa.* and modified it 
to suit my needs. Now for apa, editors and authors are included in one 
set, e.g., in line 169-171:


categories.book = {
sets = {
author = { "author", "editor", "publisher", "title" },
}

In my German bibliography file, I distinguish between authored volumes 
and edited volumes both for the presentation and for the sorting:


Author, Firstname: Title ...

as opposed to

Edited Volume, hrsg. von Firstname Editor ...

and I found that as long as I had this "set" line in my 
publ-imp-style.lua file, I would always get


Editor, Firstname: Edited Volume, hrsg. von Firstname Editor ...

When I deleted the line, I could get what I wanted. So my inference was 
that for my German bibliography, I needed a different lua and a 
different publ-imp-.tex file. But maybe I was wrong and you have an 
easier approach?


All best and thanks!

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
___

Re: [NTG-context] xml, language, btx problems

2018-06-17 Thread Alan Braslau
On Sun, 17 Jun 2018 19:52:35 +0200
"Thomas A. Schmitz"  wrote:

> However, this implies a \starttext. And the btxdefinitions need to be 
> loaded before \starttext, or so it seems.

Thomas,

Why would the definitions need to be loaded before \starttext?
The bibliographic data can be loaded independent of any rendering or
use definitions. Also, why don't you write your custom definitions to
handle languages, rather than writing new definition sets based on
language?

Alan
___
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
___

Re: [NTG-context] xml, language, btx problems

2018-06-17 Thread Wolfgang Schuster
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]

   test

\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 
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:



...


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 
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 
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]

   test

\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  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
___


___
If your 

Re: [NTG-context] xml, language, btx problems

2018-06-17 Thread Thomas A. Schmitz

On 06/17/2018 09:37 PM, Pablo Rodriguez wrote:

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.


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]

   test

\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  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
___

Re: [NTG-context] xml, language, btx problems

2018-06-17 Thread Pablo Rodriguez
On 06/17/2018 07:52 PM, Thomas A. Schmitz wrote:
> 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:
> 
> 
> ...
> 
> 
> 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

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
-- 
http://www.ousia.tk
___
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
___

[NTG-context] xml, language, btx problems

2018-06-17 Thread Thomas A. Schmitz

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:



...


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
___