ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Strange expansion behavior in XML/luatex
@ 2010-05-29 10:01 Martin Kolařík
  2010-05-31 22:10 ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Kolařík @ 2010-05-29 10:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,

I had a problem with some my documents; I extracted it to as small code 
as possible. What is happening -- if any of xml flushing function (I 
tried xmlflush, xmlfilter and xmlall) is expanded to a macro (so the 
content of xml becomes a text of the macro), and the xml contains other 
hooked xml tags, the \edef (and its counterparts \xdef or 
\expandedaction) inside the inner tag is "skipped" by the log. Then 
macros relying on the expansion fail (I detected it in \doif and 
\processaction). Macros are normally expanded, only \edef fails (maybe 
some other TeX commands fail too, but I did not test it).

In my example below, content of "il" is flushed to a macro, "inline" is 
the inner tag and "\processaction" is the example of macro using 
"\edef". Do not look for sense, it is an example.

XML:
<?xml version="1.0" encoding="utf-8"?>
<il>
   Text <inline what="something" /> text.
</il>

TeX:
\startxmlsetups doc:inline
   \processaction
     [\xmlatt{#1}{what}]
     [something=>A thing,
        nothing=>Hic sunt leones]
\stopxmlsetups

\startxmlsetups doc:il
   \edef\content{\xmlflush{#1}}%
\stopxmlsetups

\xmlregistersetup{xml:doc}

\startxmlsetups xml:doc
   \xmlsetsetup{\xmldocument}{inline|il}{doc:*}
\stopxmlsetups

I do not know, if it is a bug or a feature :-); but notwithstanding the 
fact, similar code I used in MkII worked very well.

Thanks for hints,

Martin

-- 
Martin Kolařík

martin.kolarik@email.cz
martin.kolarik@jabber.cz
+420603535593

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Strange expansion behavior in XML/luatex
  2010-05-29 10:01 Strange expansion behavior in XML/luatex Martin Kolařík
@ 2010-05-31 22:10 ` Hans Hagen
  2010-06-01  7:03   ` Martin Kolařík
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2010-05-31 22:10 UTC (permalink / raw)
  To: martin.kolarik, mailing list for ConTeXt users

On 29-5-2010 12:01, Martin Kolařík wrote:

> I do not know, if it is a bug or a feature :-); but notwithstanding the
> fact, similar code I used in MkII worked very well.

effectively you as for:

\starttext
     \edef\content{\processaction[x][something=>A thing, nothing=>Hic 
sunt leones]}
\stoptext

and that will not work; ok, we could make processaction unexpandable but 
i'm sure that you want something different

you can save the content this way:

     \edef\content{#1}

and do this later on:

     \xmlflush{\content}

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Strange expansion behavior in XML/luatex
  2010-05-31 22:10 ` Hans Hagen
@ 2010-06-01  7:03   ` Martin Kolařík
  2010-06-01  7:51     ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Kolařík @ 2010-06-01  7:03 UTC (permalink / raw)
  Cc: mailing list for ConTeXt users

I see,

and for the single case it works. Also saving is fine, I am using it. 
Unfortunately, my example was too reduced :-). In fact, I have a problem 
with more complex documents, for example, think about:

<section>
<caption>Some <inline what="something"> caption</caption>
<text><p>Text.</p></text>
</section>

Now, if I want not to only typeset a caption, but also to store it and 
reuse it later (typeset it twice, e.g. in the marging or elsewhere in 
the page, ...), it fails (on \processaction, \doif, ...).

So, if I understand, there is a way to modify my XML template to be safe 
during expanding -- I would use self unexpandable macros). Another way 
is problematic, as \edef inside \edef causes problems? Is it true or 
there is some other way?

Thank you,

Martin

Dne 1.6.2010 0:10, Hans Hagen napsal(a):
> On 29-5-2010 12:01, Martin Kolařík wrote:
>
>> I do not know, if it is a bug or a feature :-); but notwithstanding the
>> fact, similar code I used in MkII worked very well.
>
> effectively you as for:
>
> \starttext
>     \edef\content{\processaction[x][something=>A thing, nothing=>Hic 
> sunt leones]}
> \stoptext
>
> and that will not work; ok, we could make processaction unexpandable 
> but i'm sure that you want something different
>
> you can save the content this way:
>
>     \edef\content{#1}
>
> and do this later on:
>
>     \xmlflush{\content}
>
> Hans
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Strange expansion behavior in XML/luatex
  2010-06-01  7:03   ` Martin Kolařík
@ 2010-06-01  7:51     ` Hans Hagen
  2010-06-01  8:17       ` Martin Kolařík
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2010-06-01  7:51 UTC (permalink / raw)
  To: martin.kolarik, mailing list for ConTeXt users

On 1-6-2010 9:03, Martin Kolařík wrote:
> I see,
>
> and for the single case it works. Also saving is fine, I am using it.
> Unfortunately, my example was too reduced :-). In fact, I have a problem
> with more complex documents, for example, think about:
>
> <section>
> <caption>Some <inline what="something"> caption</caption>
> <text><p>Text.</p></text>
> </section>
>
> Now, if I want not to only typeset a caption, but also to store it and
> reuse it later (typeset it twice, e.g. in the marging or elsewhere in
> the page, ...), it fails (on \processaction, \doif, ...).

can't you just filter the caption then? in principle you can access each 
element everywhere

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Strange expansion behavior in XML/luatex
  2010-06-01  7:51     ` Hans Hagen
@ 2010-06-01  8:17       ` Martin Kolařík
  2010-06-01  8:23         ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Kolařík @ 2010-06-01  8:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

I the case probably yes. Now I have new info how to continue with my 
MkII-->MkIV conversion, so I will do. I prefer to keep the XML schema 
and the style as clean and simple as possible, but this does not 
necessarily mean that the typesetting code itself will be clean and 
simple too :-),

Thanks for now; I will ask you, if I do not succeed :-),

Martin

Dne 1.6.2010 9:51, Hans Hagen napsal(a):
> On 1-6-2010 9:03, Martin Kolařík wrote:
>> I see,
>>
>> and for the single case it works. Also saving is fine, I am using it.
>> Unfortunately, my example was too reduced :-). In fact, I have a problem
>> with more complex documents, for example, think about:
>>
>> <section>
>> <caption>Some <inline what="something"> caption</caption>
>> <text><p>Text.</p></text>
>> </section>
>>
>> Now, if I want not to only typeset a caption, but also to store it and
>> reuse it later (typeset it twice, e.g. in the marging or elsewhere in
>> the page, ...), it fails (on \processaction, \doif, ...).
>
> can't you just filter the caption then? in principle you can access 
> each element everywhere
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------

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

[-- Attachment #2: Type: text/plain, Size: 486 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Strange expansion behavior in XML/luatex
  2010-06-01  8:17       ` Martin Kolařík
@ 2010-06-01  8:23         ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2010-06-01  8:23 UTC (permalink / raw)
  To: martin.kolarik, mailing list for ConTeXt users

On 1-6-2010 10:17, Martin Kolařík wrote:
> I the case probably yes. Now I have new info how to continue with my
> MkII-->MkIV conversion, so I will do. I prefer to keep the XML schema
> and the style as clean and simple as possible, but this does not
> necessarily mean that the typesetting code itself will be clean and
> simple too :-),

indeed, as the problems themselves don't change there is no guarantee 
that the outcome looks clean; this is also why using external tools 
(like xslt) is not making things easier and cleaner

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2010-06-01  8:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-29 10:01 Strange expansion behavior in XML/luatex Martin Kolařík
2010-05-31 22:10 ` Hans Hagen
2010-06-01  7:03   ` Martin Kolařík
2010-06-01  7:51     ` Hans Hagen
2010-06-01  8:17       ` Martin Kolařík
2010-06-01  8:23         ` Hans Hagen

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