Observations ConTeXt & XML 5th ConTeXt Meeting, Bassenge, Belgium Jano Kula 21. 9. 2011 � � � � �
Files Topics Indexes Exceptions Solution XML Conclusion Reaching the Limits � � � � �
LaTeX Files � � � � �
ConTeXt Files � � � � �
Files <filename="book.tex"> even if you give up direct processing of XML there are still indexes, you — hand made changes not possible, exceptions — advanced XSLT constructs (grouping) — </filename> <include file="04.tex"> <include file="03.tex"> <include file="02.tex"> <include file="01.tex"> any editor of virtual file? — keep structure — change in XSLT always reqires a change in other files — less files = big simplification (creating, maintaining) — Conclusion cannot influence in detail (external file) � � � � �
“I Know Where I'm Going!” Indexes Çoğunluk Čestná stráž Cœurs È finita la commedia Écrivain d’O İklimler Værelse 304 Žralok v hlavě � � � � �
— Indexes countries: definite set — proper nouns (names, movies): expect literally anything � � � � �
Examples Exceptions � � � � �
Solution \IfFileExists{<filename>}{<do>}{<else>} — based on screening ID — based on movie ID — exceptions based in the tree structure, not influencing style file — result doesn't look good or is not easily usable “be strict or don't complain” is not a solution: — possibly containg exception content � � � � �
Escaping Solution % special characters \def\EscapeSpecials#1{\directlua{% local f = "#1" f = string.gsub(f, '\letterampersand', '{\\\\letterampersand}') f = string.gsub(f, '\letterunderscore', '{\\\\letterunderscore}') f = string.gsub(f, '\letterhash', '{\\\\letterhash}') tex.write(f) }} still one character remaining in data, changed externally by sed : s/'/’/g � � � � �
Solution f = string.gsub(f, ' +\letterdollar', '') tex.write(f) f = string.gsub(f, '[ ]+–[ ]+', '~– ') f = string.gsub(f, '[ ]+[–][ ]+', '~– ') f = string.gsub(f, '[ ]+[-][ ]+', '~– ') % dashes f = string.gsub(f, '[ ]+:[ ]*', ': ') f = string.gsub(f, '[ ]*…[ ]*', '… ') f = string.gsub(f, '[.][.][.]', '…') f = string.gsub(f, '^ +', '') % leading and trailing spaces local f = '#1' \def\Nice#1{\directlua{% Typesetting }} � � � � �
Solution f = string.gsub(f, 'H2O', 'H 2O') All-in-one }} tex.write(f) f = string.gsub(f, '\letterpercent ]', '') % ignore ] f = string.gsub(f, '\letterpercent [', '') % ignore [ f = string.gsub(f, 'V I N Y L', 'VINYL') local f = "#1" \def\ChangeSorting#1{\directlua{% Indexes \Nice{\ChangeSorting{\EscapeSpecials{\xmltext{#1}{/OriginalTitle}}}} � � � � �
XML \xmlprocessfile{main}{input.xml}{} lost in the tree — \stopmode \xmlprocessfile{main}{input.xml}{} \startmode[Black] \stopmode \startmode[Color] multiple processing of one XML tree (color part, black part) — \xmlshow shows nodes from actual position forward � � � � �
XML \xmltext{#1}{/OriginalTitle}% {\currentregisterpageuserdata{myrealpage}} \def\MyRegisterPageCommand#1% %} ][myrealpage=\pagenumber] }}}% \xmltext{#1}{/OriginalTitle},~\xmltext{#1}{/OriginalArticle} entries:1={\Nice{\EscapeSpecials{% }}}},% keys:1={\Nice{\ChangeSorting{\EscapeSpecials{% \setregisterentry[IndexOriginal][ %\expanded{ moving information around — \setupregisters[pagecommand=\MyRegisterPageCommand] � � � � �
— Conclusion partial answer: lpeg — other fallbacks? tuc file? � � � � �
Reaching the Limits � � � � �
Recommend
More recommend