Observations ConTeXt & XML 5th ConTeXt Meeting, Bassenge, - - PowerPoint PPT Presentation

observations context xml
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1
  • ConTeXt & XML

Observations

5th ConTeXt Meeting, Bassenge, Belgium

Jano Kula

  • 21. 9. 2011
slide-2
SLIDE 2

Topics

  • Files

Indexes Exceptions Solution XML Conclusion Reaching the Limits

slide-3
SLIDE 3

Files

  • LaTeX
slide-4
SLIDE 4

Files

  • ConTeXt
slide-5
SLIDE 5

Files

  • Conclusion

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

slide-6
SLIDE 6

Indexes

  • “I Know Where I'm Going!”

Çoğunluk Čestná stráž Cœurs È finita la commedia Écrivain d’O İklimler Værelse 304 Žralok v hlavě

slide-7
SLIDE 7

Indexes

countries: definite set — proper nouns (names, movies): expect literally anything

slide-8
SLIDE 8

Exceptions

  • Examples
slide-9
SLIDE 9

Solution

“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

slide-10
SLIDE 10

Solution

  • Escaping

% 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

slide-11
SLIDE 11

Solution

  • Typesetting

\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) }}

slide-12
SLIDE 12

Solution

  • Indexes

\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}}}}

slide-13
SLIDE 13

XML

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

slide-14
SLIDE 14

XML

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]

slide-15
SLIDE 15

Conclusion

partial answer: lpeg —

  • ther fallbacks? tuc file?
slide-16
SLIDE 16

Reaching the Limits