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 = " xmlbadinclusions " , public = true , actions = lxml . badinclusions , arguments = " string " }
49implement { name = " xmlchainatt " , public = true , actions = lxml . chainattribute , arguments = { " string " , " '/' " , " string " } }
50implement { name = " xmlchainattdef " , public = true , actions = lxml . chainattribute , arguments = { " string " , " '/' " , " string " , " string " } }
51implement { name = " xmlchecknamespace " , public = true , actions = xml . checknamespace , arguments = { " lxmlid " , " string " , " string " } }
52implement { name = " xmlcommand " , public = true , actions = lxml . command , arguments = " 3 strings " }
53implement { name = " xmlconcat " , actions = lxml . concat , arguments = " 3 strings " }
54implement { name = " xmlconcatrange " , actions = lxml . concatrange , arguments = " 5 strings " }
55
56
57implement { name = " xmlcontext " , public = true , actions = lxml . context , arguments = " 2 strings " }
58implement { name = " xmlcount " , public = true , actions = lxml . count , arguments = " 2 strings " }
59implement { name = " xmldepth " , public = true , actions = lxml . depth , arguments = " string " }
60implement { name = " xmldelete " , public = true , actions = lxml . delete , arguments = " 2 strings " }
61implement { name = " xmldirect " , public = true , actions = lxml . direct , arguments = " string " }
62implement { name = " xmldirectives " , public = true , actions = lxml . directives . setup , arguments = " string " }
63implement { name = " xmldirectivesafter " , public = true , actions = lxml . directives . after , arguments = " string " }
64implement { name = " xmldirectivesbefore " , public = true , actions = lxml . directives . before , arguments = " string " }
65implement { name = " xmldisplayverbatim " , public = true , actions = lxml . displayverbatim , arguments = " string " }
66implement { name = " xmlelement " , public = true , actions = lxml . element , arguments = " 2 strings " }
67implement { name = " xmlfilter " , public = true , actions = lxml . filter , arguments = " 2 strings " }
68implement { name = " xmlfilterlist " , public = true , actions = lxml . filterlist , arguments = " 2 strings " }
69implement { name = " xmlfirst " , public = true , actions = lxml . first , arguments = " 2 strings " }
70implement { name = " xmlflush " , public = true , actions = lxml . flush , arguments = " string " }
71implement { name = " xmlflushcontext " , public = true , actions = lxml . context , arguments = " string " }
72implement { name = " xmlflushlinewise " , public = true , actions = lxml . flushlinewise , arguments = " string " }
73implement { name = " xmlflushpure " , public = true , actions = lxml . pure , arguments = " string " }
74implement { name = " xmlflushspacewise " , public = true , actions = lxml . flushspacewise , arguments = " string " }
75implement { name = " xmlflushtext " , public = true , actions = lxml . text , arguments = " string " }
76implement { name = " xmlfunction " , public = true , actions = lxml . applyfunction , arguments = " 2 strings " }
77implement { name = " xmlinclude " , public = true , actions = lxml . include , arguments = { " string " , " string " , " string " , true } }
78implement { name = " xmlincludeoptions " , public = true , actions = lxml . include , arguments = " 4 strings " }
79implement { name = " xmlinclusion " , public = true , actions = lxml . inclusion , arguments = " string " }
80implement { name = " xmlinclusionbase " , public = true , actions = lxml . inclusion , arguments = { " string " , false , true } }
81implement { name = " xmlinclusions " , public = true , actions = lxml . inclusions , arguments = " string " }
82implement { name = " xmlindex " , public = true , actions = lxml . index , arguments = " 3 strings " }
83implement { name = " xmlinlineverbatim " , public = true , actions = lxml . inlineverbatim , arguments = " string " }
84implement { name = " xmllast " , public = true , actions = lxml . last , arguments = " 2 strings " }
85implement { name = " xmllastatt " , public = true , actions = lxml . lastatt }
86implement { name = " xmllastmatch " , public = true , actions = lxml . lastmatch }
87implement { name = " xmllastpar " , public = true , actions = lxml . lastpar }
88implement { name = " xmlloadfile " , actions = lxml . load , arguments = " 3 strings " }
89implement { name = " xmlloadbuffer " , actions = lxml . loadbuffer , arguments = " 3 strings " }
90implement { name = " xmlloaddata " , actions = lxml . loaddata , arguments = " 3 strings " }
91implement { name = " xmlloaddirectives " , public = true , actions = lxml . directives . load , arguments = " string " }
92implement { name = " xmlmain " , public = true , actions = lxml . main , arguments = " string " }
93implement { name = " xmlmatch " , public = true , actions = lxml . match , arguments = " string " }
94implement { name = " xmlname " , public = true , actions = lxml . name , arguments = " string " }
95implement { name = " xmlnamespace " , public = true , actions = lxml . namespace , arguments = " string " }
96implement { name = " xmlnonspace " , public = true , actions = lxml . nonspace , arguments = " 2 strings " }
97implement { name = " xmlpar " , public = true , actions = lxml . par , arguments = " 2 strings " }
98implement { name = " xmlparam " , public = true , actions = lxml . param , arguments = " 3 strings " }
99implement { name = " xmlpath " , public = true , actions = lxml . path , arguments = { " string " , " '/' " } }
100implement { name = " xmlpopmatch " , public = true , actions = lxml . popmatch }
101implement { name = " xmlpos " , public = true , actions = lxml . pos , arguments = " string " }
102implement { name = " xmlpure " , public = true , actions = lxml . pure , arguments = " 2 strings " }
103implement { name = " xmlpushmatch " , public = true , actions = lxml . pushmatch }
104implement { name = " xmlraw " , public = true , actions = lxml . raw , arguments = " 2 strings " }
105implement { name = " xmlrawtex " , actions = lxml . rawtex , arguments = " 2 strings " }
106implement { name = " xmlrefatt " , public = true , actions = lxml . refatt , arguments = " 2 strings " }
107implement { name = " xmlregisterns " , public = true , actions = xml . registerns , arguments = " 2 strings " }
108implement { name = " xmlremapname " , public = true , actions = xml . remapname , arguments = { " lxmlid " , " string " , " string " , " string " } }
109implement { name = " xmlremapnamespace " , public = true , actions = xml . renamespace , arguments = { " lxmlid " , " string " , " string " } }
110implement { name = " xmlsave " , public = true , actions = lxml . save , arguments = " 2 strings " }
111implement { name = " xmlsetatt " , public = true , actions = lxml . setatt , arguments = " 3 strings " }
112implement { name = " xmlsetattribute " , public = true , actions = lxml . setattribute , arguments = " 4 strings " }
113implement { name = " xmlsetpar " , public = true , actions = lxml . setpar , arguments = " 3 strings " }
114implement { name = " xmlsetparam " , public = true , actions = lxml . setparam , arguments = " 4 strings " }
115implement { name = " xmlsetsetup " , public = true , actions = lxml . setsetup , arguments = " 3 strings " }
116implement { name = " xmlsnippet " , public = true , actions = lxml . snippet , arguments = " 2 strings " }
117implement { name = " xmlstrip " , public = true , actions = lxml . strip , arguments = " 2 strings " }
118implement { name = " xmlstripanywhere " , public = true , actions = lxml . strip , arguments = { " string " , " string " , true , true } }
119implement { name = " xmlstripeverything " , public = true , actions = lxml . strip , arguments = { " string " , " string " , true , true , true } }
120implement { name = " xmlstripnolines " , public = true , actions = lxml . strip , arguments = { " string " , " string " , true } }
121implement { name = " xmlstripped " , public = true , actions = lxml . stripped , arguments = " 2 strings " }
122implement { name = " xmlstrippednolines " , public = true , actions = lxml . stripped , arguments = { " string " , " string " , true } }
123implement { name = " xmltag " , public = true , actions = lxml . tag , arguments = " string " }
124implement { name = " xmltext " , public = true , actions = lxml . text , arguments = " 2 strings " }
125implement { name = " xmltobuffer " , public = true , actions = lxml . tobuffer , arguments = " 3 strings " }
126implement { name = " xmltobuffertextonly " , public = true , actions = lxml . tobuffer , arguments = { " string " , " string " , " string " , false } }
127implement { name = " xmltobufferverbose " , public = true , actions = lxml . tobuffer , arguments = { " string " , " string " , " string " , true , true } }
128implement { name = " xmltofile " , public = true , actions = lxml . tofile , arguments = " 3 strings " }
129implement { name = " xmltoparameters " , public = true , actions = lxml . toparameters , arguments = " string " }
130implement { name = " xmlverbatim " , public = true , actions = lxml . verbatim , arguments = " string " }
131
132implement { name = " xmlstartraw " , actions = lxml . startraw }
133implement { name = " xmlstopraw " , actions = lxml . stopraw }
134
135implement { name = " xmlprependsetup " , actions = lxml . installsetup , arguments = { 1 , " string " , " string " } }
136implement { name = " xmlappendsetup " , actions = lxml . installsetup , arguments = { 2 , " string " , " string " } }
137implement { name = " xmlbeforesetup " , actions = lxml . installsetup , arguments = { 3 , " string " , " string " , " string " } }
138implement { name = " xmlaftersetup " , actions = lxml . installsetup , arguments = { 4 , " string " , " string " , " string " } }
139implement { name = " xmlremovesetup " , actions = lxml . removesetup , arguments = " 2 strings " }
140implement { name = " xmlflushsetups " , actions = lxml . flushsetups , arguments = " 3 strings " }
141implement { name = " xmlresetsetups " , actions = lxml . resetsetups , arguments = " string " }
142
143implement { name = " xmlgetindex " , actions = lxml . getindex , arguments = " 2 strings " }
144implement { name = " xmlwithindex " , actions = lxml . withindex , arguments = " 3 strings " }
145
146implement { name = " xmlsetentity " , actions = xml . registerentity , arguments = " 2 strings " }
147implement { name = " xmltexentity " , actions = lxml . registerentity , arguments = " 2 strings " }
148
149implement { name = " xmlsetcommandtotext " , actions = lxml . setcommandtotext , arguments = " string " }
150implement { name = " xmlsetcommandtonone " , actions = lxml . setcommandtonone , arguments = " string " }
151
152implement { name = " xmlstarttiming " , actions = function ( ) statistics . starttiming ( lxml ) end }
153implement { name = " xmlstoptiming " , actions = function ( ) statistics . stoptiming ( lxml ) end }
154
155implement { name = " xmlloadentities " , actions = characters . registerentities , onceonly = true }
156
157if 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
228end
229
230
231
232commands . xmlsetfunction = lxml . setaction
233 |