mtx-context-xml.tex /size: 2674 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=mtx-context-xml,
3
%D version=2013.05.30,
4
%D title=\CONTEXT\ Extra Trickry,
5
%D subtitle=Analyzing XML files,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% This module replaces mkii analyzers.
15 16
% begin help
17
%
18
% usage: context --extra=xml [options] list-of-files
19
%
20
% --analyze : show elements and characters
21
% --template : also export template
22
% --topspace=dimension : distance above first line
23
% --backspace=dimension : distance before left margin
24
% --bodyfont=list : additional bodyfont settings
25
% --paperformat=spec : paper*print or paperxprint
26
%
27
% context --extra=xml --analyze path::i-context.xml
28
% context --extra=xml --analyze --template path::i-context.xml
29
% context --extra=xml --analyze selfautoparent:texmf-context/tex/context/interface/mkiv/i-*.xml
30
% end help
31 32
\input
mtx
-
context
-
common
.
tex
33 34
\setupbodyfont
35
[
dejavu
,
1
1
pt
,
tt
,
\getdocumentargument
{
bodyfont
}
]
36 37
\setuptyping
38
[
lines
=
yes
]
39 40
\setuplayout
41
[
header
=
0
cm
,
42
footer
=
1
.
5
cm
,
43
topspace
=
\getdocumentargumentdefault
{
topspace
}{
1
.
5
cm
}
,
44
backspace
=
\getdocumentargumentdefault
{
backspace
}{
1
.
5
cm
}
,
45
width
=
middle
,
46
height
=
middle
]
47 48
\setuppapersize
49
[
\getdocumentargument
{
paperformat
_
paper
}
]
50
[
\getdocumentargument
{
paperformat
_
print
}
]
51 52
\usemodule
[
xml
-
analyzers
]
53 54
\starttext
55 56
\startluacode
57
local
files
=
document
.
files
58
local
pattern
=
document
.
arguments
.
pattern
or
(
#
files
=
=
1
and
files
[
1
]
)
59
local
analyze
=
document
.
arguments
.
analyze
60
local
template
=
document
.
arguments
.
template
61 62
if
pattern
then
63
files
=
dir
.
glob
(
pattern
)
64
context
.
setupfootertexts
(
{
pattern
}
,
{
"
pagenumber
"
}
)
65
else
66
context
.
setupfootertexts
(
{
table
.
concat
(
files
,
"
"
)
}
,
{
"
pagenumber
"
}
)
67
end
68 69
if
#
files
>
0
then
70
if
analyze
then
71
moduledata
.
xml
.
analyzers
.
structure
(
files
)
72
context
.
page
(
)
73
moduledata
.
xml
.
analyzers
.
characters
(
files
)
74
context
.
page
(
)
75
moduledata
.
xml
.
analyzers
.
entities
(
files
)
76
if
template
then
77
moduledata
.
xml
.
analyzers
.
allsetups
(
files
,
type
(
template
)
=
=
"
string
"
and
template
or
nil
)
78
end
79
context
.
page
(
)
80
for
i
=
1
,
#
files
do
81
context
.
type
(
files
[
i
]
)
82
context
.
par
(
)
83
end
84
else
85
context
(
"
no action given
"
)
86
end
87
else
88
context
(
"
no files given
"
)
89
end
90
\stopluacode
91 92
\stoptext
93