1
|
|
/* Generated By:JavaCC: Do not edit this line. Parser.java */
|
2
|
|
package org.jbind.xml.parser;
|
3
|
|
|
4
|
|
import java.io.*;
|
5
|
|
import java.net.URL;
|
6
|
|
import java.util.*;
|
7
|
|
|
8
|
|
import org.jbind.message.IMessage;
|
9
|
|
import org.jbind.xml.Config;
|
10
|
|
import org.jbind.xml.base.ILocation;
|
11
|
|
import org.jbind.xml.base.INamespaces;
|
12
|
|
import org.jbind.xml.base.InputSourceLocation;
|
13
|
|
import org.jbind.xml.base.PrefixDeclaration;
|
14
|
|
import org.jbind.xml.core.bridge.IRegEx;
|
15
|
|
import org.jbind.xml.msg.XmlMessages;
|
16
|
|
|
17
|
|
import org.xml.sax.InputSource;
|
18
|
|
|
19
|
|
/**
|
20
|
|
* Non validating namespace aware XML parser that supports XIncludes. DOCTYPE
|
21
|
|
* declarations are ignored.
|
22
|
|
*/
|
23
|
|
public class Parser implements ParserConstants {
|
24
|
|
|
25
|
|
private static IRegEx p_encoding = null;
|
26
|
|
|
27
|
|
static {
|
28
|
3
|
try {
|
29
|
3
|
p_encoding = Config.instance.createRegEx("[A-Za-z]([A-Za-z0-9\\._\\-])*");
|
30
|
|
} catch (Exception e) {
|
31
|
0
|
e.printStackTrace();
|
32
|
|
}
|
33
|
|
}
|
34
|
|
|
35
|
0
|
private static String cdata(Token aToken) {
|
36
|
0
|
return null != aToken ? aToken.image.substring(1, aToken.image.length() - 1) : null;
|
37
|
|
}
|
38
|
|
|
39
|
|
// XInclude attributes
|
40
|
|
private final static QualifiedName XIA_HREF = new QualifiedName(INamespaces.NO, "href");
|
41
|
|
private final static QualifiedName XIA_PARSE = new QualifiedName(INamespaces.NO, "parse");
|
42
|
|
private final static QualifiedName XIA_ENCODING = new QualifiedName(INamespaces.NO, "encoding");
|
43
|
|
|
44
|
|
private ParserContext myParserContext = null;
|
45
|
|
|
46
|
|
private boolean mySkipContent = false;
|
47
|
|
private boolean myWasXInclude = false;
|
48
|
|
private URL myBaseUrl = null;
|
49
|
|
|
50
|
|
private InputSourceParser myInputSourceParser = null;
|
51
|
|
|
52
|
1
|
private InputSourceParser getInputSourceParser() {
|
53
|
1
|
if (null == myInputSourceParser) myInputSourceParser = new InputSourceParser();
|
54
|
1
|
return myInputSourceParser;
|
55
|
|
}
|
56
|
|
|
57
|
|
/**
|
58
|
|
* Resets the internal parse state. Must be called before each usage of the parser.
|
59
|
|
*
|
60
|
|
* @param aParserContext <i>(required)</i>.
|
61
|
|
*/
|
62
|
467
|
public void initParser(ParserContext aParserContext) throws Exception {
|
63
|
467
|
myParserContext = aParserContext;
|
64
|
467
|
mySkipContent = false;
|
65
|
467
|
myWasXInclude = false;
|
66
|
467
|
if (null != aParserContext.inputSource.getSystemId()) {
|
67
|
462
|
myBaseUrl = new URL(aParserContext.inputSource.getSystemId());
|
68
|
|
} else {
|
69
|
5
|
myBaseUrl = null;
|
70
|
|
}
|
71
|
|
}
|
72
|
|
|
73
|
1
|
private boolean startXInclude(Map anAttributes, ILocation aLocation) throws Exception {
|
74
|
1
|
boolean skipContent = true;
|
75
|
1
|
AttributeData hd = (AttributeData)anAttributes.get(XIA_HREF);
|
76
|
1
|
if (null == hd) {
|
77
|
0
|
error(XmlMessages.missingHRefInXInclude(aLocation));
|
78
|
|
} else {
|
79
|
1
|
int idx = hd.value.lastIndexOf('#');
|
80
|
1
|
String url = idx > 0 ? hd.value.substring(0, idx) : hd.value;
|
81
|
1
|
String fragmentId = idx > 0 ? hd.value.substring(idx+1) : null;
|
82
|
1
|
URL inputUrl = null;
|
83
|
1
|
if (null == myBaseUrl) {
|
84
|
0
|
inputUrl = new URL(url);
|
85
|
|
} else {
|
86
|
1
|
inputUrl = new URL(myBaseUrl, url);
|
87
|
|
}
|
88
|
1
|
InputSource inputSource = myParserContext.entityResolver.resolveEntity(inputUrl.toString(), null);
|
89
|
1
|
if (null == inputSource) {
|
90
|
1
|
try {
|
91
|
1
|
InputStream inputStream = inputUrl.openStream();
|
92
|
1
|
inputSource = new InputSource(inputStream);
|
93
|
1
|
inputSource.setSystemId(inputUrl.toString());
|
94
|
|
} catch (IOException e) {
|
95
|
|
// signal a fallback
|
96
|
0
|
myParserContext.contentHandler.startXInclude("fallback", inputUrl, fragmentId);
|
97
|
0
|
return false;
|
98
|
|
}
|
99
|
|
} else {
|
100
|
0
|
if (null != inputSource.getSystemId()) {
|
101
|
0
|
inputUrl = new URL(inputSource.getSystemId());
|
102
|
|
}
|
103
|
|
}
|
104
|
|
|
105
|
1
|
AttributeData pd = (AttributeData)anAttributes.get(XIA_PARSE);
|
106
|
|
|
107
|
1
|
if (pd == null || pd.value.equals("xml")) {
|
108
|
|
|
109
|
1
|
myParserContext.contentHandler.startXInclude("xml", inputUrl, fragmentId);
|
110
|
1
|
InputSourceParser parser = getInputSourceParser();
|
111
|
1
|
parser.xInclude(inputSource, myParserContext.contentHandler, myParserContext.errorHandler, myParserContext.entityResolver);
|
112
|
|
|
113
|
0
|
} else if (pd.value.equals("text")) {
|
114
|
|
|
115
|
0
|
Reader reader = inputSource.getCharacterStream();
|
116
|
|
|
117
|
0
|
if (null == reader) {
|
118
|
0
|
InputStream inputStream = inputSource.getByteStream();
|
119
|
0
|
if (null == inputStream) {
|
120
|
0
|
try {
|
121
|
0
|
inputStream = inputUrl.openStream();
|
122
|
|
} catch (IOException e) {
|
123
|
|
// signal a fallback
|
124
|
0
|
myParserContext.contentHandler.startXInclude("fallback", inputUrl, fragmentId);
|
125
|
0
|
return false;
|
126
|
|
}
|
127
|
|
}
|
128
|
|
|
129
|
0
|
String encoding = null;
|
130
|
|
|
131
|
|
// TODO if an xml document is included as text then the encoding
|
132
|
|
// must be determined corresponding the the XML specification.
|
133
|
|
|
134
|
0
|
if (encoding == null) {
|
135
|
0
|
AttributeData ed = (AttributeData)anAttributes.get(XIA_ENCODING);
|
136
|
0
|
if (ed != null) encoding = ed.value;
|
137
|
|
}
|
138
|
|
|
139
|
0
|
if (encoding == null) encoding = "UTF-8";
|
140
|
|
|
141
|
0
|
reader = new InputStreamReader(inputStream, encoding);
|
142
|
|
}
|
143
|
|
|
144
|
0
|
myParserContext.contentHandler.startXInclude("text", inputUrl, fragmentId);
|
145
|
|
|
146
|
0
|
char[] buffer = new char[1024];
|
147
|
0
|
int length;
|
148
|
0
|
while ((length = reader.read(buffer)) >= 0) {
|
149
|
0
|
String s = new String(buffer, 0, length);
|
150
|
0
|
myParserContext.text(s, aLocation.getLineNumber(), aLocation.getColumnNumber());
|
151
|
|
}
|
152
|
|
|
153
|
|
} else {
|
154
|
0
|
error(XmlMessages.invalidParseMethod(pd.value, aLocation));
|
155
|
|
}
|
156
|
|
}
|
157
|
1
|
return skipContent;
|
158
|
|
}
|
159
|
|
|
160
|
1
|
private void endXInclude() {
|
161
|
1
|
myParserContext.contentHandler.endXInclude();
|
162
|
|
}
|
163
|
|
|
164
|
1
|
private ILocation getLocation(Token aToken) {
|
165
|
1
|
return new InputSourceLocation(myParserContext.inputSource, aToken.beginLine, aToken.beginColumn);
|
166
|
|
}
|
167
|
|
|
168
|
0
|
private ILocation getLocation(int aLine, int aColumn) {
|
169
|
0
|
return new InputSourceLocation(myParserContext.inputSource, aLine, aColumn);
|
170
|
|
}
|
171
|
|
|
172
|
|
|
173
|
0
|
private void fatalError(IMessage aMessage) throws ParsingAbortedException {
|
174
|
0
|
myParserContext.errorHandler.fatalError(aMessage);
|
175
|
0
|
throw new ParsingAbortedException();
|
176
|
|
}
|
177
|
|
|
178
|
0
|
private void error(IMessage aMessage) throws ParsingAbortedException {
|
179
|
0
|
if (myParserContext.errorHandler.error(aMessage)) throw new ParsingAbortedException();
|
180
|
|
}
|
181
|
|
|
182
|
0
|
private void warning(IMessage aMessage) throws ParsingAbortedException {
|
183
|
0
|
if (myParserContext.errorHandler.warning(aMessage)) throw new ParsingAbortedException();
|
184
|
|
}
|
185
|
|
|
186
|
10255
|
final public AttributeData attribute() throws ParseException, ParsingAbortedException {
|
187
|
10255
|
QualifiedName qn;
|
188
|
10255
|
StringBuffer sb = new StringBuffer();
|
189
|
10255
|
String s;
|
190
|
10255
|
Token t;
|
191
|
10255
|
qn = qName();
|
192
|
10255
|
jj_consume_token(EQ);
|
193
|
10255
|
switch (jj_nt.kind) {
|
194
|
|
case QUOT:
|
195
|
10255
|
jj_consume_token(QUOT);
|
196
|
10255
|
label_1:
|
197
|
|
while (true) {
|
198
|
20504
|
switch (jj_nt.kind) {
|
199
|
|
case ATT_CHARS_Q:
|
200
|
|
case ENTITY_REF:
|
201
|
|
case CHAR_REF_D:
|
202
|
|
case CHAR_REF_H:
|
203
|
|
;
|
204
|
10249
|
break;
|
205
|
|
default:
|
206
|
10255
|
jj_la1[0] = jj_gen;
|
207
|
10255
|
break label_1;
|
208
|
|
}
|
209
|
10249
|
switch (jj_nt.kind) {
|
210
|
|
case ATT_CHARS_Q:
|
211
|
10245
|
t = jj_consume_token(ATT_CHARS_Q);
|
212
|
10245
|
sb.append(t.image);
|
213
|
10245
|
break;
|
214
|
|
case ENTITY_REF:
|
215
|
|
case CHAR_REF_D:
|
216
|
|
case CHAR_REF_H:
|
217
|
4
|
s = reference();
|
218
|
4
|
sb.append(s);
|
219
|
4
|
break;
|
220
|
|
default:
|
221
|
0
|
jj_la1[1] = jj_gen;
|
222
|
0
|
jj_consume_token(-1);
|
223
|
0
|
throw new ParseException();
|
224
|
|
}
|
225
|
|
}
|
226
|
10255
|
jj_consume_token(ATT_QUOT);
|
227
|
10255
|
break;
|
228
|
|
case APOS:
|
229
|
0
|
jj_consume_token(APOS);
|
230
|
0
|
label_2:
|
231
|
|
while (true) {
|
232
|
0
|
switch (jj_nt.kind) {
|
233
|
|
case ATT_CHARS_A:
|
234
|
|
case ENTITY_REF:
|
235
|
|
case CHAR_REF_D:
|
236
|
|
case CHAR_REF_H:
|
237
|
|
;
|
238
|
0
|
break;
|
239
|
|
default:
|
240
|
0
|
jj_la1[2] = jj_gen;
|
241
|
0
|
break label_2;
|
242
|
|
}
|
243
|
0
|
switch (jj_nt.kind) {
|
244
|
|
case ATT_CHARS_A:
|
245
|
0
|
t = jj_consume_token(ATT_CHARS_A);
|
246
|
0
|
sb.append(t.image);
|
247
|
0
|
break;
|
248
|
|
case ENTITY_REF:
|
249
|
|
case CHAR_REF_D:
|
250
|
|
case CHAR_REF_H:
|
251
|
0
|
s = reference();
|
252
|
0
|
sb.append(s);
|
253
|
0
|
break;
|
254
|
|
default:
|
255
|
0
|
jj_la1[3] = jj_gen;
|
256
|
0
|
jj_consume_token(-1);
|
257
|
0
|
throw new ParseException();
|
258
|
|
}
|
259
|
|
}
|
260
|
0
|
jj_consume_token(ATT_APOS);
|
261
|
0
|
break;
|
262
|
|
default:
|
263
|
0
|
jj_la1[4] = jj_gen;
|
264
|
0
|
jj_consume_token(-1);
|
265
|
0
|
throw new ParseException();
|
266
|
|
}
|
267
|
10255
|
{if (true) return new AttributeData(qn, sb.toString());}
|
268
|
0
|
throw new Error("Missing return statement in function");
|
269
|
|
}
|
270
|
|
|
271
|
0
|
final public String charRefD() throws ParseException {
|
272
|
0
|
Token t;
|
273
|
0
|
t = jj_consume_token(CHAR_REF_D);
|
274
|
0
|
String s = t.image.substring(2, t.image.length()-1);
|
275
|
0
|
short sh = Short.parseShort(s);
|
276
|
0
|
{if (true) return Character.toString((char)sh);}
|
277
|
0
|
throw new Error("Missing return statement in function");
|
278
|
|
}
|
279
|
|
|
280
|
0
|
final public String charRefH() throws ParseException {
|
281
|
0
|
Token t;
|
282
|
0
|
t = jj_consume_token(CHAR_REF_H);
|
283
|
0
|
String s = t.image.substring(3, t.image.length()-1);
|
284
|
0
|
short sh = Short.parseShort(s, 16);
|
285
|
0
|
{if (true) return Character.toString((char)sh);}
|
286
|
0
|
throw new Error("Missing return statement in function");
|
287
|
|
}
|
288
|
|
|
289
|
4574
|
final public boolean content() throws ParseException, Exception {
|
290
|
4574
|
String s;
|
291
|
4574
|
Token t;
|
292
|
4574
|
boolean containsFallback = false;
|
293
|
4574
|
boolean isFallback;
|
294
|
4574
|
switch (jj_nt.kind) {
|
295
|
|
case CHAR_DATA:
|
296
|
4437
|
t = jj_consume_token(CHAR_DATA);
|
297
|
4437
|
if (!mySkipContent) myParserContext.text(t.image, t.beginLine, t.beginColumn);
|
298
|
4437
|
break;
|
299
|
|
default:
|
300
|
137
|
jj_la1[5] = jj_gen;
|
301
|
|
;
|
302
|
|
}
|
303
|
4574
|
label_3:
|
304
|
|
while (true) {
|
305
|
12951
|
switch (jj_nt.kind) {
|
306
|
|
case LT:
|
307
|
|
case COMMENT:
|
308
|
|
case PI:
|
309
|
|
case CDATA_START:
|
310
|
|
case ENTITY_REF:
|
311
|
|
case CHAR_REF_D:
|
312
|
|
case CHAR_REF_H:
|
313
|
|
;
|
314
|
8377
|
break;
|
315
|
|
default:
|
316
|
4574
|
jj_la1[6] = jj_gen;
|
317
|
4574
|
break label_3;
|
318
|
|
}
|
319
|
8377
|
switch (jj_nt.kind) {
|
320
|
|
case LT:
|
321
|
8209
|
isFallback = element(containsFallback);
|
322
|
8209
|
containsFallback |= isFallback;
|
323
|
8209
|
break;
|
324
|
|
case ENTITY_REF:
|
325
|
|
case CHAR_REF_D:
|
326
|
|
case CHAR_REF_H:
|
327
|
46
|
s = reference();
|
328
|
46
|
if (!mySkipContent) myParserContext.text(s, token.beginLine, token.beginColumn);
|
329
|
46
|
break;
|
330
|
|
case CDATA_START:
|
331
|
8
|
jj_consume_token(CDATA_START);
|
332
|
8
|
t = jj_consume_token(CDATA);
|
333
|
8
|
jj_consume_token(CDATA_END);
|
334
|
8
|
if (!mySkipContent) myParserContext.text(t.image, t.beginLine, t.beginColumn);
|
335
|
8
|
break;
|
336
|
|
case COMMENT:
|
337
|
114
|
jj_consume_token(COMMENT);
|
338
|
114
|
break;
|
339
|
|
case PI:
|
340
|
0
|
jj_consume_token(PI);
|
341
|
0
|
break;
|
342
|
|
default:
|
343
|
0
|
jj_la1[7] = jj_gen;
|
344
|
0
|
jj_consume_token(-1);
|
345
|
0
|
throw new ParseException();
|
346
|
|
}
|
347
|
8377
|
switch (jj_nt.kind) {
|
348
|
|
case CHAR_DATA:
|
349
|
8128
|
t = jj_consume_token(CHAR_DATA);
|
350
|
8128
|
if (!mySkipContent) myParserContext.text(t.image, t.beginLine, t.beginColumn);
|
351
|
8128
|
break;
|
352
|
|
default:
|
353
|
249
|
jj_la1[8] = jj_gen;
|
354
|
|
;
|
355
|
|
}
|
356
|
|
}
|
357
|
4574
|
{if (true) return containsFallback;}
|
358
|
0
|
throw new Error("Missing return statement in function");
|
359
|
|
}
|
360
|
|
|
361
|
7
|
final public void docTypeDecl() throws ParseException, Exception {
|
362
|
7
|
jj_consume_token(DOC_TYPE_START);
|
363
|
7
|
switch (jj_nt.kind) {
|
364
|
|
case MARKUP_DECL_START:
|
365
|
3
|
jj_consume_token(MARKUP_DECL_START);
|
366
|
3
|
label_4:
|
367
|
|
while (true) {
|
368
|
144
|
switch (jj_nt.kind) {
|
369
|
|
case COMMENT:
|
370
|
|
case PI:
|
371
|
|
case ATTLIST_DECL:
|
372
|
|
case ELEMENT_DECL:
|
373
|
|
case ENTITY_DECL:
|
374
|
|
;
|
375
|
141
|
break;
|
376
|
|
default:
|
377
|
3
|
jj_la1[9] = jj_gen;
|
378
|
3
|
break label_4;
|
379
|
|
}
|
380
|
141
|
switch (jj_nt.kind) {
|
381
|
|
case ATTLIST_DECL:
|
382
|
123
|
jj_consume_token(ATTLIST_DECL);
|
383
|
123
|
break;
|
384
|
|
case ELEMENT_DECL:
|
385
|
6
|
jj_consume_token(ELEMENT_DECL);
|
386
|
6
|
break;
|
387
|
|
case ENTITY_DECL:
|
388
|
3
|
jj_consume_token(ENTITY_DECL);
|
389
|
3
|
break;
|
390
|
|
case COMMENT:
|
391
|
9
|
jj_consume_token(COMMENT);
|
392
|
9
|
break;
|
393
|
|
case PI:
|
394
|
0
|
jj_consume_token(PI);
|
395
|
0
|
break;
|
396
|
|
default:
|
397
|
0
|
jj_la1[10] = jj_gen;
|
398
|
0
|
jj_consume_token(-1);
|
399
|
0
|
throw new ParseException();
|
400
|
|
}
|
401
|
|
}
|
402
|
3
|
jj_consume_token(MARKUP_DECL_END);
|
403
|
3
|
break;
|
404
|
|
default:
|
405
|
4
|
jj_la1[11] = jj_gen;
|
406
|
|
;
|
407
|
|
}
|
408
|
7
|
jj_consume_token(DOC_TYPE_END);
|
409
|
|
}
|
410
|
|
|
411
|
467
|
final public void document() throws ParseException, Exception {
|
412
|
467
|
myParserContext.startDocument();
|
413
|
467
|
prolog();
|
414
|
467
|
element(false);
|
415
|
467
|
label_5:
|
416
|
|
while (true) {
|
417
|
467
|
switch (jj_nt.kind) {
|
418
|
|
case S:
|
419
|
|
case COMMENT:
|
420
|
|
case PI:
|
421
|
|
;
|
422
|
0
|
break;
|
423
|
|
default:
|
424
|
467
|
jj_la1[12] = jj_gen;
|
425
|
467
|
break label_5;
|
426
|
|
}
|
427
|
0
|
misc();
|
428
|
|
}
|
429
|
467
|
myParserContext.endDocument();
|
430
|
|
}
|
431
|
|
|
432
|
8676
|
final public boolean element(boolean aContainsFallback) throws ParseException, Exception {
|
433
|
8676
|
QualifiedName qnStart;
|
434
|
8676
|
QualifiedName qnEnd;
|
435
|
8676
|
List attributeList = null;
|
436
|
8676
|
Map attributes = null;
|
437
|
8676
|
Collection prefixDeclarations = null;
|
438
|
8676
|
AttributeData a = null;
|
439
|
8676
|
Token startToken;
|
440
|
8676
|
Token endToken = null;
|
441
|
|
|
442
|
|
// save environment
|
443
|
|
|
444
|
8676
|
boolean saveSkipContent = mySkipContent;
|
445
|
8676
|
boolean saveWasXInclude = myWasXInclude;
|
446
|
8676
|
URL saveBaseUrl = myBaseUrl;
|
447
|
|
|
448
|
8676
|
boolean contentContainsFallback = false;
|
449
|
8676
|
startToken = jj_consume_token(LT);
|
450
|
8676
|
qnStart = qName();
|
451
|
8676
|
label_6:
|
452
|
|
while (true) {
|
453
|
18931
|
switch (jj_nt.kind) {
|
454
|
|
case NCName:
|
455
|
|
;
|
456
|
10255
|
break;
|
457
|
|
default:
|
458
|
8676
|
jj_la1[13] = jj_gen;
|
459
|
8676
|
break label_6;
|
460
|
|
}
|
461
|
10255
|
a = attribute();
|
462
|
10255
|
if ("xmlns".equals(a.qn.getPrefix()) || "".equals(a.qn.getPrefix()) && "xmlns".equals(a.qn.getLocalPart())) {
|
463
|
483
|
if (null == prefixDeclarations) prefixDeclarations = new ArrayList();
|
464
|
908
|
if ("xmlns".equals(a.qn.getPrefix())) {
|
465
|
646
|
prefixDeclarations.add(new PrefixDeclaration(a.qn.getLocalPart(), a.value));
|
466
|
|
} else {
|
467
|
262
|
prefixDeclarations.add(new PrefixDeclaration("", a.value));
|
468
|
|
}
|
469
|
|
} else {
|
470
|
5857
|
if (null == attributeList) attributeList = new ArrayList();
|
471
|
9347
|
attributeList.add(a);
|
472
|
|
}
|
473
|
|
}
|
474
|
8676
|
myParserContext.namespaceContext.pushContext(prefixDeclarations);
|
475
|
8676
|
Map m = myParserContext.namespaceContext.getCurrentMapping();
|
476
|
8676
|
qnStart.setNamespace((String)m.get(qnStart.getPrefix()));
|
477
|
8676
|
if (null == qnStart.getNamespace()) {
|
478
|
0
|
error(XmlMessages.unknownNamespacePrefixInQName(qnStart, getLocation(qnStart.line, qnStart.column)));
|
479
|
|
}
|
480
|
8676
|
if (null != attributeList) {
|
481
|
5857
|
attributes = new HashMap();
|
482
|
5857
|
for (Iterator i = attributeList.iterator(); i.hasNext(); ) {
|
483
|
9347
|
a = (AttributeData)i.next();
|
484
|
9347
|
if ("".equals(a.qn.getPrefix())) {
|
485
|
8799
|
a.qn.setNamespace(""); // The attribute has no namespace
|
486
|
|
} else {
|
487
|
548
|
a.qn.setNamespace((String)m.get(a.qn.getPrefix()));
|
488
|
|
}
|
489
|
9347
|
if (null != a.qn.getNamespace()) {
|
490
|
9347
|
if (null != attributes.put(a.qn, a)) {
|
491
|
0
|
error(XmlMessages.duplicateAttribute(a.qn, getLocation(a.qn.line, a.qn.column)));
|
492
|
|
}
|
493
|
|
} else {
|
494
|
0
|
if (null == a.qn.getNamespace()) {
|
495
|
0
|
error(XmlMessages.unknownNamespacePrefixInQName(a.qn, getLocation(a.qn.line, a.qn.column)));
|
496
|
|
}
|
497
|
|
}
|
498
|
|
}
|
499
|
|
}
|
500
|
8676
|
boolean isXInclude = false;
|
501
|
8676
|
boolean isFallback = false;
|
502
|
8676
|
if (INamespaces.XINCLUDE.equals(qnStart.getNamespace())) {
|
503
|
1
|
if ("include".equals(qnStart.getLocalPart())) {
|
504
|
1
|
isXInclude = true;
|
505
|
1
|
if (myWasXInclude) {
|
506
|
0
|
error(XmlMessages.xIncludeNotAllowedInsideXInclude(getLocation(startToken)));
|
507
|
|
}
|
508
|
1
|
if (!mySkipContent) {
|
509
|
1
|
mySkipContent = startXInclude(attributes, getLocation(startToken));
|
510
|
|
}
|
511
|
0
|
} else if ("fallback".equals(qnStart.getLocalPart())) {
|
512
|
0
|
isFallback = true;
|
513
|
0
|
if (!myWasXInclude) {
|
514
|
0
|
error(XmlMessages.fallbackOnlyAllowedInsideXInclude(getLocation(startToken)));
|
515
|
|
}
|
516
|
0
|
if (aContainsFallback) {
|
517
|
0
|
error(XmlMessages.moreThanOneFallbackInXInclude(getLocation(startToken)));
|
518
|
|
}
|
519
|
|
} else {
|
520
|
0
|
error(XmlMessages.unknownXIncludeElement(qnStart, getLocation(startToken)));
|
521
|
|
}
|
522
|
|
} else {
|
523
|
8675
|
if (!myWasXInclude && !mySkipContent) {
|
524
|
8675
|
myParserContext.startElement(qnStart, null != attributes ? attributes : Collections.EMPTY_MAP, startToken.beginLine, startToken.beginColumn);
|
525
|
|
}
|
526
|
|
}
|
527
|
8676
|
myWasXInclude = isXInclude;
|
528
|
8676
|
switch (jj_nt.kind) {
|
529
|
|
case SLASH_GT:
|
530
|
4102
|
endToken = jj_consume_token(SLASH_GT);
|
531
|
4102
|
break;
|
532
|
|
case GT:
|
533
|
4574
|
jj_consume_token(GT);
|
534
|
4574
|
contentContainsFallback = content();
|
535
|
4574
|
endToken = jj_consume_token(LT_SLASH);
|
536
|
4574
|
qnEnd = qName();
|
537
|
4574
|
jj_consume_token(GT);
|
538
|
4574
|
if (!qnStart.getPrefix().equals(qnEnd.getPrefix()) || !qnStart.getLocalPart().equals(qnEnd.getLocalPart())) {
|
539
|
0
|
fatalError(XmlMessages.startQNameAndEndQNameDifferent(qnStart, qnEnd, getLocation(qnEnd.line, qnEnd.column)));
|
540
|
|
}
|
541
|
4574
|
break;
|
542
|
|
default:
|
543
|
0
|
jj_la1[14] = jj_gen;
|
544
|
0
|
jj_consume_token(-1);
|
545
|
0
|
throw new ParseException();
|
546
|
|
}
|
547
|
8676
|
if (myWasXInclude && !mySkipContent) {
|
548
|
|
// There was an XInclude that could not be retrieved
|
549
|
|
// -> There must have been a fallback
|
550
|
0
|
if (!contentContainsFallback) {
|
551
|
0
|
error(XmlMessages.missingFallbackInXInclude(getLocation(startToken)));
|
552
|
|
}
|
553
|
|
}
|
554
|
|
|
555
|
|
// restore environment
|
556
|
|
|
557
|
8676
|
mySkipContent = saveSkipContent;
|
558
|
8676
|
myWasXInclude = saveWasXInclude;
|
559
|
8676
|
myBaseUrl = saveBaseUrl;
|
560
|
|
|
561
|
8676
|
if (INamespaces.XINCLUDE.equals(qnStart.getNamespace())) {
|
562
|
1
|
if ("include".equals(qnStart.getLocalPart()) && !mySkipContent) {
|
563
|
1
|
endXInclude();
|
564
|
|
}
|
565
|
|
} else {
|
566
|
8675
|
if (!myWasXInclude && !mySkipContent) {
|
567
|
8675
|
myParserContext.endElement(qnStart, attributes, endToken.beginLine, endToken.beginColumn);
|
568
|
|
}
|
569
|
|
}
|
570
|
|
|
571
|
8676
|
myParserContext.namespaceContext.popContext();
|
572
|
8676
|
{if (true) return isFallback;}
|
573
|
0
|
throw new Error("Missing return statement in function");
|
574
|
|
}
|
575
|
|
|
576
|
50
|
final public String entityRef() throws ParseException, ParsingAbortedException {
|
577
|
50
|
Token t;
|
578
|
50
|
t = jj_consume_token(ENTITY_REF);
|
579
|
50
|
String entityName = t.image.substring(1, t.image.length()-1);
|
580
|
50
|
String s = (String)myParserContext.internalEntities.get(entityName);
|
581
|
50
|
if (null == s) {
|
582
|
0
|
error(XmlMessages.unknownEntity(entityName, getLocation(t)));
|
583
|
0
|
s = "";
|
584
|
|
}
|
585
|
50
|
{if (true) return s;}
|
586
|
0
|
throw new Error("Missing return statement in function");
|
587
|
|
}
|
588
|
|
|
589
|
953
|
final public void misc() throws ParseException {
|
590
|
953
|
switch (jj_nt.kind) {
|
591
|
|
case COMMENT:
|
592
|
69
|
jj_consume_token(COMMENT);
|
593
|
69
|
break;
|
594
|
|
case PI:
|
595
|
372
|
jj_consume_token(PI);
|
596
|
372
|
break;
|
597
|
|
case S:
|
598
|
512
|
jj_consume_token(S);
|
599
|
512
|
break;
|
600
|
|
default:
|
601
|
0
|
jj_la1[15] = jj_gen;
|
602
|
0
|
jj_consume_token(-1);
|
603
|
0
|
throw new ParseException();
|
604
|
|
}
|
605
|
|
}
|
606
|
|
|
607
|
462
|
final public XmlDecl optionalXmlDecl() throws ParseException, ParsingAbortedException {
|
608
|
462
|
XmlDecl xmlDecl = null;
|
609
|
462
|
switch (jj_nt.kind) {
|
610
|
|
case XML_DECL_START:
|
611
|
0
|
xmlDecl = xmlDecl();
|
612
|
0
|
break;
|
613
|
|
default:
|
614
|
462
|
jj_la1[16] = jj_gen;
|
615
|
|
;
|
616
|
|
}
|
617
|
462
|
{if (true) return xmlDecl;}
|
618
|
0
|
throw new Error("Missing return statement in function");
|
619
|
|
}
|
620
|
|
|
621
|
467
|
final public void prolog() throws ParseException, Exception {
|
622
|
467
|
switch (jj_nt.kind) {
|
623
|
|
case XML_DECL_START:
|
624
|
0
|
xmlDecl();
|
625
|
0
|
break;
|
626
|
|
default:
|
627
|
467
|
jj_la1[17] = jj_gen;
|
628
|
|
;
|
629
|
|
}
|
630
|
467
|
label_7:
|
631
|
|
while (true) {
|
632
|
1413
|
switch (jj_nt.kind) {
|
633
|
|
case S:
|
634
|
|
case COMMENT:
|
635
|
|
case PI:
|
636
|
|
;
|
637
|
946
|
break;
|
638
|
|
default:
|
639
|
467
|
jj_la1[18] = jj_gen;
|
640
|
467
|
break label_7;
|
641
|
|
}
|
642
|
946
|
misc();
|
643
|
|
}
|
644
|
467
|
switch (jj_nt.kind) {
|
645
|
|
case DOC_TYPE_START:
|
646
|
7
|
docTypeDecl();
|
647
|
7
|
label_8:
|
648
|
|
while (true) {
|
649
|
14
|
switch (jj_nt.kind) {
|
650
|
|
case S:
|
651
|
|
case COMMENT:
|
652
|
|
case PI:
|
653
|
|
;
|
654
|
7
|
break;
|
655
|
|
default:
|
656
|
7
|
jj_la1[19] = jj_gen;
|
657
|
7
|
break label_8;
|
658
|
|
}
|
659
|
7
|
misc();
|
660
|
|
}
|
661
|
7
|
break;
|
662
|
|
default:
|
663
|
460
|
jj_la1[20] = jj_gen;
|
664
|
|
;
|
665
|
|
}
|
666
|
|
}
|
667
|
|
|
668
|
23505
|
final public QualifiedName qName() throws ParseException {
|
669
|
23505
|
Token t1 = null;
|
670
|
23505
|
Token t2 = null;
|
671
|
23505
|
t1 = jj_consume_token(NCName);
|
672
|
23505
|
switch (jj_nt.kind) {
|
673
|
|
case COLON:
|
674
|
9919
|
jj_consume_token(COLON);
|
675
|
9919
|
t2 = jj_consume_token(NCName);
|
676
|
9919
|
break;
|
677
|
|
default:
|
678
|
13586
|
jj_la1[21] = jj_gen;
|
679
|
|
;
|
680
|
|
}
|
681
|
23505
|
{if (true) return null != t2 ? new QualifiedName(t1.image, t2.image, t1.beginLine, t1.beginColumn) : new QualifiedName("", t1.image, t1.beginLine, t1.beginColumn);}
|
682
|
0
|
throw new Error("Missing return statement in function");
|
683
|
|
}
|
684
|
|
|
685
|
50
|
final public String reference() throws ParseException, ParsingAbortedException {
|
686
|
50
|
String s = null;
|
687
|
50
|
switch (jj_nt.kind) {
|
688
|
|
case CHAR_REF_D:
|
689
|
0
|
s = charRefD();
|
690
|
0
|
break;
|
691
|
|
case CHAR_REF_H:
|
692
|
0
|
s = charRefH();
|
693
|
0
|
break;
|
694
|
|
case ENTITY_REF:
|
695
|
50
|
s = entityRef();
|
696
|
50
|
{if (true) return s;}
|
697
|
0
|
break;
|
698
|
|
default:
|
699
|
0
|
jj_la1[22] = jj_gen;
|
700
|
0
|
jj_consume_token(-1);
|
701
|
0
|
throw new ParseException();
|
702
|
|
}
|
703
|
0
|
throw new Error("Missing return statement in function");
|
704
|
|
}
|
705
|
|
|
706
|
0
|
final public XmlDecl xmlDecl() throws ParseException, ParsingAbortedException {
|
707
|
0
|
XmlDecl xmlDecl = null;
|
708
|
0
|
Token vt = null;
|
709
|
0
|
Token et = null;
|
710
|
0
|
Token st = null;
|
711
|
0
|
jj_consume_token(XML_DECL_START);
|
712
|
0
|
jj_consume_token(version);
|
713
|
0
|
jj_consume_token(decl_EQ);
|
714
|
0
|
vt = jj_consume_token(decl_CDATA);
|
715
|
0
|
switch (jj_nt.kind) {
|
716
|
|
case encoding:
|
717
|
0
|
jj_consume_token(encoding);
|
718
|
0
|
jj_consume_token(decl_EQ);
|
719
|
0
|
et = jj_consume_token(decl_CDATA);
|
720
|
0
|
break;
|
721
|
|
default:
|
722
|
0
|
jj_la1[23] = jj_gen;
|
723
|
|
;
|
724
|
|
}
|
725
|
0
|
switch (jj_nt.kind) {
|
726
|
|
case standalone:
|
727
|
0
|
jj_consume_token(standalone);
|
728
|
0
|
jj_consume_token(decl_EQ);
|
729
|
0
|
st = jj_consume_token(decl_CDATA);
|
730
|
0
|
break;
|
731
|
|
default:
|
732
|
0
|
jj_la1[24] = jj_gen;
|
733
|
|
;
|
734
|
|
}
|
735
|
0
|
jj_consume_token(XML_DECL_END);
|
736
|
0
|
String v = cdata(vt);
|
737
|
0
|
if (!"1.0".equals(v)) {
|
738
|
0
|
error(XmlMessages.invalidAttributeValue("version", v, getLocation(vt)));
|
739
|
|
}
|
740
|
0
|
String e = cdata(et);
|
741
|
0
|
if (null != e && !p_encoding.matches(e)) {
|
742
|
0
|
error(XmlMessages.invalidAttributeValue("encoding", e, getLocation(et)));
|
743
|
|
}
|
744
|
0
|
String s = cdata(st);
|
745
|
0
|
if (null != s && !"yes".equals(s) && !"no".equals(s)) {
|
746
|
0
|
error(XmlMessages.invalidAttributeValue("standalone", s, getLocation(st)));
|
747
|
|
}
|
748
|
0
|
xmlDecl = new XmlDecl(v, e, s);
|
749
|
0
|
{if (true) return xmlDecl;}
|
750
|
0
|
throw new Error("Missing return statement in function");
|
751
|
|
}
|
752
|
|
|
753
|
|
public ParserTokenManager token_source;
|
754
|
|
SimpleCharStream jj_input_stream;
|
755
|
|
public Token token, jj_nt;
|
756
|
|
private int jj_gen;
|
757
|
|
final private int[] jj_la1 = new int[25];
|
758
|
|
final private int[] jj_la1_0 = {0x38800,0x38800,0x3a000,0x3a000,0x0,0x200,0x384d0,0x384d0,0x200,0x380000c0,0x380000c0,0x800000,0xe0,0x0,0x0,0xe0,0x4,0x4,0xe0,0xe0,0x8,0x80000000,0x38000,0x0,0x0,};
|
759
|
|
final private int[] jj_la1_1 = {0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4000,0x8000,};
|
760
|
|
|
761
|
0
|
public Parser(java.io.InputStream stream) {
|
762
|
0
|
jj_input_stream = new SimpleCharStream(stream, 1, 1);
|
763
|
0
|
token_source = new ParserTokenManager(jj_input_stream);
|
764
|
0
|
token = new Token();
|
765
|
0
|
token.next = jj_nt = token_source.getNextToken();
|
766
|
0
|
jj_gen = 0;
|
767
|
0
|
for (int i = 0; i < 25; i++) jj_la1[i] = -1;
|
768
|
|
}
|
769
|
|
|
770
|
0
|
public void ReInit(java.io.InputStream stream) {
|
771
|
0
|
jj_input_stream.ReInit(stream, 1, 1);
|
772
|
0
|
token_source.ReInit(jj_input_stream);
|
773
|
0
|
token = new Token();
|
774
|
0
|
token.next = jj_nt = token_source.getNextToken();
|
775
|
0
|
jj_gen = 0;
|
776
|
0
|
for (int i = 0; i < 25; i++) jj_la1[i] = -1;
|
777
|
|
}
|
778
|
|
|
779
|
398
|
public Parser(java.io.Reader stream) {
|
780
|
398
|
jj_input_stream = new SimpleCharStream(stream, 1, 1);
|
781
|
398
|
token_source = new ParserTokenManager(jj_input_stream);
|
782
|
398
|
token = new Token();
|
783
|
398
|
token.next = jj_nt = token_source.getNextToken();
|
784
|
398
|
jj_gen = 0;
|
785
|
9950
|
for (int i = 0; i < 25; i++) jj_la1[i] = -1;
|
786
|
|
}
|
787
|
|
|
788
|
69
|
public void ReInit(java.io.Reader stream) {
|
789
|
69
|
jj_input_stream.ReInit(stream, 1, 1);
|
790
|
69
|
token_source.ReInit(jj_input_stream);
|
791
|
69
|
token = new Token();
|
792
|
69
|
token.next = jj_nt = token_source.getNextToken();
|
793
|
69
|
jj_gen = 0;
|
794
|
1725
|
for (int i = 0; i < 25; i++) jj_la1[i] = -1;
|
795
|
|
}
|
796
|
|
|
797
|
0
|
public Parser(ParserTokenManager tm) {
|
798
|
0
|
token_source = tm;
|
799
|
0
|
token = new Token();
|
800
|
0
|
token.next = jj_nt = token_source.getNextToken();
|
801
|
0
|
jj_gen = 0;
|
802
|
0
|
for (int i = 0; i < 25; i++) jj_la1[i] = -1;
|
803
|
|
}
|
804
|
|
|
805
|
0
|
public void ReInit(ParserTokenManager tm) {
|
806
|
0
|
token_source = tm;
|
807
|
0
|
token = new Token();
|
808
|
0
|
token.next = jj_nt = token_source.getNextToken();
|
809
|
0
|
jj_gen = 0;
|
810
|
0
|
for (int i = 0; i < 25; i++) jj_la1[i] = -1;
|
811
|
|
}
|
812
|
|
|
813
|
124720
|
final private Token jj_consume_token(int kind) throws ParseException {
|
814
|
124720
|
Token oldToken = token;
|
815
|
0
|
if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
|
816
|
124720
|
else jj_nt = jj_nt.next = token_source.getNextToken();
|
817
|
124720
|
if (token.kind == kind) {
|
818
|
124720
|
jj_gen++;
|
819
|
124720
|
return token;
|
820
|
|
}
|
821
|
0
|
jj_nt = token;
|
822
|
0
|
token = oldToken;
|
823
|
0
|
jj_kind = kind;
|
824
|
0
|
throw generateParseException();
|
825
|
|
}
|
826
|
|
|
827
|
0
|
final public Token getNextToken() {
|
828
|
0
|
if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
|
829
|
0
|
else jj_nt = jj_nt.next = token_source.getNextToken();
|
830
|
0
|
jj_gen++;
|
831
|
0
|
return token;
|
832
|
|
}
|
833
|
|
|
834
|
0
|
final public Token getToken(int index) {
|
835
|
0
|
Token t = token;
|
836
|
0
|
for (int i = 0; i < index; i++) {
|
837
|
0
|
if (t.next != null) t = t.next;
|
838
|
0
|
else t = t.next = token_source.getNextToken();
|
839
|
|
}
|
840
|
0
|
return t;
|
841
|
|
}
|
842
|
|
|
843
|
|
private java.util.Vector jj_expentries = new java.util.Vector();
|
844
|
|
private int[] jj_expentry;
|
845
|
|
private int jj_kind = -1;
|
846
|
|
|
847
|
0
|
final public ParseException generateParseException() {
|
848
|
0
|
jj_expentries.removeAllElements();
|
849
|
0
|
boolean[] la1tokens = new boolean[50];
|
850
|
0
|
for (int i = 0; i < 50; i++) {
|
851
|
0
|
la1tokens[i] = false;
|
852
|
|
}
|
853
|
0
|
if (jj_kind >= 0) {
|
854
|
0
|
la1tokens[jj_kind] = true;
|
855
|
0
|
jj_kind = -1;
|
856
|
|
}
|
857
|
0
|
for (int i = 0; i < 25; i++) {
|
858
|
0
|
if (jj_la1[i] == jj_gen) {
|
859
|
0
|
for (int j = 0; j < 32; j++) {
|
860
|
0
|
if ((jj_la1_0[i] & (1<<j)) != 0) {
|
861
|
0
|
la1tokens[j] = true;
|
862
|
|
}
|
863
|
0
|
if ((jj_la1_1[i] & (1<<j)) != 0) {
|
864
|
0
|
la1tokens[32+j] = true;
|
865
|
|
}
|
866
|
|
}
|
867
|
|
}
|
868
|
|
}
|
869
|
0
|
for (int i = 0; i < 50; i++) {
|
870
|
0
|
if (la1tokens[i]) {
|
871
|
0
|
jj_expentry = new int[1];
|
872
|
0
|
jj_expentry[0] = i;
|
873
|
0
|
jj_expentries.addElement(jj_expentry);
|
874
|
|
}
|
875
|
|
}
|
876
|
0
|
int[][] exptokseq = new int[jj_expentries.size()][];
|
877
|
0
|
for (int i = 0; i < jj_expentries.size(); i++) {
|
878
|
0
|
exptokseq[i] = (int[])jj_expentries.elementAt(i);
|
879
|
|
}
|
880
|
0
|
return new ParseException(token, exptokseq, tokenImage);
|
881
|
|
}
|
882
|
|
|
883
|
0
|
final public void enable_tracing() {
|
884
|
|
}
|
885
|
|
|
886
|
0
|
final public void disable_tracing() {
|
887
|
|
}
|
888
|
|
|
889
|
|
}
|
890
|
|
|