lxml-ini.lua /size: 16 Kb    last modification: 2021-10-28 13:50
1
    
if
not
modules
then
modules
=
{
}
end
modules
[
'
lxml-ini
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
this module is the basis for the lxml-* ones
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
7
}
8 9
local
xml
=
xml
10
local
lxml
=
lxml
11 12
-- this defines an extra scanner lxmlid:
13 14
local
scanners
=
tokens
.
scanners
15
local
scanstring
=
scanners
.
string
16
local
getid
=
lxml
.
id
17 18
scanners
.
lxmlid
=
function
(
)
return
getid
(
scanstring
(
)
)
end
19 20
local
implement
=
interfaces
.
implement
21 22
-- lxml.id
23 24
implement
{
name
=
"
lxmlid
"
,
public
=
true
,
actions
=
lxml
.
getid
,
arguments
=
"
string
"
}
25 26
implement
{
name
=
"
xmldoif
"
,
public
=
true
,
actions
=
lxml
.
doif
,
arguments
=
"
2 strings
"
}
27
implement
{
name
=
"
xmldoifnot
"
,
public
=
true
,
actions
=
lxml
.
doifnot
,
arguments
=
"
2 strings
"
}
28
implement
{
name
=
"
xmldoifelse
"
,
public
=
true
,
actions
=
lxml
.
doifelse
,
arguments
=
"
2 strings
"
}
29
implement
{
name
=
"
xmldoiftext
"
,
public
=
true
,
actions
=
lxml
.
doiftext
,
arguments
=
"
2 strings
"
}
30
implement
{
name
=
"
xmldoifnottext
"
,
public
=
true
,
actions
=
lxml
.
doifnottext
,
arguments
=
"
2 strings
"
}
31
implement
{
name
=
"
xmldoifelsetext
"
,
public
=
true
,
actions
=
lxml
.
doifelsetext
,
arguments
=
"
2 strings
"
}
32 33
implement
{
name
=
"
xmldoifempty
"
,
public
=
true
,
actions
=
lxml
.
doifempty
,
arguments
=
"
2 strings
"
}
34
implement
{
name
=
"
xmldoifnotempty
"
,
public
=
true
,
actions
=
lxml
.
doifnotempty
,
arguments
=
"
2 strings
"
}
35
implement
{
name
=
"
xmldoifelseempty
"
,
public
=
true
,
actions
=
lxml
.
doifelseempty
,
arguments
=
"
2 strings
"
}
36
implement
{
name
=
"
xmldoifselfempty
"
,
public
=
true
,
actions
=
lxml
.
doifempty
,
arguments
=
"
string
"
}
-- second arg is not passed (used)
37
implement
{
name
=
"
xmldoifnotselfempty
"
,
public
=
true
,
actions
=
lxml
.
doifnotempty
,
arguments
=
"
string
"
}
-- second arg is not passed (used)
38
implement
{
name
=
"
xmldoifelseselfempty
"
,
public
=
true
,
actions
=
lxml
.
doifelseempty
,
arguments
=
"
string
"
}
-- second arg is not passed (used)
39 40
--------- { name = "xmlcontent", actions = lxml.content, arguments = "string" }
41
--------- { name = "xmlflushstripped", actions = lxml.strip, arguments = { "string", true } }
42 43
implement
{
name
=
"
xmlall
"
,
public
=
true
,
actions
=
lxml
.
all
,
arguments
=
"
2 strings
"
}
44
implement
{
name
=
"
xmlatt
"
,
public
=
true
,
actions
=
lxml
.
att
,
arguments
=
"
2 strings
"
}
45
implement
{
name
=
"
xmlattdef
"
,
public
=
true
,
actions
=
lxml
.
att
,
arguments
=
"
3 strings
"
}
46
implement
{
name
=
"
xmlattribute
"
,
public
=
true
,
actions
=
lxml
.
attribute
,
arguments
=
"
3 strings
"
}
47
implement
{
name
=
"
xmlattributedef
"
,
public
=
true
,
actions
=
lxml
.
attribute
,
arguments
=
"
4 strings
"
}
48
implement
{
name
=
"
xmlbadinclusions
"
,
public
=
true
,
actions
=
lxml
.
badinclusions
,
arguments
=
"
string
"
}
49
implement
{
name
=
"
xmlchainatt
"
,
public
=
true
,
actions
=
lxml
.
chainattribute
,
arguments
=
{
"
string
"
,
"
'/'
"
,
"
string
"
}
}
50
implement
{
name
=
"
xmlchainattdef
"
,
public
=
true
,
actions
=
lxml
.
chainattribute
,
arguments
=
{
"
string
"
,
"
'/'
"
,
"
string
"
,
"
string
"
}
}
51
implement
{
name
=
"
xmlchecknamespace
"
,
public
=
true
,
actions
=
xml
.
checknamespace
,
arguments
=
{
"
lxmlid
"
,
"
string
"
,
"
string
"
}
}
52
implement
{
name
=
"
xmlcommand
"
,
public
=
true
,
actions
=
lxml
.
command
,
arguments
=
"
3 strings
"
}
53
implement
{
name
=
"
xmlconcat
"
,
actions
=
lxml
.
concat
,
arguments
=
"
3 strings
"
}
-- \detokenize{#3}
54
implement
{
name
=
"
xmlconcatrange
"
,
actions
=
lxml
.
concatrange
,
arguments
=
"
5 strings
"
}
-- \detokenize{#5}
55
--------- { name = "xmlconcat", actions = lxml.concat, arguments = { "string", "string", "verbatim" } }
56
--------- { name = "xmlconcatrange", actions = lxml.concatrange, arguments = { "string", "string", "string", "string", "verbatim" } }
57
implement
{
name
=
"
xmlcontext
"
,
public
=
true
,
actions
=
lxml
.
context
,
arguments
=
"
2 strings
"
}
58
implement
{
name
=
"
xmlcount
"
,
public
=
true
,
actions
=
lxml
.
count
,
arguments
=
"
2 strings
"
}
59
implement
{
name
=
"
xmldepth
"
,
public
=
true
,
actions
=
lxml
.
depth
,
arguments
=
"
string
"
}
60
implement
{
name
=
"
xmldelete
"
,
public
=
true
,
actions
=
lxml
.
delete
,
arguments
=
"
2 strings
"
}
61
implement
{
name
=
"
xmldirect
"
,
public
=
true
,
actions
=
lxml
.
direct
,
arguments
=
"
string
"
}
62
implement
{
name
=
"
xmldirectives
"
,
public
=
true
,
actions
=
lxml
.
directives
.
setup
,
arguments
=
"
string
"
}
63
implement
{
name
=
"
xmldirectivesafter
"
,
public
=
true
,
actions
=
lxml
.
directives
.
after
,
arguments
=
"
string
"
}
64
implement
{
name
=
"
xmldirectivesbefore
"
,
public
=
true
,
actions
=
lxml
.
directives
.
before
,
arguments
=
"
string
"
}
65
implement
{
name
=
"
xmldisplayverbatim
"
,
public
=
true
,
actions
=
lxml
.
displayverbatim
,
arguments
=
"
string
"
}
66
implement
{
name
=
"
xmlelement
"
,
public
=
true
,
actions
=
lxml
.
element
,
arguments
=
"
2 strings
"
}
-- could be integer but now we can alias
67
implement
{
name
=
"
xmlfilter
"
,
public
=
true
,
actions
=
lxml
.
filter
,
arguments
=
"
2 strings
"
}
68
implement
{
name
=
"
xmlfilterlist
"
,
public
=
true
,
actions
=
lxml
.
filterlist
,
arguments
=
"
2 strings
"
}
69
implement
{
name
=
"
xmlfirst
"
,
public
=
true
,
actions
=
lxml
.
first
,
arguments
=
"
2 strings
"
}
70
implement
{
name
=
"
xmlflush
"
,
public
=
true
,
actions
=
lxml
.
flush
,
arguments
=
"
string
"
}
71
implement
{
name
=
"
xmlflushcontext
"
,
public
=
true
,
actions
=
lxml
.
context
,
arguments
=
"
string
"
}
72
implement
{
name
=
"
xmlflushlinewise
"
,
public
=
true
,
actions
=
lxml
.
flushlinewise
,
arguments
=
"
string
"
}
73
implement
{
name
=
"
xmlflushpure
"
,
public
=
true
,
actions
=
lxml
.
pure
,
arguments
=
"
string
"
}
74
implement
{
name
=
"
xmlflushspacewise
"
,
public
=
true
,
actions
=
lxml
.
flushspacewise
,
arguments
=
"
string
"
}
75
implement
{
name
=
"
xmlflushtext
"
,
public
=
true
,
actions
=
lxml
.
text
,
arguments
=
"
string
"
}
76
implement
{
name
=
"
xmlfunction
"
,
public
=
true
,
actions
=
lxml
.
applyfunction
,
arguments
=
"
2 strings
"
}
77
implement
{
name
=
"
xmlinclude
"
,
public
=
true
,
actions
=
lxml
.
include
,
arguments
=
{
"
string
"
,
"
string
"
,
"
string
"
,
true
}
}
78
implement
{
name
=
"
xmlincludeoptions
"
,
public
=
true
,
actions
=
lxml
.
include
,
arguments
=
"
4 strings
"
}
79
implement
{
name
=
"
xmlinclusion
"
,
public
=
true
,
actions
=
lxml
.
inclusion
,
arguments
=
"
string
"
}
80
implement
{
name
=
"
xmlinclusionbase
"
,
public
=
true
,
actions
=
lxml
.
inclusion
,
arguments
=
{
"
string
"
,
false
,
true
}
}
81
implement
{
name
=
"
xmlinclusions
"
,
public
=
true
,
actions
=
lxml
.
inclusions
,
arguments
=
"
string
"
}
82
implement
{
name
=
"
xmlindex
"
,
public
=
true
,
actions
=
lxml
.
index
,
arguments
=
"
3 strings
"
}
-- can be integer but now we can alias
83
implement
{
name
=
"
xmlinlineverbatim
"
,
public
=
true
,
actions
=
lxml
.
inlineverbatim
,
arguments
=
"
string
"
}
84
implement
{
name
=
"
xmllast
"
,
public
=
true
,
actions
=
lxml
.
last
,
arguments
=
"
2 strings
"
}
85
implement
{
name
=
"
xmllastatt
"
,
public
=
true
,
actions
=
lxml
.
lastatt
}
86
implement
{
name
=
"
xmllastmatch
"
,
public
=
true
,
actions
=
lxml
.
lastmatch
}
87
implement
{
name
=
"
xmllastpar
"
,
public
=
true
,
actions
=
lxml
.
lastpar
}
88
implement
{
name
=
"
xmlloadfile
"
,
actions
=
lxml
.
load
,
arguments
=
"
3 strings
"
}
89
implement
{
name
=
"
xmlloadbuffer
"
,
actions
=
lxml
.
loadbuffer
,
arguments
=
"
3 strings
"
}
90
implement
{
name
=
"
xmlloaddata
"
,
actions
=
lxml
.
loaddata
,
arguments
=
"
3 strings
"
}
91
implement
{
name
=
"
xmlloaddirectives
"
,
public
=
true
,
actions
=
lxml
.
directives
.
load
,
arguments
=
"
string
"
}
92
implement
{
name
=
"
xmlmain
"
,
public
=
true
,
actions
=
lxml
.
main
,
arguments
=
"
string
"
}
93
implement
{
name
=
"
xmlmatch
"
,
public
=
true
,
actions
=
lxml
.
match
,
arguments
=
"
string
"
}
94
implement
{
name
=
"
xmlname
"
,
public
=
true
,
actions
=
lxml
.
name
,
arguments
=
"
string
"
}
95
implement
{
name
=
"
xmlnamespace
"
,
public
=
true
,
actions
=
lxml
.
namespace
,
arguments
=
"
string
"
}
96
implement
{
name
=
"
xmlnonspace
"
,
public
=
true
,
actions
=
lxml
.
nonspace
,
arguments
=
"
2 strings
"
}
97
implement
{
name
=
"
xmlpar
"
,
public
=
true
,
actions
=
lxml
.
par
,
arguments
=
"
2 strings
"
}
98
implement
{
name
=
"
xmlparam
"
,
public
=
true
,
actions
=
lxml
.
param
,
arguments
=
"
3 strings
"
}
99
implement
{
name
=
"
xmlpath
"
,
public
=
true
,
actions
=
lxml
.
path
,
arguments
=
{
"
string
"
,
"
'/'
"
}
}
100
implement
{
name
=
"
xmlpopmatch
"
,
public
=
true
,
actions
=
lxml
.
popmatch
}
101
implement
{
name
=
"
xmlpos
"
,
public
=
true
,
actions
=
lxml
.
pos
,
arguments
=
"
string
"
}
102
implement
{
name
=
"
xmlpure
"
,
public
=
true
,
actions
=
lxml
.
pure
,
arguments
=
"
2 strings
"
}
103
implement
{
name
=
"
xmlpushmatch
"
,
public
=
true
,
actions
=
lxml
.
pushmatch
}
104
implement
{
name
=
"
xmlraw
"
,
public
=
true
,
actions
=
lxml
.
raw
,
arguments
=
"
2 strings
"
}
105
implement
{
name
=
"
xmlrawtex
"
,
actions
=
lxml
.
rawtex
,
arguments
=
"
2 strings
"
}
106
implement
{
name
=
"
xmlrefatt
"
,
public
=
true
,
actions
=
lxml
.
refatt
,
arguments
=
"
2 strings
"
}
107
implement
{
name
=
"
xmlregisterns
"
,
public
=
true
,
actions
=
xml
.
registerns
,
arguments
=
"
2 strings
"
}
108
implement
{
name
=
"
xmlremapname
"
,
public
=
true
,
actions
=
xml
.
remapname
,
arguments
=
{
"
lxmlid
"
,
"
string
"
,
"
string
"
,
"
string
"
}
}
109
implement
{
name
=
"
xmlremapnamespace
"
,
public
=
true
,
actions
=
xml
.
renamespace
,
arguments
=
{
"
lxmlid
"
,
"
string
"
,
"
string
"
}
}
110
implement
{
name
=
"
xmlsave
"
,
public
=
true
,
actions
=
lxml
.
save
,
arguments
=
"
2 strings
"
}
111
implement
{
name
=
"
xmlsetatt
"
,
public
=
true
,
actions
=
lxml
.
setatt
,
arguments
=
"
3 strings
"
}
112
implement
{
name
=
"
xmlsetattribute
"
,
public
=
true
,
actions
=
lxml
.
setattribute
,
arguments
=
"
4 strings
"
}
113
implement
{
name
=
"
xmlsetpar
"
,
public
=
true
,
actions
=
lxml
.
setpar
,
arguments
=
"
3 strings
"
}
114
implement
{
name
=
"
xmlsetparam
"
,
public
=
true
,
actions
=
lxml
.
setparam
,
arguments
=
"
4 strings
"
}
115
implement
{
name
=
"
xmlsetsetup
"
,
public
=
true
,
actions
=
lxml
.
setsetup
,
arguments
=
"
3 strings
"
}
116
implement
{
name
=
"
xmlsnippet
"
,
public
=
true
,
actions
=
lxml
.
snippet
,
arguments
=
"
2 strings
"
}
117
implement
{
name
=
"
xmlstrip
"
,
public
=
true
,
actions
=
lxml
.
strip
,
arguments
=
"
2 strings
"
}
118
implement
{
name
=
"
xmlstripanywhere
"
,
public
=
true
,
actions
=
lxml
.
strip
,
arguments
=
{
"
string
"
,
"
string
"
,
true
,
true
}
}
119
implement
{
name
=
"
xmlstripeverything
"
,
public
=
true
,
actions
=
lxml
.
strip
,
arguments
=
{
"
string
"
,
"
string
"
,
true
,
true
,
true
}
}
120
implement
{
name
=
"
xmlstripnolines
"
,
public
=
true
,
actions
=
lxml
.
strip
,
arguments
=
{
"
string
"
,
"
string
"
,
true
}
}
121
implement
{
name
=
"
xmlstripped
"
,
public
=
true
,
actions
=
lxml
.
stripped
,
arguments
=
"
2 strings
"
}
122
implement
{
name
=
"
xmlstrippednolines
"
,
public
=
true
,
actions
=
lxml
.
stripped
,
arguments
=
{
"
string
"
,
"
string
"
,
true
}
}
123
implement
{
name
=
"
xmltag
"
,
public
=
true
,
actions
=
lxml
.
tag
,
arguments
=
"
string
"
}
124
implement
{
name
=
"
xmltext
"
,
public
=
true
,
actions
=
lxml
.
text
,
arguments
=
"
2 strings
"
}
125
implement
{
name
=
"
xmltobuffer
"
,
public
=
true
,
actions
=
lxml
.
tobuffer
,
arguments
=
"
3 strings
"
}
126
implement
{
name
=
"
xmltobuffertextonly
"
,
public
=
true
,
actions
=
lxml
.
tobuffer
,
arguments
=
{
"
string
"
,
"
string
"
,
"
string
"
,
false
}
}
127
implement
{
name
=
"
xmltobufferverbose
"
,
public
=
true
,
actions
=
lxml
.
tobuffer
,
arguments
=
{
"
string
"
,
"
string
"
,
"
string
"
,
true
,
true
}
}
128
implement
{
name
=
"
xmltofile
"
,
public
=
true
,
actions
=
lxml
.
tofile
,
arguments
=
"
3 strings
"
}
129
implement
{
name
=
"
xmltoparameters
"
,
public
=
true
,
actions
=
lxml
.
toparameters
,
arguments
=
"
string
"
}
130
implement
{
name
=
"
xmlverbatim
"
,
public
=
true
,
actions
=
lxml
.
verbatim
,
arguments
=
"
string
"
}
131 132
implement
{
name
=
"
xmlstartraw
"
,
actions
=
lxml
.
startraw
}
133
implement
{
name
=
"
xmlstopraw
"
,
actions
=
lxml
.
stopraw
}
134 135
implement
{
name
=
"
xmlprependsetup
"
,
actions
=
lxml
.
installsetup
,
arguments
=
{
1
,
"
string
"
,
"
string
"
}
}
-- 2:*
136
implement
{
name
=
"
xmlappendsetup
"
,
actions
=
lxml
.
installsetup
,
arguments
=
{
2
,
"
string
"
,
"
string
"
}
}
-- 2:*
137
implement
{
name
=
"
xmlbeforesetup
"
,
actions
=
lxml
.
installsetup
,
arguments
=
{
3
,
"
string
"
,
"
string
"
,
"
string
"
}
}
-- 2:*
138
implement
{
name
=
"
xmlaftersetup
"
,
actions
=
lxml
.
installsetup
,
arguments
=
{
4
,
"
string
"
,
"
string
"
,
"
string
"
}
}
-- 2:*
139
implement
{
name
=
"
xmlremovesetup
"
,
actions
=
lxml
.
removesetup
,
arguments
=
"
2 strings
"
}
-- 1:*
140
implement
{
name
=
"
xmlflushsetups
"
,
actions
=
lxml
.
flushsetups
,
arguments
=
"
3 strings
"
}
-- 2:*
141
implement
{
name
=
"
xmlresetsetups
"
,
actions
=
lxml
.
resetsetups
,
arguments
=
"
string
"
}
142 143
implement
{
name
=
"
xmlgetindex
"
,
actions
=
lxml
.
getindex
,
arguments
=
"
2 strings
"
}
144
implement
{
name
=
"
xmlwithindex
"
,
actions
=
lxml
.
withindex
,
arguments
=
"
3 strings
"
}
145 146
implement
{
name
=
"
xmlsetentity
"
,
actions
=
xml
.
registerentity
,
arguments
=
"
2 strings
"
}
147
implement
{
name
=
"
xmltexentity
"
,
actions
=
lxml
.
registerentity
,
arguments
=
"
2 strings
"
}
148 149
implement
{
name
=
"
xmlsetcommandtotext
"
,
actions
=
lxml
.
setcommandtotext
,
arguments
=
"
string
"
}
150
implement
{
name
=
"
xmlsetcommandtonone
"
,
actions
=
lxml
.
setcommandtonone
,
arguments
=
"
string
"
}
151 152
implement
{
name
=
"
xmlstarttiming
"
,
actions
=
function
(
)
statistics
.
starttiming
(
lxml
)
end
}
153
implement
{
name
=
"
xmlstoptiming
"
,
actions
=
function
(
)
statistics
.
stoptiming
(
lxml
)
end
}
154 155
implement
{
name
=
"
xmlloadentities
"
,
actions
=
characters
.
registerentities
,
onceonly
=
true
}
156 157
if
CONTEXTLMTXMODE
>
0
then
158 159
local
boolean_code
=
tokens
.
values
.
boolean
160 161
local
getid
=
lxml
.
getid
162
local
found
=
xml
.
found
163
local
empty
=
xml
.
empty
164
local
checkedempty
=
xml
.
checkedempty
165
local
ifatt
=
lxml
.
ifatt
166
local
ifattempty
=
lxml
.
ifattempty
167 168
implement
{
169
name
=
"
ifxml
"
,
170
public
=
true
,
171
usage
=
"
condition
"
,
172
arguments
=
"
2 arguments
"
,
173
actions
=
function
(
id
,
pattern
)
174
return
boolean_code
,
found
(
getid
(
id
)
,
pattern
)
and
true
175
end
176
}
177 178
implement
{
179
name
=
"
ifxmltext
"
,
180
public
=
true
,
181
usage
=
"
condition
"
,
182
arguments
=
"
2 arguments
"
,
183
actions
=
function
(
id
,
pattern
)
184
return
boolean_code
,
not
empty
(
getid
(
id
)
,
pattern
)
and
true
185
end
186
}
187 188
implement
{
189
name
=
"
ifxmlatt
"
,
190
public
=
true
,
191
usage
=
"
condition
"
,
192
arguments
=
"
3 arguments
"
,
193
actions
=
function
(
id
,
name
,
value
)
194
return
boolean_code
,
ifatt
(
getid
(
id
)
,
name
,
value
)
195
end
196
}
197 198
implement
{
199
name
=
"
ifxmlattempty
"
,
200
public
=
true
,
201
usage
=
"
condition
"
,
202
arguments
=
"
2 arguments
"
,
203
actions
=
function
(
id
,
name
)
204
return
boolean_code
,
ifattempty
(
getid
(
id
)
,
name
)
205
end
206
}
207 208
implement
{
209
name
=
"
ifxmlempty
"
,
210
public
=
true
,
211
usage
=
"
condition
"
,
212
arguments
=
"
2 arguments
"
,
213
actions
=
function
(
id
,
pattern
)
214
return
boolean_code
,
not
checkedempty
(
getid
(
id
)
,
pattern
)
and
true
215
end
216
}
217 218
implement
{
219
name
=
"
ifxmlselfempty
"
,
220
public
=
true
,
221
usage
=
"
condition
"
,
222
arguments
=
"
argument
"
,
223
actions
=
function
(
id
)
224
return
boolean_code
,
not
checkedempty
(
getid
(
id
)
)
and
true
225
end
226
}
227 228
end
229 230
-- kind of special (3rd argument is a function)
231 232
commands
.
xmlsetfunction
=
lxml
.
setaction
233