summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/x-xml-11.mkii
blob: 047561370e96c6b9de2746a0b13e092c997c39c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
%D \module
%D   [      file=x-xml-11,
%D        version=2004.09.16,
%D          title=\CONTEXT\ XML Style File,
%D       subtitle=Formatting X?? files,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% xmltools --analyze yourfile.xml
% texexec --use=xml-analyze yourfile.*

% \doifnothing  {\inputfilename}    {\end}
% \doiffileelse {\inputfilename} {} {\end}

\doifnothing  {\jobfullname}    {\end}
\doiffileelse {\jobfullname} {} {\end}

\useXMLfilter[ent]
\useXMLfilter[utf]

\chardef\XMLtokensreduction\plustwo

\definehead
  [SomeElement]
  [subsection]

\setuphead
  [SomeElement]
  [ownnumber=yes,
   style=\tfb,
   numberstyle=\tfxx,
   alternative=margin]

\setuplayout
  [width=middle,
   height=middle,
   backspace=2cm,
   cutspace=1cm,
   topspace=1cm,
   header=0pt]

\setupfootertexts
  [\jobfullname] % [\inputfilename]

\usetypescript[modern][texnansi] \setupbodyfont[modern,tt,10pt]

\defineXMLenvironment
  [document]
  {}
  {}

\defineXMLpickup
  [entities][n=0]
  {\expanded{\SomeElement{\XMLop{n}}{Entities}}
   \starttabulate[|l|l|l|]}
  {\stoptabulate}

\defineXMLcommand % ugly hack (make macro of it)
  [entity][name=,n=0]
  {\startexpanded
     \noexpand \NC \XMLop{name}
     \noexpand \NC \XMLop{n}
     \noexpand \NC \noexpand\doXMLentity\XMLop{name};
     \noexpand \NC
     \noexpand \NR
   \stopexpanded}

\defineXMLpickup
  [characters][n=0]
  {\expanded{\SomeElement{\XMLop{n}}{Characters}}
   \bgroup
   \let\nonbreakablespace\empty % messes up the table
   \starttabulate[|l|r|r|l|l|l|l|]}
  {\stoptabulate
   \egroup}

% todo: narrowtt

\defineXMLcommand
  [character][number=,utf=,n=0,uname=,pname=,cname=]
  {\startexpanded
     \noexpand \NC \noexpand \unicodehexnumber{\XMLop{number}}
     \noexpand \NC \XMLop{number}
     \noexpand \NC \XMLop{n}
     \noexpand \NC \noexpand \unicodechar     {\XMLop{number}}
     \noexpand \NC \tx \lowercase\expandafter{\XMLop{uname}}
     \noexpand \NC \tx \noexpand \unicodepair     {\XMLop{number}}
     \noexpand \NC \tx \XMLop{cname}
     \noexpand \NC
     \noexpand \NR
   \stopexpanded}

\defineXMLenvironment
  [elements]
  {}
  {}

\newtoks \TabulateToks

\defineXMLpickup
  [element][name=,n=0]
  {\expanded{\SomeElement{\XMLop{n}}{\XMLop{name}}}
   \TabulateToks\emptytoks}
  {\starttabulate[|l|r|p|]
   \the\TabulateToks
   \stoptabulate}

\defineXMLenvironment
  [attribute][name=]
  {\xdef\AttributeName{\XMLop{name}}}
  {}

\defineXMLenvironment
  [instance][value=,n=0]
  {\appendetoks
     \noexpand \NC \AttributeName
     \noexpand \NC \XMLop{n}
     \noexpand \NC \XMLop{value}
     \noexpand \NC
     \noexpand \NR
   \to \TabulateToks}
  {\xdef\AttributeName{}}

\starttext

% \processXMLfilegrouped{\inputfilename}
\processXMLfilegrouped{\jobfullname}

\stoptext