ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* xml, language, btx problems
@ 2018-06-17 17:52 Thomas A. Schmitz
  2018-06-17 19:37 ` Pablo Rodriguez
  2018-06-17 22:58 ` Alan Braslau
  0 siblings, 2 replies; 9+ messages in thread
From: Thomas A. Schmitz @ 2018-06-17 17:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-17 17:52 xml, language, btx problems Thomas A. Schmitz
@ 2018-06-17 19:37 ` Pablo Rodriguez
  2018-06-17 20:10   ` Thomas A. Schmitz
  2018-06-17 22:58 ` Alan Braslau
  1 sibling, 1 reply; 9+ messages in thread
From: Pablo Rodriguez @ 2018-06-17 19:37 UTC (permalink / raw)
  To: ntg-context

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

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-17 19:37 ` Pablo Rodriguez
@ 2018-06-17 20:10   ` Thomas A. Schmitz
  2018-06-17 20:36     ` Wolfgang Schuster
  2018-06-18 16:36     ` Pablo Rodriguez
  0 siblings, 2 replies; 9+ messages in thread
From: Thomas A. Schmitz @ 2018-06-17 20:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-17 20:10   ` Thomas A. Schmitz
@ 2018-06-17 20:36     ` Wolfgang Schuster
  2018-06-18 16:36     ` Pablo Rodriguez
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2018-06-17 20:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 5262 bytes --]

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


[-- Attachment #1.2: Type: text/html, Size: 9101 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 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: xml, language, btx problems
  2018-06-17 17:52 xml, language, btx problems Thomas A. Schmitz
  2018-06-17 19:37 ` Pablo Rodriguez
@ 2018-06-17 22:58 ` Alan Braslau
  2018-06-18 10:19   ` Thomas A. Schmitz
  1 sibling, 1 reply; 9+ messages in thread
From: Alan Braslau @ 2018-06-17 22:58 UTC (permalink / raw)
  To: Thomas A. Schmitz; +Cc: mailing list for ConTeXt users

On Sun, 17 Jun 2018 19:52:35 +0200
"Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de> 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-17 22:58 ` Alan Braslau
@ 2018-06-18 10:19   ` Thomas A. Schmitz
  2018-06-18 10:53     ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas A. Schmitz @ 2018-06-18 10:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Alan Braslau

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-18 10:19   ` Thomas A. Schmitz
@ 2018-06-18 10:53     ` Hans Hagen
  2018-06-18 11:07       ` Thomas A. Schmitz
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2018-06-18 10:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Thomas A. Schmitz, Alan Braslau

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-18 10:53     ` Hans Hagen
@ 2018-06-18 11:07       ` Thomas A. Schmitz
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas A. Schmitz @ 2018-06-18 11:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans Hagen, Alan Braslau


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: xml, language, btx problems
  2018-06-17 20:10   ` Thomas A. Schmitz
  2018-06-17 20:36     ` Wolfgang Schuster
@ 2018-06-18 16:36     ` Pablo Rodriguez
  1 sibling, 0 replies; 9+ messages in thread
From: Pablo Rodriguez @ 2018-06-18 16:36 UTC (permalink / raw)
  To: ntg-context

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 <document> 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-06-18 16:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-17 17:52 xml, language, btx problems Thomas A. Schmitz
2018-06-17 19:37 ` Pablo Rodriguez
2018-06-17 20:10   ` Thomas A. Schmitz
2018-06-17 20:36     ` Wolfgang Schuster
2018-06-18 16:36     ` Pablo Rodriguez
2018-06-17 22:58 ` Alan Braslau
2018-06-18 10:19   ` Thomas A. Schmitz
2018-06-18 10:53     ` Hans Hagen
2018-06-18 11:07       ` Thomas A. Schmitz

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).