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