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