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
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
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 -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Martin Kolařík