1 |
Module: |
2 |
@QName: MDOM|XMLParser |
3 |
@Namespace: |
4 |
http://suika.fam.cx/~wakaba/archive/2004/dom/xml-parser# |
5 |
|
6 |
@FullName: |
7 |
@@lang:en |
8 |
@@@: XML Parser |
9 |
|
10 |
@DISCore:author: DISCore|Wakaba |
11 |
@License: license|Perl+MPL |
12 |
@Date: |
13 |
$Date: 2006/01/21 07:06:09 $ |
14 |
|
15 |
@DefaultFor: ManakaiDOM|ManakaiDOMLatest |
16 |
|
17 |
@Require: |
18 |
@@Module: |
19 |
@@@QName: MDOM|DOMLS |
20 |
@@@WithFor: ManakaiDOM|ManakaiDOMLatest |
21 |
@@Module: |
22 |
@@@QName: MDOM|XDoctype |
23 |
@@@WithFor: ManakaiDOM|ManakaiDOMLatest |
24 |
|
25 |
Namespace: |
26 |
@d: |
27 |
http://suika.fam.cx/~wakaba/archive/2004/dom/xdt# |
28 |
@dis: |
29 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis-- |
30 |
@DOMCore: |
31 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core# |
32 |
@DOMMain: |
33 |
http://suika.fam.cx/~wakaba/archive/2004/dom/main# |
34 |
@dtest: |
35 |
http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#Test/ |
36 |
@dx: |
37 |
http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException# |
38 |
@ecore: |
39 |
http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/Core/ |
40 |
@f: |
41 |
http://suika.fam.cx/~wakaba/archive/2004/dom/feature# |
42 |
@idl: |
43 |
http://suika.fam.cx/~wakaba/archive/2004/dis/IDL# |
44 |
@infoset: |
45 |
http://www.w3.org/2001/04/infoset# |
46 |
@lang: |
47 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/lang# |
48 |
@license: |
49 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/license# |
50 |
@LSEV: |
51 |
http://www.w3.org/2002/DOMLS |
52 |
@ManakaiDOM: |
53 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom# |
54 |
@ManakaiDOMLS: |
55 |
http://suika.fam.cx/~wakaba/archive/2004/mdom-ls# |
56 |
@MDOM: |
57 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM. |
58 |
@MDOMX: |
59 |
http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception# |
60 |
@rdf: |
61 |
http://www.w3.org/1999/02/22-rdf-syntax-ns# |
62 |
@rdfs: |
63 |
http://www.w3.org/2000/01/rdf-schema# |
64 |
@t: |
65 |
http://suika.fam.cx/~wakaba/archive/2004/dom/tree# |
66 |
@test: |
67 |
http://suika.fam.cx/~wakaba/archive/2004/dis/Test# |
68 |
@xml: |
69 |
http://www.w3.org/XML/1998/namespace |
70 |
@xmlns: |
71 |
http://www.w3.org/2000/xmlns/ |
72 |
@xp: |
73 |
http://suika.fam.cx/~wakaba/archive/2004/dom/xml-parser# |
74 |
|
75 |
## -- Features |
76 |
|
77 |
ElementTypeBinding: |
78 |
@Name: FeatureDef |
79 |
@ElementType: |
80 |
dis:ResourceDef |
81 |
@ShadowContent: |
82 |
@@rdf:type: f|Feature |
83 |
@@For: =ManakaiDOM|all |
84 |
|
85 |
ElementTypeBinding: |
86 |
@Name: FeatureVerDef |
87 |
@ElementType: |
88 |
dis:ResourceDef |
89 |
@ShadowContent: |
90 |
@@rdf:type: f|Feature |
91 |
|
92 |
ElementTypeBinding: |
93 |
@Name: featureQName |
94 |
@ElementType: |
95 |
f:name |
96 |
@ShadowContent: |
97 |
@@ContentType: DISCore|QName |
98 |
|
99 |
ResourceDef: |
100 |
@QName: DOMString |
101 |
@AliasFor: DOMMain|DOMString |
102 |
@For: ManakaiDOM|DOM |
103 |
|
104 |
ResourceDef: |
105 |
@QName: Node |
106 |
@AliasFor: t|Node |
107 |
@For: ManakaiDOM|DOM |
108 |
|
109 |
ResourceDef: |
110 |
@QName: Element |
111 |
@AliasFor: t|Element |
112 |
@For: ManakaiDOM|DOM |
113 |
|
114 |
ResourceDef: |
115 |
@QName: Document |
116 |
@AliasFor: t|Document |
117 |
@For: ManakaiDOM|DOM |
118 |
|
119 |
ResourceDef: |
120 |
@QName: DocumentXDoctype |
121 |
@AliasFor: d|DocumentXDoctype |
122 |
@For: ManakaiDOM|DOM |
123 |
|
124 |
ElementTypeBinding: |
125 |
@Name: ClsDef |
126 |
@ElementType: |
127 |
dis:ResourceDef |
128 |
@ShadowContent: |
129 |
@@rdf:type: |
130 |
@@@@: dis|MultipleResource |
131 |
@@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass |
132 |
@@resourceFor: |
133 |
@@@@: ManakaiDOM|ForClass |
134 |
@@@ForCheck: ManakaiDOM|ManakaiDOM !=ManakaiDOM|ManakaiDOM |
135 |
@@For: ManakaiDOM|DOM3 |
136 |
@@For: =ManakaiDOM|ManakaiDOM |
137 |
|
138 |
@@rdf:type: |
139 |
@@@@: DISLang|Class |
140 |
@@@ForCheck: ManakaiDOM|ForClass |
141 |
|
142 |
ElementTypeBinding: |
143 |
@Name: ClsQName |
144 |
@ElementType: |
145 |
dis:QName |
146 |
@ShadowContent: |
147 |
@@ForCheck: ManakaiDOM|ForClass |
148 |
|
149 |
ElementTypeBinding: |
150 |
@Name: ClsISA |
151 |
@ElementType: |
152 |
dis:ISA |
153 |
@ShadowContent: |
154 |
@@ForCheck: ManakaiDOM|ForClass |
155 |
|
156 |
ElementTypeBinding: |
157 |
@Name: nullCase |
158 |
@ElementType: |
159 |
dis:ResourceDef |
160 |
@ShadowContent: |
161 |
@@rdf:type: ManakaiDOM|InCase |
162 |
@@Value: |
163 |
@@@is-null:1 |
164 |
|
165 |
ResourceDef: |
166 |
@QName: LSParser |
167 |
@AliasFor: DOMLS|LSParser |
168 |
@For: ManakaiDOM|DOM3 |
169 |
|
170 |
ClsDef: |
171 |
@ClsQName: ManakaiXMLParser |
172 |
|
173 |
@Implement: DOMLS|LSParser |
174 |
|
175 |
@f:implements: |
176 |
@@@: DOMLS|LSFeature30 |
177 |
@@For: ManakaiDOM|DOM3 |
178 |
|
179 |
@DISLang:role: DOMLS|ParserRole |
180 |
|
181 |
@enDesc: |
182 |
Note that the <Class::ManakaiXMLParser> reports any XML errors |
183 |
(syntax errors and / or well-formedness constraint errors) |
184 |
via the <IF::DOMCore:error-handler> registered to |
185 |
the <A::DOMLS:LSParser.domConfig> object. Each error has |
186 |
its <A::DOMCore:DOMError.severity>, either <C::DOMCore:SEVERITY_ERROR> |
187 |
or <C::DOMCore:SEVERITY_FATAL_ERROR>. However, their semantics |
188 |
are slight different from the ones of <QUOTE::error> and |
189 |
<QUOTE::fatal error> in XML; in this implemenetation, |
190 |
<C::DOMCore:SEVERITY_ERROR> implies that the parsing process |
191 |
can effectively be continued to detect more errors while |
192 |
<C::DOMCore:SEVERITY_FATAL_ERROR> implies that the error |
193 |
is serious so that the result document tree and any errors |
194 |
might be far from the ones obtained when the error would not |
195 |
be found. |
196 |
|
197 |
@Attr: |
198 |
@@Name: domConfig |
199 |
@@enDesc: |
200 |
The configuration of the parser. |
201 |
|
202 |
@@Get: |
203 |
@@@Type: DOMCore|DOMConfiguration |
204 |
@@@enDesc: The DOM configuration object. |
205 |
@@@PerlDef: |
206 |
__CODE{DOMCore|getConfigObject:: |
207 |
$target => $self, |
208 |
$targetHash => $self, |
209 |
$targetType => {<IFName::LSParser>}, |
210 |
$result => $r, |
211 |
}__; |
212 |
|
213 |
@Method: |
214 |
@@ManakaiDOM:isForInternal:1 |
215 |
@@ForCheck: ManakaiDOM|ForClass |
216 |
@@Operator: DISPerl|NewMethod |
217 |
@@enDesc: |
218 |
Creates a new instance of the object. |
219 |
@@Param: |
220 |
@@@Name: impl |
221 |
@@@Type: DOMLS|GLSImplementation |
222 |
@@@enDesc: |
223 |
The implementation from which the parser is created. |
224 |
@@Param: |
225 |
@@@Name: features |
226 |
@@@Type: DOMString |
227 |
@@@dis:actualType: f|FeaturesString |
228 |
@@@enDesc: |
229 |
The set of features requested for the parser. |
230 |
@@Return: |
231 |
@@@Type: DOMMain|DOMObject |
232 |
@@@dis:actualType: LSParser |
233 |
@@@enDesc: |
234 |
The newly created parser. |
235 |
@@@PerlDef: |
236 |
$r = bless { |
237 |
<H::DOMCore:implementation> => $impl, |
238 |
}, $self; |
239 |
|
240 |
@Method: |
241 |
@@Name: parseString |
242 |
@@enImplNote: |
243 |
Non-standard - to be removed |
244 |
|
245 |
@@Param: |
246 |
@@@Name: sourceText |
247 |
@@@Type: DOMString |
248 |
@@Return: |
249 |
@@@Type: Document |
250 |
@@@PerlDef: |
251 |
|
252 |
$self->{char} = []; |
253 |
$self->{token} = []; |
254 |
$self->{entity} = [{ |
255 |
reptxt => \$sourceText, |
256 |
line => 1, |
257 |
column => 1, |
258 |
pos => 0, |
259 |
}]; |
260 |
$self->{entity_char} = []; |
261 |
$self->{entity_token} = []; |
262 |
$self->{xml_version} = '1.0'; |
263 |
$self->{standalone} = false; |
264 |
$self->{general_entity} = {}; |
265 |
$self->{param_entity} = {}; |
266 |
$self->{has_error} = false; |
267 |
## Well-formedness constraint Entity Declared takes effect? |
268 |
|
269 |
__DEEP{ |
270 |
$r = $self->_parse_DocumentEntity |
271 |
($self->{<H::DOMCore:implementation>}); |
272 |
}__; |
273 |
|
274 |
@Method: |
275 |
@@Name: shiftChar |
276 |
@@ManakaiDOM:isForInternal:1 |
277 |
@@ForCheck: ManakaiDOM|ForClass |
278 |
@@enDesc: |
279 |
Returns the next character. |
280 |
@@Return: |
281 |
@@@Type: idl|long||ManakaiDOM|all |
282 |
@@@enDesc: |
283 |
The code position number of the next character, if any, |
284 |
or <CODE::-1>. |
285 |
@@@PerlDef: |
286 |
if (@{$self->{char}}) { |
287 |
$r = shift @{$self->{char}}; |
288 |
} else { |
289 |
GETCHAR: { |
290 |
my $char = substr (${$self->{entity}->[-1]->{reptxt}}, |
291 |
$self->{entity}->[-1]->{pos}, 1); |
292 |
$self->{entity}->[-1]->{pos}++; |
293 |
|
294 |
if (length $char) { |
295 |
$r = ord $char; |
296 |
if ($r == 0x000A) { |
297 |
$self->{entity}->[-1]->{line}++; |
298 |
$self->{entity}->[-1]->{column} = 1; |
299 |
} elsif ($r == 0x000D) { |
300 |
my $next_char = substr (${$self->{entity}->[-1]->{reptxt}}, |
301 |
$self->{entity}->[-1]->{pos}, 1); |
302 |
if ($next_char eq "\x0A") { |
303 |
$self->{entity}->[-1]->{pos}++; |
304 |
$self->{entity}->[-1]->{column} = 1; |
305 |
} elsif ($next_char eq "\x85") { |
306 |
if ($self->{xml_version} eq '1.1') { |
307 |
$self->{entity}->[-1]->{pos}++; |
308 |
$self->{entity}->[-1]->{column} = 1; |
309 |
} else { |
310 |
$self->{entity}->[-1]->{column} = 0; |
311 |
} |
312 |
} else { |
313 |
$self->{entity}->[-1]->{column} = 1; |
314 |
} |
315 |
$r = 0x000A; |
316 |
$self->{entity}->[-1]->{line}++; |
317 |
} elsif ( |
318 |
not ((0x0020 <= $r and $r <= 0x007E) or |
319 |
(0x00A0 <= $r and $r <= 0xD7FF) or |
320 |
(0xE000 <= $r and $r <= 0xFFFD) or |
321 |
(0x10000 <= $r and $r <= 0x10FFFF)) and |
322 |
$r != 0x0009 and $r != 0x0085 and |
323 |
not ($self->{xml_version} eq '1.0' and |
324 |
(0x007F <= $r and $r <= 0x009F)) |
325 |
) { |
326 |
my $location = { |
327 |
utf32_offset => $self->{entity}->[-1]->{pos}, |
328 |
line_number => $self->{entity}->[-1]->{line}, |
329 |
column_number => $self->{entity}->[-1]->{column}, |
330 |
}; |
331 |
my $continue = __DOMCore:ERROR{xp|wf-legal-literal-character:: |
332 |
DOMCore|location => {$location}, |
333 |
xp|character-number => {$r}, |
334 |
}__; |
335 |
unless ($continue) { |
336 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
337 |
} |
338 |
$self->{has_error} = true; |
339 |
$self->{entity}->[-1]->{column}++; |
340 |
} elsif ($r == 0x0085 or $r == 0x2028) { |
341 |
$r = 0x000A if $self->{xml_version} eq '1.1'; |
342 |
$self->{entity}->[-1]->{line}++; |
343 |
$self->{entity}->[-1]->{column} = 1; |
344 |
} else { |
345 |
$self->{entity}->[-1]->{column}++; |
346 |
} |
347 |
# } elsif (@{$self->{entity}} > 1) { |
348 |
# pop @{$self->{entity}}; |
349 |
# redo GETCHAR; |
350 |
# ## ISSUE: How cope with delimiter scanning & |
351 |
# ## self-containedness constraints?? |
352 |
} else { |
353 |
$r = -1; |
354 |
} |
355 |
} # GETCHAR |
356 |
} |
357 |
|
358 |
@Method: |
359 |
@@ManakaiDOM:isForInternal: 1 |
360 |
@@Operator: ManakaiDOM|MUErrorHandler |
361 |
@@enDesc: |
362 |
When a <IF::ecore|ErrorInterface||ManakaiDOM|Perl> is <Perl::report>ed, |
363 |
then this method is invoked. |
364 |
|
365 |
The method calls the <cfg::DOMCore|error-handler> if the error is of |
366 |
<IF::DOMCore|DOMError>. Otherwise, the error is re-thrown so that |
367 |
corresponding <Perl::catch> clause, if any, can catch the error. |
368 |
@@Param: |
369 |
@@@Name: err |
370 |
@@@Type: ecore|ErrorInterface||ManakaiDOM|Perl |
371 |
@@@enDesc: |
372 |
The reported error object. |
373 |
@@Return: |
374 |
@@@Type: DISPerl|Any |
375 |
@@@enDesc: |
376 |
If the <P::err> is a <IF::DOMCore|DOMError>, then the return value |
377 |
of the error handler. |
378 |
|
379 |
{NOTE:: If the error is thrown, the method never returns. |
380 |
} |
381 |
@@@nullCase: |
382 |
@@@@enDesc: |
383 |
No error handler. |
384 |
@@@PerlDef: |
385 |
if ($err->isa (<IFName::DOMCore|DOMError||ManakaiDOM|ManakaiDOM>)) { |
386 |
__DEEP{ |
387 |
A: { |
388 |
my $cfg = $self-><AG::LSParser.domConfig>; |
389 |
my $h = $cfg-><M::DOMCore|DOMConfiguration.getParameter> |
390 |
('error-handler'); |
391 |
$r = $h-><M::DOMCore|DOMErrorHandler.handleError> ($err); |
392 |
} # A |
393 |
}__; |
394 |
} else { |
395 |
$err-><M::ecore|ErrorInterface||ManakaiDOM|Perl.throw>; |
396 |
} |
397 |
|
398 |
@DISPerl:dpgDef: |
399 |
|
400 |
/* |
401 |
XML Document Entity |
402 |
|
403 |
document := prolog element *Misc |
404 |
- *Char RestrictedChar *Char ;; [1] |
405 |
*/ |
406 |
rule DocumentEntity ($impl) : standalone { |
407 |
my $doc : return; |
408 |
|
409 |
lang:Perl { |
410 |
$doc = $impl-><M::DOMImpl.createDocument>; |
411 |
$doc-><AS::Document.strictErrorChecking> (false); |
412 |
} |
413 |
|
414 |
/* |
415 |
prolog := XMLDecl? *Misc [doctypedecl *Misc] ;; [22] |
416 |
*/ |
417 |
?lexmode 'DocumentStart'; |
418 |
|
419 |
~? (XDO) { |
420 |
&_XMLDeclaration_ ($doc => $doc); |
421 |
|
422 |
~ (PIC) { |
423 |
?lexmode DocumentProlog; |
424 |
} else { |
425 |
?lexmode DocumentProlog; |
426 |
} |
427 |
} else { |
428 |
?lexmode 'DocumentProlog'; |
429 |
} |
430 |
|
431 |
// *Misc |
432 |
~* (CDO) { |
433 |
&_CommentDeclaration_ ($doc => $doc, $parent => $doc); |
434 |
|
435 |
~ (MDC) { |
436 |
?lexmode DocumentProlog; |
437 |
} else { |
438 |
?lexmode DocumentProlog; |
439 |
} |
440 |
} (PIO) { |
441 |
&_ProcessingInstruction_ ($doc => $doc, $parent => $doc); |
442 |
|
443 |
~ (PIC) { |
444 |
?lexmode 'DocumentProlog'; |
445 |
} else { |
446 |
?lexmode DocumentProlog; |
447 |
} |
448 |
} (S) { |
449 |
// |
450 |
} |
451 |
|
452 |
// doctypedecl |
453 |
~? (MDO) { |
454 |
&_DocumentTypeDeclaration_ ($doc => $doc); |
455 |
|
456 |
~ (MDC) { |
457 |
?lexmode DocumentMisc; |
458 |
} else { |
459 |
?lexmode DocumentMisc; |
460 |
} |
461 |
} else { |
462 |
lang:Perl { |
463 |
$self->{standalone} = true; |
464 |
} |
465 |
?lexmode DocumentMisc; |
466 |
} |
467 |
|
468 |
// *Misc |
469 |
~* (CDO) { |
470 |
&_CommentDeclaration_ ($doc => $doc, $parent => $doc); |
471 |
|
472 |
~ (MDC) { |
473 |
?lexmode DocumentMisc; |
474 |
} else { |
475 |
?lexmode DocumentMisc; |
476 |
} |
477 |
} (PIO) { |
478 |
&_ProcessingInstruction_ ($doc => $doc, $parent => $doc); |
479 |
|
480 |
~ (PIC) { |
481 |
?lexmode 'DocumentMisc'; |
482 |
} else { |
483 |
?lexmode DocumentMisc; |
484 |
} |
485 |
} (S) { |
486 |
// |
487 |
} |
488 |
|
489 |
// Document element |
490 |
~ (STAGO) { |
491 |
&Element_ ($doc => $doc, $parent => $doc) |
492 |
: unshift-current-token; |
493 |
~ (TAGC) { |
494 |
?lexmode DocumentEnd; |
495 |
} else { |
496 |
?lexmode DocumentEnd; |
497 |
} |
498 |
} else { |
499 |
?lexmode 'DocumentEnd'; |
500 |
} |
501 |
|
502 |
// *Misc |
503 |
~* (CDO) { |
504 |
&_CommentDeclaration_ ($doc => $doc, $parent => $doc); |
505 |
|
506 |
~ (MDC) { |
507 |
?lexmode DocumentEnd; |
508 |
} else { |
509 |
?lexmode DocumentEnd; |
510 |
} |
511 |
} (PIO) { |
512 |
&_ProcessingInstruction_ ($doc => $doc, $parent => $doc); |
513 |
~ (PIC) { |
514 |
?lexmode 'DocumentEnd'; |
515 |
} else { |
516 |
?lexmode DocumentEnd; |
517 |
} |
518 |
} (S) { |
519 |
// |
520 |
} |
521 |
|
522 |
~ (#EOF) { } |
523 |
|
524 |
lang:Perl { |
525 |
if ($self->{has_error}) { |
526 |
__EXCEPTION{DOMLS|PARSE_ERR:: |
527 |
}__; |
528 |
} |
529 |
|
530 |
$doc-><AS::Document.strictErrorChecking> (true); |
531 |
} |
532 |
} // DocumentEntity |
533 |
|
534 |
/* |
535 |
XML Declaration |
536 |
|
537 |
XMLDecl := '<?xml' VersionInfo |
538 |
[EncodingDecl] |
539 |
[SDDecl] |
540 |
[S] '?>' ;; [23] |
541 |
|
542 |
NOTE: XML declaration is optional in XML 1.0 |
543 |
while it is required in XML 1.1. |
544 |
*/ |
545 |
rule _XMLDeclaration_ ($doc) { |
546 |
?lexmode XMLDeclaration; |
547 |
|
548 |
~ (S) { } |
549 |
|
550 |
~ (Name == 'version') { |
551 |
~? (S) { } |
552 |
~ (VI) { } |
553 |
~? (S) { } |
554 |
|
555 |
my $ver; |
556 |
my $bad_token; |
557 |
|
558 |
~ (LIT) { |
559 |
?lexmode AttributeValueLiteral; |
560 |
|
561 |
~ (STRING) { |
562 |
lang:Perl ($version => $token.value) { |
563 |
$ver = $version; |
564 |
$bad_token = $token; |
565 |
} |
566 |
} |
567 |
|
568 |
~ (LIT) { |
569 |
?lexmode XMLDeclaration; |
570 |
} |
571 |
} (LITA) { |
572 |
?lexmode AttributeValueLiteralA; |
573 |
|
574 |
~ (STRING) { |
575 |
lang:Perl ($version => $token.value) { |
576 |
$ver = $version; |
577 |
$bad_token = $token; |
578 |
} |
579 |
} |
580 |
|
581 |
~ (LITA) { |
582 |
?lexmode XMLDeclaration; |
583 |
} |
584 |
} |
585 |
|
586 |
lang:Perl : has-error { |
587 |
unless ($ver eq '1.0' or $ver eq '1.1') { |
588 |
my $location; |
589 |
__CODE{xp|get-location-from-token:: |
590 |
$token => {$bad_token}, |
591 |
$result => {$location}, |
592 |
}__; |
593 |
my $continue = __DOMCore:ERROR{xp|wf-unsupported-xml-version:: |
594 |
DOMCore|location => {$location}, |
595 |
xp|parent => {$doc}, |
596 |
infoset|version => {$ver}, |
597 |
xp|error-token => {$bad_token}, |
598 |
}__; |
599 |
unless ($continue) { |
600 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
601 |
} |
602 |
$self->{has_error} = true; |
603 |
} |
604 |
$doc-><AS::Document.xmlVersion> ($ver); |
605 |
$self->{xml_version} = $ver; |
606 |
} |
607 |
|
608 |
~? (S) { } |
609 |
} |
610 |
|
611 |
~? (Name == 'encoding') { |
612 |
~? (S) { } |
613 |
~ (VI) { } |
614 |
~? (S) { } |
615 |
|
616 |
my $ver; |
617 |
my $bad_token; |
618 |
|
619 |
~ (LIT) { |
620 |
?lexmode AttributeValueLiteral; |
621 |
|
622 |
~ (STRING) { |
623 |
lang:Perl ($version => $token.value) { |
624 |
$ver = $version; |
625 |
$bad_token = $token; |
626 |
} |
627 |
} |
628 |
|
629 |
~ (LIT) { |
630 |
?lexmode XMLDeclaration; |
631 |
} |
632 |
} (LITA) { |
633 |
?lexmode AttributeValueLiteralA; |
634 |
|
635 |
~ (STRING) { |
636 |
lang:Perl ($version => $token.value) { |
637 |
$ver = $version; |
638 |
$bad_token = $token; |
639 |
} |
640 |
} |
641 |
|
642 |
~ (LITA) { |
643 |
?lexmode XMLDeclaration; |
644 |
} |
645 |
} |
646 |
|
647 |
lang:Perl : has-error { |
648 |
unless ($ver =~ /\A[A-Za-z][A-Za-z0-9._-]*\z/) { |
649 |
my $location; |
650 |
__CODE{xp|get-location-from-token:: |
651 |
$token => {$bad_token}, |
652 |
$result => {$location}, |
653 |
}__; |
654 |
my $continue = __DOMCore:ERROR{xp|wf-malformed-enc-name:: |
655 |
DOMCore|location => {$location}, |
656 |
xp|parent => {$doc}, |
657 |
xp|name => {$ver}, |
658 |
xp|error-token => {$bad_token}, |
659 |
}__; |
660 |
unless ($continue) { |
661 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
662 |
} |
663 |
$self->{has_error} = true; |
664 |
} |
665 |
$doc-><AS::Document.xmlEncoding> ($ver); |
666 |
} |
667 |
|
668 |
~? (S) { } |
669 |
} |
670 |
|
671 |
~? (Name == 'standalone') { |
672 |
~? (S) { } |
673 |
~ (VI) { } |
674 |
~? (S) { } |
675 |
|
676 |
my $ver; |
677 |
my $bad_token; |
678 |
|
679 |
~ (LIT) { |
680 |
?lexmode AttributeValueLiteral; |
681 |
|
682 |
~ (STRING) { |
683 |
lang:Perl ($version => $token.value) { |
684 |
$ver = $version; |
685 |
$bad_token = $token; |
686 |
} |
687 |
} |
688 |
|
689 |
~ (LIT) { |
690 |
?lexmode XMLDeclaration; |
691 |
} |
692 |
} (LITA) { |
693 |
?lexmode AttributeValueLiteralA; |
694 |
|
695 |
~ (STRING) { |
696 |
lang:Perl ($version => $token.value) { |
697 |
$ver = $version; |
698 |
$bad_token = $token; |
699 |
} |
700 |
} |
701 |
|
702 |
~ (LITA) { |
703 |
?lexmode XMLDeclaration; |
704 |
} |
705 |
} |
706 |
|
707 |
lang:Perl : has-error { |
708 |
unless ($ver eq 'yes' or $ver eq 'no') { |
709 |
my $location; |
710 |
__CODE{xp|get-location-from-token:: |
711 |
$token => {$bad_token}, |
712 |
$result => {$location}, |
713 |
}__; |
714 |
my $continue = __DOMCore:ERROR{xp|wf-malformed-xml-standalone:: |
715 |
DOMCore|location => {$location}, |
716 |
xp|parent => {$doc}, |
717 |
xp|name => {$ver}, |
718 |
xp|error-token => {$bad_token}, |
719 |
}__; |
720 |
unless ($continue) { |
721 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
722 |
} |
723 |
$self->{has_error} = true; |
724 |
} |
725 |
$doc-><AS::Document.xmlStandalone> ($ver); |
726 |
$self->{standalone} = true if $ver eq 'yes'; |
727 |
} |
728 |
|
729 |
~? (S) { } |
730 |
} |
731 |
|
732 |
// ~ (PIC) { } |
733 |
} // _XMLDeclaration_ |
734 |
|
735 |
/* |
736 |
Comment Declaration |
737 |
|
738 |
Comment := '<!--' *(Char - '-' / '-' (Char - '-')) |
739 |
'-->' ;; [15] |
740 |
*/ |
741 |
rule _CommentDeclaration_ ($doc, $parent) { |
742 |
?lexmode 'CommentDeclaration'; |
743 |
|
744 |
~? (STRING) { |
745 |
lang:Perl ($data => $token.value) { |
746 |
my $com = $doc-><M::Document.createComment> ($data); |
747 |
$parent-><M::Node.appendChild> ($com); |
748 |
} |
749 |
} else { |
750 |
lang:Perl { |
751 |
my $com = $doc-><M::Document.createComment> (''); |
752 |
$parent-><M::Node.appendChild> ($com); |
753 |
} |
754 |
} |
755 |
|
756 |
~ (COM) { |
757 |
?lexmode MarkupDeclaration; |
758 |
} else { |
759 |
?lexmode MarkupDeclaration; |
760 |
} |
761 |
|
762 |
// ~ (MDC) { } |
763 |
} // _CommentDeclaration |
764 |
_ |
765 |
rule _CommentDeclarationDTD ($doc) { |
766 |
?lexmode 'CommentDeclaration'; |
767 |
|
768 |
~? (STRING) { |
769 |
// |
770 |
} |
771 |
|
772 |
~ (COM) { |
773 |
?lexmode MarkupDeclaration; |
774 |
} else { |
775 |
?lexmode MarkupDeclaration; |
776 |
} |
777 |
|
778 |
~ (MDC) { |
779 |
?lexmode DTD; |
780 |
} else { |
781 |
?lexmode DTD; |
782 |
} |
783 |
} // _CommentDeclarationDTD |
784 |
|
785 |
/* |
786 |
Processing Instruction |
787 |
|
788 |
PI := '<?' PITarget [S *Char - *Char '?>' *Char] |
789 |
'?>' ;; [16] |
790 |
*/ |
791 |
rule _ProcessingInstruction_ ($doc, $parent) { |
792 |
?lexmode 'PIName'; |
793 |
|
794 |
my $pi; |
795 |
|
796 |
~ (Name) { |
797 |
lang:Perl ($name => $token.value) : has-error { |
798 |
if (lc $name eq 'xml') { |
799 |
my $location; |
800 |
__CODE{xp|get-location-from-token:: |
801 |
$token => {$token}, |
802 |
$result => {$location}, |
803 |
}__; |
804 |
my $continue = __DOMCore:ERROR{xp|wf-pi-target-is-xml:: |
805 |
xp|name => {$name}, |
806 |
DOMCore|location => {$location}, |
807 |
xp|parent => {$parent}, |
808 |
}__; |
809 |
unless ($continue) { |
810 |
__EXCEPTION{DOMLS|PARSE_ERR:: |
811 |
}__; |
812 |
} |
813 |
$self->{has_error} = true; |
814 |
} |
815 |
## TODO: Namespace well-formedness |
816 |
$pi = $doc-><M::Document.createProcessingInstruction> |
817 |
($name); |
818 |
} |
819 |
} |
820 |
|
821 |
~ (S) { |
822 |
?lexmode 'PIData'; |
823 |
|
824 |
my $tdata; |
825 |
|
826 |
~? (DATA) { |
827 |
lang:Perl ($data => $token.value) { |
828 |
$tdata = $data; |
829 |
} |
830 |
} else { |
831 |
lang:Perl { |
832 |
$tdata = ''; |
833 |
} |
834 |
} |
835 |
|
836 |
lang:Perl { |
837 |
$pi-><AS::Node.nodeValue> ($tdata); |
838 |
} |
839 |
} |
840 |
|
841 |
lang:Perl { |
842 |
$parent-><M::Node.appendChild> ($pi); |
843 |
} |
844 |
|
845 |
// ~ (PIC) { } |
846 |
} // _ProcessingInstruction_ |
847 |
|
848 |
/* |
849 |
Processing instruction in DTD |
850 |
*/ |
851 |
rule _ProcessingInstructionDTD ($doc, $doctype) { |
852 |
?lexmode 'PIName'; |
853 |
|
854 |
my $pi; |
855 |
|
856 |
~ (Name) { |
857 |
lang:Perl ($name => $token.value) : has-error { |
858 |
if (lc $name eq 'xml') { |
859 |
my $location; |
860 |
__CODE{xp|get-location-from-token:: |
861 |
$token => {$token}, |
862 |
$result => {$location}, |
863 |
}__; |
864 |
my $continue = __DOMCore:ERROR{xp|wf-pi-target-is-xml:: |
865 |
xp|name => {$name}, |
866 |
DOMCore|location => {$location}, |
867 |
xp|parent => {$doctype}, |
868 |
}__; |
869 |
unless ($continue) { |
870 |
__EXCEPTION{DOMLS|PARSE_ERR:: |
871 |
}__; |
872 |
} |
873 |
$self->{has_error} = true; |
874 |
} |
875 |
## TODO: Namespace well-formedness |
876 |
$pi = $doc-><M::Document.createProcessingInstruction> |
877 |
($name); |
878 |
} |
879 |
} |
880 |
|
881 |
~ (S) { |
882 |
?lexmode 'PIData'; |
883 |
|
884 |
my $tdata; |
885 |
|
886 |
~? (DATA) { |
887 |
lang:Perl ($data => $token.value) { |
888 |
$tdata = $data; |
889 |
} |
890 |
} else { |
891 |
lang:Perl { |
892 |
$tdata = ''; |
893 |
} |
894 |
} |
895 |
|
896 |
lang:Perl { |
897 |
$pi-><AS::Node.nodeValue> ($tdata); |
898 |
} |
899 |
} |
900 |
|
901 |
lang:Perl { |
902 |
$doctype-><M::Node.appendChild> ($pi); |
903 |
} |
904 |
|
905 |
~ (PIC) { |
906 |
?lexmode DTD; |
907 |
} else { |
908 |
?lexmode DTD; |
909 |
} |
910 |
} // _ProcessingInstructionDTD |
911 |
|
912 |
/* |
913 |
Element content parsing mode |
914 |
|
915 |
element := EmptyElemTag / |
916 |
STag content ETag ;; [39] |
917 |
content := (CharData / element / Reference / CDSect / |
918 |
PI / Comment) ;; [43] |
919 |
*/ |
920 |
rule Element_ ($doc, $parent, $ns) : standalone { |
921 |
?lexmode 'ElementContent'; |
922 |
|
923 |
my $node; // Current "parent" node |
924 |
my $nodes; // Node stack (w/o $current_node) |
925 |
my $type; // Current "parent" element type QName |
926 |
my $types; // Element type stack (w/o $current_type) |
927 |
//my $ns; // Current in-scope namespace bindings |
928 |
my $nses; // Namespace binding stack (w/o $current_ns) |
929 |
|
930 |
lang:Perl { |
931 |
$node = $parent; |
932 |
$nodes = []; |
933 |
$type = ''; |
934 |
$types = []; |
935 |
$ns ||= { |
936 |
xml => <Q::xml:>, |
937 |
xmlns => <Q::xmlns:>, |
938 |
}; |
939 |
$nses = []; |
940 |
} |
941 |
|
942 |
~* : name => CONTENT |
943 |
(CharData) { |
944 |
// Character data |
945 |
lang:Perl ($data => $token.value) { |
946 |
$node-><M::Node.appendChild> |
947 |
($doc-><M::Document.createTextNode> ($data)); |
948 |
} |
949 |
} (STAGO) { |
950 |
// Start tag or empty element tag |
951 |
|
952 |
?lexmode 'StartTag'; |
953 |
|
954 |
~ (Name) { |
955 |
my $attrs; |
956 |
lang:Perl ($name => $token.value) { |
957 |
push @{$types}, $type; |
958 |
$type = $name; |
959 |
$attrs = {}; |
960 |
} |
961 |
|
962 |
~? (S) { |
963 |
&AttributeSpecificationList |
964 |
($doc => $doc, $attrs => $attrs); |
965 |
} |
966 |
|
967 |
my $el; |
968 |
|
969 |
lang:Perl { |
970 |
push @{$nses}, $ns; |
971 |
$ns = {%$ns}; |
972 |
|
973 |
my %gattr; |
974 |
my %lattr; |
975 |
for my $atqname (keys %$attrs) { |
976 |
my ($pfx, $lname) = split /:/, $atqname; |
977 |
if (defined $lname) { ## Global attribute |
978 |
## TODO: Namespace well-formedness (lname is NCName) |
979 |
if ($pfx eq 'xmlns') { |
980 |
my $nsuri = $attrs->{$atqname}->{value}; |
981 |
if ($lname eq 'xml' and |
982 |
$nsuri ne <Q::xml:>) { |
983 |
## TODO: error |
984 |
} elsif ($lname eq 'xmlns') { |
985 |
## TODO: error |
986 |
} |
987 |
if ($nsuri eq '') { |
988 |
## TODO: error in XML 1.0 |
989 |
} elsif ($nsuri eq <Q::xml:> and |
990 |
$lname ne 'xml') { |
991 |
## TODO: error |
992 |
} elsif ($nsuri eq <Q::xmlns:>) { |
993 |
## TODO: error |
994 |
} |
995 |
$ns->{$lname} = $attrs->{$atqname}->{value}; |
996 |
delete $ns->{$lname} unless length $ns->{$lname}; |
997 |
} elsif ($pfx eq '') { |
998 |
## TODO: pfx is not NCName error |
999 |
} else { |
1000 |
if ($gattr{$pfx}->{$lname}) { |
1001 |
## TODO: Namespace well-formedness error |
1002 |
} |
1003 |
} |
1004 |
$gattr{$pfx}->{$lname} = $attrs->{$atqname}; |
1005 |
} else { ## Local attribute |
1006 |
if ($pfx eq 'xmlns') { |
1007 |
$ns->{''} = $attrs->{xmlns}->{value}; |
1008 |
delete $ns->{''} unless length $ns->{''}; |
1009 |
} else { |
1010 |
$lattr{$pfx} = $attrs->{$atqname}; |
1011 |
} |
1012 |
} |
1013 |
} |
1014 |
|
1015 |
my ($pfx, $lname) = split /:/, $type; |
1016 |
my $nsuri; |
1017 |
## TODO: lname is NCName? |
1018 |
if (defined $lname) { ## Prefixed namespace |
1019 |
if ($pfx eq '') { |
1020 |
## TODO: pfx is not NCName error |
1021 |
} |
1022 |
if (defined $ns->{$pfx}) { |
1023 |
$nsuri = $ns->{$pfx}; |
1024 |
} else { |
1025 |
## TODO: namespace ill-formed |
1026 |
} |
1027 |
} else { ## Default namespace |
1028 |
$nsuri = $ns->{''}; |
1029 |
} |
1030 |
|
1031 |
$el = $doc-><M::Document.createElementNS> |
1032 |
($nsuri, $type); |
1033 |
|
1034 |
if ($attrs->{xmlns}) { |
1035 |
my $attr = $doc-><M::Document.createAttributeNS> |
1036 |
(<Q::xmlns:>, 'xmlns'); |
1037 |
for (@{$attrs->{xmlns}->{nodes}}) { |
1038 |
$attr-><M::Node.appendChild> ($_); |
1039 |
} |
1040 |
$el-><M::Element.setAttributeNodeNS> ($attr); |
1041 |
} |
1042 |
|
1043 |
for my $lname (keys %lattr) { |
1044 |
my $attr = $doc-><M::Document.createAttributeNS> |
1045 |
(null, $lname); |
1046 |
for (@{$lattr{$lname}->{nodes}}) { |
1047 |
$attr-><M::Node.appendChild> ($_); |
1048 |
} |
1049 |
$el-><M::Element.setAttributeNodeNS> ($attr); |
1050 |
} |
1051 |
|
1052 |
for my $pfx (keys %gattr) { |
1053 |
for my $lname (keys %{$gattr{$pfx}}) { |
1054 |
my $attr = $doc-><M::Document.createAttributeNS> |
1055 |
($ns->{$pfx}, $pfx.':'.$lname); |
1056 |
for (@{$gattr{$pfx}->{$lname}->{nodes}}) { |
1057 |
$attr-><M::Node.appendChild> ($_); |
1058 |
} |
1059 |
$el-><M::Element.setAttributeNodeNS> ($attr); |
1060 |
} |
1061 |
} |
1062 |
|
1063 |
$node-><M::Node.appendChild> ($el); |
1064 |
} |
1065 |
|
1066 |
~ (TAGC) { |
1067 |
lang:Perl { |
1068 |
push @{$nodes}, $node; |
1069 |
$node = $el; |
1070 |
} |
1071 |
?lexmode ElementContent; |
1072 |
} (NESTC) { |
1073 |
my $is_docel; |
1074 |
lang:Perl { |
1075 |
$ns = pop @{$nses}; |
1076 |
$type = pop @{$types}; |
1077 |
$is_docel = (@{$types} == 0); |
1078 |
} |
1079 |
|
1080 |
if-true ($is_docel) { |
1081 |
return; |
1082 |
} |
1083 |
|
1084 |
~ (TAGC) { |
1085 |
?lexmode ElementContent; |
1086 |
} else { |
1087 |
?lexmode ElementContent; |
1088 |
} |
1089 |
} else { |
1090 |
?lexmode ElementContent; |
1091 |
} |
1092 |
} else { |
1093 |
?lexmode ElementContent; |
1094 |
} |
1095 |
|
1096 |
} (ETAGO) { |
1097 |
// End tag |
1098 |
|
1099 |
?lexmode 'EndTag'; |
1100 |
|
1101 |
my $is_docel; |
1102 |
|
1103 |
~ (Name) { |
1104 |
lang:Perl ($name => $token.value) : has-error { |
1105 |
if ($name eq $type) { |
1106 |
$type = pop @{$types}; |
1107 |
if ($type eq '') { |
1108 |
$is_docel = true; |
1109 |
} |
1110 |
$node = pop @{$nodes}; |
1111 |
$ns = pop @{$nses}; |
1112 |
} else { |
1113 |
my $location; |
1114 |
__CODE{xp|get-location-from-token:: |
1115 |
$token => $token, |
1116 |
$result => $location, |
1117 |
}__; |
1118 |
my $continue = __DOMCore:ERROR{xp|wf-element-type-match:: |
1119 |
DOMCore:location => {$location}, |
1120 |
xp|token => {$token}, |
1121 |
xp|expected-element-type => {$type}, |
1122 |
xp|actual-element-type => {$name}, |
1123 |
xp|node => {$node}, |
1124 |
}__; |
1125 |
unless ($continue) { |
1126 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1127 |
} |
1128 |
$self->{has_error} = true; |
1129 |
} |
1130 |
} |
1131 |
} |
1132 |
|
1133 |
~? (S) { } |
1134 |
|
1135 |
if-true ($is_docel) { |
1136 |
lang:Perl : has-error { |
1137 |
if (@{$types}) { |
1138 |
my $location; |
1139 |
__CODE{xp|get-location-from-token:: |
1140 |
$token => $token, |
1141 |
$result => $location, |
1142 |
}__; |
1143 |
for my $type (reverse @{$types}) { |
1144 |
my $continue = __DOMCore:ERROR{xp|wf-no-end-tag:: |
1145 |
DOMCore:location => {$location}, |
1146 |
xp|token => {$token}, |
1147 |
xp|expected-element-type => {$type}, |
1148 |
xp|node => {$node}, |
1149 |
}__; |
1150 |
unless ($continue) { |
1151 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1152 |
} |
1153 |
$node = shift @{$nodes}; |
1154 |
} |
1155 |
$self->{has_error} = true; |
1156 |
} |
1157 |
} |
1158 |
return; |
1159 |
} |
1160 |
|
1161 |
~ (TAGC) { |
1162 |
?lexmode ElementContent; |
1163 |
} else { |
1164 |
?lexmode 'ElementContent'; |
1165 |
} |
1166 |
|
1167 |
} (HCRO) { |
1168 |
&_HexadecimalCharacterReference_ |
1169 |
($doc => $doc, $parent => $node); |
1170 |
|
1171 |
~ (REFC) { |
1172 |
?lexmode 'ElementContent'; |
1173 |
} else { |
1174 |
?lexmode ElementContent; |
1175 |
} |
1176 |
} (CRO) { |
1177 |
&_NumericCharacterReference_ |
1178 |
($doc => $doc, $parent => $node); |
1179 |
|
1180 |
~ (REFC) { |
1181 |
?lexmode 'ElementContent'; |
1182 |
} else { |
1183 |
?lexmode ElementContent; |
1184 |
} |
1185 |
} (ERO) { |
1186 |
&_GeneralEntityReferenceEC |
1187 |
($doc => $doc, $parent => $node, $ns => $ns); |
1188 |
} (CDO) { |
1189 |
&_CommentDeclaration_ ($doc => $doc, $parent => $node); |
1190 |
|
1191 |
~ (MDC) { |
1192 |
?lexmode ElementContent; |
1193 |
} else { |
1194 |
?lexmode ElementContent; |
1195 |
} |
1196 |
} (CDSO) { |
1197 |
&_CDATASection_ ($doc => $doc, $parent => $node); |
1198 |
|
1199 |
~ (MSE) { |
1200 |
?lexmode 'ElementContent'; |
1201 |
} else { |
1202 |
?lexmode ElementContent; |
1203 |
} |
1204 |
} (PIO) { |
1205 |
&_ProcessingInstruction_ ($doc => $doc, $parent => $node); |
1206 |
|
1207 |
~ (PIC) { |
1208 |
?lexmode 'ElementContent'; |
1209 |
} else { |
1210 |
?lexmode ElementContent; |
1211 |
} |
1212 |
} |
1213 |
|
1214 |
~ (#NONE) { } |
1215 |
} // Element_ |
1216 |
|
1217 |
rule AttributeSpecificationList ($doc, $attrs) |
1218 |
: standalone |
1219 |
{ |
1220 |
?lexmode 'StartTag'; |
1221 |
|
1222 |
my $i; |
1223 |
lang:Perl { |
1224 |
$i = 0; |
1225 |
} |
1226 |
|
1227 |
~* (Name) { |
1228 |
my $atqname; |
1229 |
lang:Perl ($name => $token.value) { |
1230 |
$atqname = $name; |
1231 |
} |
1232 |
|
1233 |
my $vals; |
1234 |
lang:Perl { |
1235 |
if ($attrs->{$atqname}) { |
1236 |
my $location; |
1237 |
__CODE{xp|get-location-from-token:: |
1238 |
$token => $token, |
1239 |
$result => $location, |
1240 |
}__; |
1241 |
my $continue = __DOMCore:ERROR{xp|wf-unique-att-spec:: |
1242 |
DOMCore:location => {$location}, |
1243 |
xp|token => {$token}, |
1244 |
xp|name => {$atqname}, |
1245 |
}__; |
1246 |
unless ($continue) { |
1247 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1248 |
} |
1249 |
$self->{has_error} = true; |
1250 |
} |
1251 |
|
1252 |
$vals = $attrs->{$atqname} = { |
1253 |
nodes => [], |
1254 |
value => '', |
1255 |
index => $i++, |
1256 |
}; |
1257 |
} |
1258 |
|
1259 |
~? (S) { } |
1260 |
~ (VI) { } |
1261 |
~? (S) { } |
1262 |
|
1263 |
~ (LIT) { |
1264 |
&_AttributeValueSpecification_ |
1265 |
($doc => $doc, $vals => $vals); |
1266 |
|
1267 |
~ (LIT) { |
1268 |
?lexmode StartTag; |
1269 |
} else { |
1270 |
?lexmode StartTag; |
1271 |
} |
1272 |
} (LITA) { |
1273 |
&_AttributeValueSpecificationA_ |
1274 |
($doc => $doc, $vals => $vals); |
1275 |
|
1276 |
~ (LITA) { |
1277 |
?lexmode StartTag; |
1278 |
} else { |
1279 |
?lexmode StartTag; |
1280 |
} |
1281 |
} |
1282 |
} (S) : separator : terminator? { } |
1283 |
} // AttributeSpecificationList |
1284 |
|
1285 |
rule _AttributeValueSpecification_ ($doc, $vals) { |
1286 |
// ~ (LIT) { } |
1287 |
?lexmode 'AttributeValueLiteral'; |
1288 |
|
1289 |
~* (STRING) { |
1290 |
lang:Perl ($value => $token.value) { |
1291 |
$value =~ s/[\x09\x0A\x0D]/ /g; |
1292 |
my $text = $doc-><M::Document.createTextNode> ($value); |
1293 |
push @{$vals->{nodes}}, $text; |
1294 |
$vals->{value} .= $value; |
1295 |
} |
1296 |
} (HCRO) { |
1297 |
&_HexadecimalCharacterReferenceV_ |
1298 |
($doc => $doc, $vals => $vals); |
1299 |
|
1300 |
~ (REFC) { |
1301 |
?lexmode AttributeValueLiteral; |
1302 |
} else { |
1303 |
?lexmode AttributeValueLiteral; |
1304 |
} |
1305 |
} (CRO) { |
1306 |
&_NumericCharacterReferenceV_ |
1307 |
($doc => $doc, $vals => $vals); |
1308 |
|
1309 |
~ (REFC) { |
1310 |
?lexmode AttributeValueLiteral; |
1311 |
} else { |
1312 |
?lexmode AttributeValueLiteral; |
1313 |
} |
1314 |
} (ERO) { |
1315 |
// TODO: Attribute value normalization |
1316 |
&_GeneralEntityReferenceV_ |
1317 |
($doc => $doc, $vals => $vals); |
1318 |
|
1319 |
~ (REFC) { |
1320 |
?lexmode AttributeValueLiteral; |
1321 |
} else { |
1322 |
?lexmode AttributeValueLiteral; |
1323 |
} |
1324 |
} |
1325 |
|
1326 |
// ~ (LIT) { } (LITA) { } |
1327 |
} // _AttributeValueSpecification_ |
1328 |
|
1329 |
rule _AttributeValueSpecificationA_ ($doc, $vals) { |
1330 |
// ~ (LITA) { } |
1331 |
?lexmode 'AttributeValueLiteralA'; |
1332 |
|
1333 |
~* (STRING) { |
1334 |
lang:Perl ($value => $token.value) { |
1335 |
$value =~ s/[\x09\x0A\x0D]/ /g; |
1336 |
my $text = $doc-><M::Document.createTextNode> ($value); |
1337 |
push @{$vals->{nodes}}, $text; |
1338 |
$vals->{value} .= $value; |
1339 |
} |
1340 |
} (HCRO) { |
1341 |
&_HexadecimalCharacterReferenceV_ |
1342 |
($doc => $doc, $vals => $vals); |
1343 |
|
1344 |
~ (REFC) { |
1345 |
?lexmode AttributeValueLiteralA; |
1346 |
} else { |
1347 |
?lexmode AttributeValueLiteralA; |
1348 |
} |
1349 |
} (CRO) { |
1350 |
&_NumericCharacterReferenceV_ |
1351 |
($doc => $doc, $vals => $vals); |
1352 |
|
1353 |
~ (REFC) { |
1354 |
?lexmode AttributeValueLiteralA; |
1355 |
} else { |
1356 |
?lexmode AttributeValueLiteralA; |
1357 |
} |
1358 |
} (ERO) { |
1359 |
// TODO: Attribute value normalization |
1360 |
&_GeneralEntityReferenceV_ |
1361 |
($doc => $doc, $vals => $vals); |
1362 |
|
1363 |
~ (REFC) { |
1364 |
?lexmode AttributeValueLiteralA; |
1365 |
} else { |
1366 |
?lexmode AttributeValueLiteralA; |
1367 |
} |
1368 |
} |
1369 |
|
1370 |
// ~ (LITA) { } |
1371 |
} // _AttributeValueSpecificationA_ |
1372 |
|
1373 |
/* |
1374 |
CDATA Section Content Parsing Mode |
1375 |
*/ |
1376 |
rule _CDATASection_ ($doc, $parent) { |
1377 |
?lexmode 'CDATASectionContent'; |
1378 |
|
1379 |
my $cdata; |
1380 |
|
1381 |
~? (CData) { |
1382 |
lang:Perl ($data => $token.value) { |
1383 |
$cdata = $data; |
1384 |
} |
1385 |
} else { |
1386 |
lang:Perl { |
1387 |
$cdata = ''; |
1388 |
} |
1389 |
} |
1390 |
|
1391 |
lang:Perl { |
1392 |
my $cdsect = $doc-><M::Document.createCDATASection> |
1393 |
($cdata); |
1394 |
$parent-><M::Node.appendChild> ($cdsect); |
1395 |
} |
1396 |
|
1397 |
// ~ (MSE) { } |
1398 |
} // _CDATASection_ |
1399 |
|
1400 |
rule _NumericCharacterReference_ ($doc, $parent) { |
1401 |
?lexmode 'NumericCharacterReference'; |
1402 |
|
1403 |
~ (NUMBER) { |
1404 |
lang:Perl ($num => $token.value) : has-error { |
1405 |
$num += 0; |
1406 |
unless ( |
1407 |
($self->{xml_version} eq '1.0' and |
1408 |
((0x0020 <= $num and $num <= 0xD7FF) or |
1409 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1410 |
(0x10000 <= $num and $num <= 0x10FFFF) or |
1411 |
$num == 0x9 or $num == 0xA or $num == 0xD)) or |
1412 |
($self->{xml_version} eq '1.1' and |
1413 |
((0x0001 <= $num and $num <= 0xD7FF) or |
1414 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1415 |
(0x10000 <= $num and $num <= 0x10FFFF))) |
1416 |
) { |
1417 |
my $location; |
1418 |
__CODE{xp|get-location-from-token:: |
1419 |
$token => $token, |
1420 |
$result => $location, |
1421 |
}__; |
1422 |
my $continue = __DOMCore:ERROR{xp|wf-legal-character:: |
1423 |
DOMCore:location => {$location}, |
1424 |
xp|token => {$token}, |
1425 |
xp|character-number => {$num}, |
1426 |
xp|parent => {$parent}, |
1427 |
}__; |
1428 |
unless ($continue) { |
1429 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1430 |
} |
1431 |
$self->{has_error} = true; |
1432 |
} |
1433 |
my $ncr = $doc-><M::Document.createTextNode> (chr $num); |
1434 |
$parent-><M::Node.appendChild> ($ncr); |
1435 |
} |
1436 |
} |
1437 |
|
1438 |
// ~ (REFC) { } |
1439 |
} // _NumericCharacterReference_ |
1440 |
|
1441 |
rule _NumericCharacterReferenceV_ ($doc, $vals) { |
1442 |
?lexmode 'NumericCharacterReference'; |
1443 |
|
1444 |
~ (NUMBER) { |
1445 |
lang:Perl ($num => $token.value) : has-error { |
1446 |
$num += 0; |
1447 |
unless ( |
1448 |
($self->{xml_version} eq '1.0' and |
1449 |
((0x0020 <= $num and $num <= 0xD7FF) or |
1450 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1451 |
(0x10000 <= $num and $num <= 0x10FFFF) or |
1452 |
$num == 0x9 or $num == 0xA or $num == 0xD)) or |
1453 |
($self->{xml_version} eq '1.1' and |
1454 |
((0x0001 <= $num and $num <= 0xD7FF) or |
1455 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1456 |
(0x10000 <= $num and $num <= 0x10FFFF))) |
1457 |
) { |
1458 |
my $location; |
1459 |
__CODE{xp|get-location-from-token:: |
1460 |
$token => $token, |
1461 |
$result => $location, |
1462 |
}__; |
1463 |
my $continue = __DOMCore:ERROR{xp|wf-legal-character:: |
1464 |
DOMCore:location => {$location}, |
1465 |
xp|token => {$token}, |
1466 |
xp|character-number => {$num}, |
1467 |
}__; |
1468 |
unless ($continue) { |
1469 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1470 |
} |
1471 |
$self->{has_error} = true; |
1472 |
} |
1473 |
my $ncr = $doc-><M::Document.createTextNode> |
1474 |
(my $char = chr (0+$num)); |
1475 |
push @{$vals->{nodes}}, $ncr; |
1476 |
$vals->{value} .= $char; |
1477 |
} |
1478 |
} |
1479 |
|
1480 |
// ~ (REFC) { } |
1481 |
} // _NumericCharacterReferenceV_ |
1482 |
|
1483 |
rule _HexadecimalCharacterReference_ ($doc, $parent) { |
1484 |
?lexmode 'HexadecimalCharacterReference'; |
1485 |
|
1486 |
~ (Hex) { |
1487 |
lang:Perl ($num => $token.value) : has-error { |
1488 |
$num += 0; |
1489 |
unless ( |
1490 |
($self->{xml_version} eq '1.0' and |
1491 |
((0x0020 <= $num and $num <= 0xD7FF) or |
1492 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1493 |
(0x10000 <= $num and $num <= 0x10FFFF) or |
1494 |
$num == 0x9 or $num == 0xA or $num == 0xD)) or |
1495 |
($self->{xml_version} eq '1.1' and |
1496 |
((0x0001 <= $num and $num <= 0xD7FF) or |
1497 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1498 |
(0x10000 <= $num and $num <= 0x10FFFF))) |
1499 |
) { |
1500 |
my $location; |
1501 |
__CODE{xp|get-location-from-token:: |
1502 |
$token => $token, |
1503 |
$result => $location, |
1504 |
}__; |
1505 |
my $continue = __DOMCore:ERROR{xp|wf-legal-character:: |
1506 |
DOMCore:location => {$location}, |
1507 |
xp|token => {$token}, |
1508 |
xp|character-number => {$num}, |
1509 |
xp|parent => {$parent}, |
1510 |
}__; |
1511 |
unless ($continue) { |
1512 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1513 |
} |
1514 |
$self->{has_error} = true; |
1515 |
} |
1516 |
my $ncr = $doc-><M::Document.createTextNode> |
1517 |
(chr hex $num); |
1518 |
$parent-><M::Node.appendChild> ($ncr); |
1519 |
} |
1520 |
} |
1521 |
|
1522 |
// ~ (REFC) { } |
1523 |
} // _HexadecimalCharacterReference_ |
1524 |
|
1525 |
rule _HexadecimalCharacterReferenceV_ ($doc, $vals) { |
1526 |
?lexmode 'HexadecimalCharacterReference'; |
1527 |
|
1528 |
~ (Hex) { |
1529 |
lang:Perl ($num => $token.value) : has-error { |
1530 |
$num += 0; |
1531 |
unless ( |
1532 |
($self->{xml_version} eq '1.0' and |
1533 |
((0x0020 <= $num and $num <= 0xD7FF) or |
1534 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1535 |
(0x10000 <= $num and $num <= 0x10FFFF) or |
1536 |
$num == 0x9 or $num == 0xA or $num == 0xD)) or |
1537 |
($self->{xml_version} eq '1.1' and |
1538 |
((0x0001 <= $num and $num <= 0xD7FF) or |
1539 |
(0xE000 <= $num and $num <= 0xFFFD) or |
1540 |
(0x10000 <= $num and $num <= 0x10FFFF))) |
1541 |
) { |
1542 |
my $location; |
1543 |
__CODE{xp|get-location-from-token:: |
1544 |
$token => $token, |
1545 |
$result => $location, |
1546 |
}__; |
1547 |
my $continue = __DOMCore:ERROR{xp|wf-legal-character:: |
1548 |
DOMCore:location => {$location}, |
1549 |
xp|token => {$token}, |
1550 |
xp|character-number => {$num}, |
1551 |
}__; |
1552 |
unless ($continue) { |
1553 |
__EXCEPTION{DOMLS|PARSE_ERR}__; |
1554 |
} |
1555 |
$self->{has_error} = true; |
1556 |
} |
1557 |
my $ncr = $doc-><M::Document.createTextNode> |
1558 |
(my $char = chr hex $num); |
1559 |
push @{$vals->{nodes}}, $ncr; |
1560 |
$vals->{value} .= $char; |
1561 |
} |
1562 |
} |
1563 |
|
1564 |
// ~ (REFC) { } |
1565 |
} // _HexadecimalCharacterReferenceV_ |
1566 |
|
1567 |
/* |
1568 |
General entity reference in element's content |
1569 |
*/ |
1570 |
rule _GeneralEntityReferenceEC ($doc, $parent, $ns) |
1571 |
: recursive |
1572 |
{ |
1573 |
?lexmode 'EntityReference'; |
1574 |
|
1575 |
~ (Name) { |
1576 |
my $er; |
1577 |
lang:Perl ($name => $token.value) { |
1578 |
## TODO: Namespace well-formedness |
1579 |
## TODO: Entity declared constraints |
1580 |
$er = $doc-><M::Document.createEntityReference> |
1581 |
($name); |
1582 |
$parent-><M::Node.appendChild> ($er); |
1583 |
push @{$self->{entity}}, <Code::getCopyOfEntityState:: |
1584 |
$entity_type = 'general_entity', |
1585 |
$entity_name = $name>; |
1586 |
push @{$self->{entity_token}}, $self->{token}; |
1587 |
$self->{token} = []; |
1588 |
push @{$self->{entity_char}}, $self->{char}; |
1589 |
$self->{char} = []; |
1590 |
} |
1591 |
|
1592 |
?lexmode ElementContent; |
1593 |
~* (CharData) { |
1594 |
lang:Perl ($data => $token.value) { |
1595 |
$er-><M::Node.appendChild> |
1596 |
($doc-><M::Document.createTextNode> ($data)); |
1597 |
} |
1598 |
} (STAGO) { |
1599 |
&Element_ ($doc => $doc, $parent => $er, $ns => $ns) |
1600 |
: unshift-current-token; |
1601 |
~ (TAGC) { |
1602 |
?lexmode ElementContent; |
1603 |
} else { |
1604 |
?lexmode ElementContent; |
1605 |
} |
1606 |
} (HCRO) { |
1607 |
&_HexadecimalCharacterReference_ |
1608 |
($doc => $doc, $parent => $er); |
1609 |
|
1610 |
~ (REFC) { |
1611 |
?lexmode 'ElementContent'; |
1612 |
} else { |
1613 |
?lexmode ElementContent; |
1614 |
} |
1615 |
} (CRO) { |
1616 |
&_NumericCharacterReference_ |
1617 |
($doc => $doc, $parent => $er); |
1618 |
|
1619 |
~ (REFC) { |
1620 |
?lexmode 'ElementContent'; |
1621 |
} else { |
1622 |
?lexmode ElementContent; |
1623 |
} |
1624 |
} (ERO) { |
1625 |
&_GeneralEntityReferenceEC |
1626 |
($doc => $doc, $parent => $er, $ns => $ns); |
1627 |
} (CDO) { |
1628 |
&_CommentDeclaration_ ($doc => $doc, $parent => $er); |
1629 |
|
1630 |
~ (MDC) { |
1631 |
?lexmode ElementContent; |
1632 |
} else { |
1633 |
?lexmode ElementContent; |
1634 |
} |
1635 |
} (CDSO) { |
1636 |
&_CDATASection_ ($doc => $doc, $parent => $er); |
1637 |
|
1638 |
~ (MSE) { |
1639 |
?lexmode 'ElementContent'; |
1640 |
} else { |
1641 |
?lexmode ElementContent; |
1642 |
} |
1643 |
} (PIO) { |
1644 |
&_ProcessingInstruction_ ($doc => $doc, $parent => $er); |
1645 |
|
1646 |
~ (PIC) { |
1647 |
?lexmode 'ElementContent'; |
1648 |
} else { |
1649 |
?lexmode ElementContent; |
1650 |
} |
1651 |
} |
1652 |
|
1653 |
~ (#EOF) { } |
1654 |
lang:Perl { |
1655 |
$self->{token} = pop @{$self->{entity_token}}; |
1656 |
$self->{char} = pop @{$self->{entity_char}}; |
1657 |
pop @{$self->{entity}}; |
1658 |
} |
1659 |
|
1660 |
?lexmode EntityReference; |
1661 |
?requires-next-token; |
1662 |
} |
1663 |
|
1664 |
~ (REFC) { |
1665 |
?lexmode ElementContent; |
1666 |
} else { |
1667 |
?lexmode ElementContent; |
1668 |
} |
1669 |
} // _GeneralEntityReferenceEC |
1670 |
|
1671 |
rule _GeneralEntityReferenceV_ ($doc, $vals) { |
1672 |
// TODO: Expansion |
1673 |
?lexmode 'EntityReference'; |
1674 |
|
1675 |
~ (Name) { |
1676 |
lang:Perl ($name => $token.value) { |
1677 |
## TODO: Namespace well-formedness |
1678 |
## TODO: Entity declared constraints |
1679 |
my $er = $doc-><M::Document.createEntityReference> |
1680 |
($name); |
1681 |
push @{$vals->{nodes}}, $er; |
1682 |
} |
1683 |
} |
1684 |
|
1685 |
// ~ (REFC) { } |
1686 |
} // _GeneralEntityReferenceV_ |
1687 |
|
1688 |
/* |
1689 |
General entity reference in literal entity value |
1690 |
*/ |
1691 |
rule _GeneralEntityReferenceEV_ ($doc, $vals) { |
1692 |
?lexmode 'EntityReference'; |
1693 |
|
1694 |
~ (Name) { |
1695 |
lang:Perl ($name => $token.value) { |
1696 |
## TODO: Namespace well-formedness |
1697 |
## TODO: Entity declared constraints |
1698 |
push @$vals, $name; |
1699 |
} |
1700 |
} |
1701 |
|
1702 |
// ~ (REFC) { } |
1703 |
} // _GeneralEntityReferenceEV_ |
1704 |
|
1705 |
/* |
1706 |
Document Type Declaration |
1707 |
*/ |
1708 |
rule _DocumentTypeDeclaration_ ($doc) { |
1709 |
?lexmode MarkupDeclaration; |
1710 |
|
1711 |
~ (Name == 'DOCTYPE') { } |
1712 |
|
1713 |
~ (S) { } |
1714 |
|
1715 |
my $node; |
1716 |
// Document type name |
1717 |
my $name; |
1718 |
~ (Name) { |
1719 |
lang:Perl ($v => $token.value) { |
1720 |
$name = $v; |
1721 |
} |
1722 |
} |
1723 |
lang:Perl { |
1724 |
$node = $doc-><M::DocumentXDoctype.createDocumentTypeDefinition> ($name); |
1725 |
$doc-><M::Node.appendChild> ($node); |
1726 |
} |
1727 |
|
1728 |
~? (S) { |
1729 |
~? (Name == 'PUBLIC') { |
1730 |
~ (S) { } |
1731 |
|
1732 |
&PubidLiteral ($doc => $doc); |
1733 |
|
1734 |
~ (S) { } |
1735 |
|
1736 |
&SystemLiteral ($doc => $doc); |
1737 |
|
1738 |
~? (S) { } |
1739 |
} (Name == 'SYSTEM') { |
1740 |
~ (S) { } |
1741 |
|
1742 |
&SystemLiteral ($doc => $doc); |
1743 |
|
1744 |
~? (S) { } |
1745 |
} |
1746 |
} |
1747 |
|
1748 |
~? (DSO) { |
1749 |
&InternalSubset ($doc => $doc, $doctype => $node); |
1750 |
|
1751 |
~ (DSC) { |
1752 |
?lexmode MarkupDeclaration; |
1753 |
} else { |
1754 |
?lexmode MarkupDeclaration; |
1755 |
} |
1756 |
|
1757 |
~? (S) { } |
1758 |
} |
1759 |
|
1760 |
// TODO: set $self->{standalone} true if only internal subset |
1761 |
// with no param ref |
1762 |
|
1763 |
// ~ (MDC) { } |
1764 |
} // _DocumentTypeDeclaration_ |
1765 |
|
1766 |
rule PubidLiteral ($doc) { |
1767 |
~ (LIT) { |
1768 |
?lexmode SystemLiteral; |
1769 |
|
1770 |
~? (STRING) { |
1771 |
// TODO: Charrange check & normalization is required |
1772 |
|
1773 |
} |
1774 |
|
1775 |
~ (LIT) { |
1776 |
?lexmode MarkupDeclaration; |
1777 |
} else { |
1778 |
?lexmode MarkupDeclaration; |
1779 |
} |
1780 |
} (LITA) { |
1781 |
?lexmode SystemLiteralA; |
1782 |
|
1783 |
~? (STRING) { |
1784 |
// TODO: Charrange check & normalization is required |
1785 |
|
1786 |
} |
1787 |
|
1788 |
~ (LITA) { |
1789 |
?lexmode MarkupDeclaration; |
1790 |
} else { |
1791 |
?lexmode MarkupDeclaration; |
1792 |
} |
1793 |
} |
1794 |
} // PubidLiteral |
1795 |
|
1796 |
rule SystemLiteral ($doc) { |
1797 |
~ (LIT) { |
1798 |
?lexmode SystemLiteral; |
1799 |
&_SystemLiteral ($doc => $doc); |
1800 |
} (LITA) { |
1801 |
?lexmode SystemLiteralA; |
1802 |
&_SystemLiteral ($doc => $doc); |
1803 |
} |
1804 |
} // SystemLiteral |
1805 |
|
1806 |
rule _SystemLiteral ($doc) { |
1807 |
~? (STRING) { |
1808 |
|
1809 |
} |
1810 |
|
1811 |
~ (LIT) { |
1812 |
?lexmode MarkupDeclaration; |
1813 |
} (LITA) { |
1814 |
?lexmode MarkupDeclaration; |
1815 |
} else { |
1816 |
?lexmode MarkupDeclaration; |
1817 |
} |
1818 |
} // _SystemLiteral |
1819 |
|
1820 |
/* |
1821 |
DTD Internal Subset |
1822 |
|
1823 |
intSubset := *(markupdecl / DeclSep) ;; [28b] |
1824 |
*/ |
1825 |
rule InternalSubset ($doc, $doctype) { |
1826 |
?lexmode DTD; |
1827 |
|
1828 |
~* (MDO) { |
1829 |
?lexmode MarkupDeclaration; |
1830 |
|
1831 |
~ (Name == 'ELEMENT') { |
1832 |
&_ElementDeclaration ($doc => $doc); |
1833 |
} (Name == 'ATTLIST') { |
1834 |
&_AttlistDeclaration ($doc => $doc); |
1835 |
} (Name == 'ENTITY') { |
1836 |
&_EntityDeclaration ($doc => $doc); |
1837 |
} (Name == 'NOTATION') { |
1838 |
&_NotationDeclaration ($doc => $doc); |
1839 |
} |
1840 |
} (S) { |
1841 |
// |
1842 |
} (CDO) { |
1843 |
&_CommentDeclarationDTD ($doc => $doc); |
1844 |
} (PIO) { |
1845 |
&_ProcessingInstructionDTD ($doc => $doc, $doctype => $doctype); |
1846 |
} (PERO) { |
1847 |
?lexmode EntityReference; |
1848 |
|
1849 |
~ (Name) { |
1850 |
|
1851 |
} |
1852 |
|
1853 |
~ (REFC) { |
1854 |
?lexmode DTD; |
1855 |
} else { |
1856 |
?lexmode DTD; |
1857 |
} |
1858 |
} |
1859 |
} // InternalSubset |
1860 |
|
1861 |
rule _ElementDeclaration ($doc) { |
1862 |
// ~ (MDO) { } |
1863 |
// ?lexmode MarkupDeclaration |
1864 |
// ~ (Name == 'Element') { } |
1865 |
|
1866 |
~ (S) { } |
1867 |
|
1868 |
~ (Name) { |
1869 |
|
1870 |
} |
1871 |
|
1872 |
?lexmode ElementDeclaration; |
1873 |
|
1874 |
~ (S) { } |
1875 |
|
1876 |
// contentspec |
1877 |
~ (MGO) { |
1878 |
&_ContentModel ($doc => $doc); |
1879 |
} (Name == 'EMPTY') { |
1880 |
|
1881 |
} (Name == 'ANY') { |
1882 |
|
1883 |
} |
1884 |
|
1885 |
~? (S) { } |
1886 |
|
1887 |
~ (MDC) { |
1888 |
?lexmode DTD; |
1889 |
} else { |
1890 |
?lexmode DTD; |
1891 |
} |
1892 |
} // _ElementDeclaration |
1893 |
|
1894 |
rule _ContentModel ($doc) { |
1895 |
// ~ (MGO) { } |
1896 |
|
1897 |
~? (S) { } |
1898 |
|
1899 |
~ (Name) { |
1900 |
// Element content model |
1901 |
&_ModelGroup ($doc => $doc) |
1902 |
: unshift-current-token; |
1903 |
|
1904 |
~? (OPT) { |
1905 |
|
1906 |
} (REP) { |
1907 |
|
1908 |
} (PLUS) { |
1909 |
|
1910 |
} |
1911 |
|
1912 |
} (MDO) { |
1913 |
&_ModelGroup ($doc => $doc) |
1914 |
: unshift-current-token; |
1915 |
|
1916 |
~? (OPT) { |
1917 |
|
1918 |
} (REP) { |
1919 |
|
1920 |
} (PLUS) { |
1921 |
|
1922 |
} |
1923 |
|
1924 |
} (PCDATA) { |
1925 |
// Mixed content declaration |
1926 |
~? (S) { } |
1927 |
|
1928 |
~* (OR) { |
1929 |
~? (S) { } |
1930 |
|
1931 |
~ (Name) { |
1932 |
|
1933 |
} |
1934 |
|
1935 |
~? (S) { } |
1936 |
} |
1937 |
|
1938 |
~ (MGC) { } |
1939 |
|
1940 |
~? (REP) { |
1941 |
|
1942 |
} else { |
1943 |
// TODO: error if |Name| |
1944 |
} |
1945 |
|
1946 |
|
1947 |
} |
1948 |
} // _ContentModel |
1949 |
|
1950 |
rule _ModelGroup ($doc) |
1951 |
: standalone |
1952 |
: recursive |
1953 |
{ |
1954 |
// ~ (MGO) { } |
1955 |
// ~? (S) { } |
1956 |
|
1957 |
&ContentParticle ($doc => $doc); |
1958 |
|
1959 |
~? (S) { } |
1960 |
|
1961 |
~? (OR) { |
1962 |
~? (S) { } |
1963 |
|
1964 |
&ContentParticle ($doc => $doc); |
1965 |
|
1966 |
~? (S) { } |
1967 |
|
1968 |
~* (OR) { |
1969 |
~? (S) { } |
1970 |
|
1971 |
&ContentParticle ($doc => $doc); |
1972 |
|
1973 |
~? (S) { } |
1974 |
} |
1975 |
|
1976 |
} (SEQ) { |
1977 |
~? (S) { } |
1978 |
|
1979 |
&ContentParticle ($doc => $doc); |
1980 |
|
1981 |
~? (S) { } |
1982 |
|
1983 |
~* (SEQ) { |
1984 |
~? (S) { } |
1985 |
|
1986 |
&ContentParticle ($doc => $doc); |
1987 |
|
1988 |
~? (S) { } |
1989 |
} |
1990 |
|
1991 |
} |
1992 |
|
1993 |
~ (MGC) { } |
1994 |
} // _ModelGroup |
1995 |
|
1996 |
rule ContentParticle ($doc) { |
1997 |
~ (Name) { |
1998 |
|
1999 |
} (MGO) { |
2000 |
~? (S) { } |
2001 |
|
2002 |
&_ModelGroup ($doc => $doc); |
2003 |
} |
2004 |
|
2005 |
~? (OPT) { |
2006 |
|
2007 |
} (REP) { |
2008 |
|
2009 |
} (PLUS) { |
2010 |
|
2011 |
} |
2012 |
} // ContentParticle |
2013 |
|
2014 |
rule _AttlistDeclaration ($doc) { |
2015 |
// ~ (MDO) { } |
2016 |
// ~ (Name == 'ATTLIST') { } |
2017 |
|
2018 |
?lexmode AttlistDeclaration; |
2019 |
|
2020 |
~ (S) { } |
2021 |
|
2022 |
~ (Name) { |
2023 |
|
2024 |
} |
2025 |
|
2026 |
~? (S) { } |
2027 |
|
2028 |
~* (Name) { |
2029 |
|
2030 |
~ (S) { } |
2031 |
|
2032 |
// AttType |
2033 |
~ (Name == 'NOTATION') { |
2034 |
~ (S) { } |
2035 |
|
2036 |
~ (EGO) { |
2037 |
~? (S) { } |
2038 |
|
2039 |
~ (Name) { |
2040 |
|
2041 |
~? (S) { } |
2042 |
} (OR) : separator { |
2043 |
~? (S) { } |
2044 |
} |
2045 |
|
2046 |
~ (EGC) { } |
2047 |
} |
2048 |
} (Name) { |
2049 |
// TODO: check keyword |
2050 |
|
2051 |
} (EGO) { |
2052 |
?lexmode Enumeration; |
2053 |
|
2054 |
~? (S) { } |
2055 |
|
2056 |
~ (Nmtoken) { |
2057 |
|
2058 |
~? (S) { } |
2059 |
} (OR) : separator { |
2060 |
~? (S) { } |
2061 |
} |
2062 |
|
2063 |
~ (EGC) { |
2064 |
?lexmode AttlistDeclaration; |
2065 |
} else { |
2066 |
?lexmode AttlistDeclaration; |
2067 |
} |
2068 |
|
2069 |
} |
2070 |
|
2071 |
~ (S) { } |
2072 |
|
2073 |
// DefaultDecl |
2074 |
~ (RNI) { |
2075 |
~ (Name == 'REQUIRED') { |
2076 |
|
2077 |
} (Name == 'IMPLIED') { |
2078 |
|
2079 |
} (Name == 'FIXED') { |
2080 |
~ (S) { } |
2081 |
|
2082 |
~ (LIT) { |
2083 |
my $vals; |
2084 |
lang:Perl { |
2085 |
$vals = []; |
2086 |
} |
2087 |
|
2088 |
&_AttributeValueSpecification_ ($doc => $doc, $vals => $vals); |
2089 |
|
2090 |
~ (LIT) { |
2091 |
?lexmode AttlistDeclaration; |
2092 |
} else { |
2093 |
?lexmode AttlistDeclaration; |
2094 |
} |
2095 |
} (LITA) { |
2096 |
my $vals; |
2097 |
lang:Perl { |
2098 |
$vals = []; |
2099 |
} |
2100 |
|
2101 |
&_AttributeValueSpecificationA_ ($doc => $doc, $vals => $vals); |
2102 |
|
2103 |
~ (LIT) { |
2104 |
?lexmode AttlistDeclaration; |
2105 |
} else { |
2106 |
?lexmode AttlistDeclaration; |
2107 |
} |
2108 |
} |
2109 |
} |
2110 |
|
2111 |
} (LIT) { |
2112 |
my $vals; |
2113 |
lang:Perl { |
2114 |
$vals = []; |
2115 |
} |
2116 |
|
2117 |
&_AttributeValueSpecification_ ($doc => $doc, $vals => $vals); |
2118 |
|
2119 |
~ (LIT) { |
2120 |
?lexmode AttlistDeclaration; |
2121 |
} else { |
2122 |
?lexmode AttlistDeclaration; |
2123 |
} |
2124 |
} (LITA) { |
2125 |
my $vals; |
2126 |
lang:Perl { |
2127 |
$vals = []; |
2128 |
} |
2129 |
|
2130 |
&_AttributeValueSpecificationA_ ($doc => $doc, $vals => $vals); |
2131 |
|
2132 |
~ (LITA) { |
2133 |
?lexmode AttlistDeclaration; |
2134 |
} else { |
2135 |
?lexmode AttlistDeclaration; |
2136 |
} |
2137 |
} |
2138 |
|
2139 |
} (S) : separator : terminator? { |
2140 |
// |
2141 |
} |
2142 |
|
2143 |
~ (MDC) { |
2144 |
?lexmode DTD; |
2145 |
} else { |
2146 |
?lexmode DTD; |
2147 |
} |
2148 |
} // _AttlistDeclaration |
2149 |
|
2150 |
rule _EntityDeclaration ($doc) { |
2151 |
// ~ (MDO) { } |
2152 |
// ~ (Name == ENTITY) { } |
2153 |
|
2154 |
~ (S) { } |
2155 |
|
2156 |
my $decl; |
2157 |
lang:Perl { $decl = {}; } |
2158 |
|
2159 |
~? (PERO) { |
2160 |
~ (S) { } |
2161 |
lang:Perl { |
2162 |
$decl->{is_param_entity} = true; |
2163 |
} |
2164 |
} |
2165 |
|
2166 |
~ (Name) { |
2167 |
lang:Perl ($v => $token.value) { |
2168 |
$decl->{name} = $v; |
2169 |
} |
2170 |
} |
2171 |
|
2172 |
~ (S) { } |
2173 |
|
2174 |
~ (LIT) { |
2175 |
&_EntityValue ($doc => $doc, $decl => $decl); |
2176 |
} (LITA) { |
2177 |
&_EntityValueA ($doc => $doc, $decl => $decl); |
2178 |
} (Name == 'PUBLIC') { |
2179 |
~ (S) { } |
2180 |
|
2181 |
&PubidLiteral ($doc => $doc, $decl => $decl); |
2182 |
|
2183 |
~ (S) { } |
2184 |
|
2185 |
&SystemLiteral ($doc => $doc, $decl => $decl); |
2186 |
} (Name == 'SYSTEM') { |
2187 |
~ (S) { } |
2188 |
|
2189 |
&SystemLiteral ($doc => $doc, $decl => $decl); |
2190 |
} |
2191 |
|
2192 |
~? (S) { |
2193 |
~? (Name == 'NDATA') { |
2194 |
// TODO: error if parameter entity |
2195 |
|
2196 |
~ (S) { } |
2197 |
|
2198 |
~ (Name) { |
2199 |
lang:Perl ($v => $token.value) { |
2200 |
$decl->{notation} = $v; |
2201 |
} |
2202 |
} |
2203 |
|
2204 |
~? (S) { } |
2205 |
} |
2206 |
} |
2207 |
|
2208 |
lang:Perl { |
2209 |
if ($self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'} |
2210 |
->{$decl->{name}}) { |
2211 |
## TODO: error |
2212 |
} else { |
2213 |
$self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'} |
2214 |
->{$decl->{name}} = $decl; |
2215 |
} |
2216 |
} |
2217 |
|
2218 |
~ (MDC) { |
2219 |
?lexmode DTD; |
2220 |
} else { |
2221 |
?lexmode DTD; |
2222 |
} |
2223 |
} // _EntityDeclaration |
2224 |
|
2225 |
rule _NotationDeclaration ($doc) { |
2226 |
// ~ (MDO) { } |
2227 |
// ~ (Name == NOTATION) { } |
2228 |
|
2229 |
~ (S) { } |
2230 |
|
2231 |
~ (Name) { |
2232 |
|
2233 |
} |
2234 |
|
2235 |
~ (S) { } |
2236 |
|
2237 |
~ (Name == 'PUBLIC') { |
2238 |
~ (S) { } |
2239 |
|
2240 |
&PubidLiteral ($doc => $doc); |
2241 |
|
2242 |
~? (S) { |
2243 |
~? (LIT) { |
2244 |
?lexmode SystemLiteral; |
2245 |
&_SystemLiteral ($doc => $doc); |
2246 |
|
2247 |
~? (S) { } |
2248 |
} (LITA) { |
2249 |
?lexmode SystemLiteralA; |
2250 |
&_SystemLiteral ($doc => $doc); |
2251 |
|
2252 |
~? (S) { } |
2253 |
} |
2254 |
} |
2255 |
} (Name == 'SYSTEM') { |
2256 |
~ (S) { } |
2257 |
|
2258 |
&SystemLiteral ($doc => $doc); |
2259 |
|
2260 |
~? (S) { } |
2261 |
} |
2262 |
|
2263 |
~ (MDC) { |
2264 |
?lexmode DTD; |
2265 |
} else { |
2266 |
?lexmode DTD; |
2267 |
} |
2268 |
} // _NotationDeclaration |
2269 |
|
2270 |
rule _EntityValue ($doc, $decl) { |
2271 |
?lexmode EntityValue; |
2272 |
|
2273 |
my $vals; |
2274 |
my $reptxt; |
2275 |
lang:Perl { |
2276 |
$vals = []; |
2277 |
$reptxt = ''; |
2278 |
} |
2279 |
|
2280 |
~* (STRING) { |
2281 |
lang:Perl ($v => $token.value) { |
2282 |
$reptxt .= $v; |
2283 |
} |
2284 |
} (PERO) { |
2285 |
?lexmode EntityDeclaration; |
2286 |
|
2287 |
// TODO: Expand or wferror if internal subset |
2288 |
|
2289 |
~ (Name) { |
2290 |
|
2291 |
} |
2292 |
|
2293 |
~ (REFC) { |
2294 |
?lexmode EntityValue; |
2295 |
} else { |
2296 |
?lexmode EntityValue; |
2297 |
} |
2298 |
} (HCRO) { |
2299 |
&_HexadecimalCharacterReferenceV_ |
2300 |
($doc => $doc, $vals => $vals); |
2301 |
|
2302 |
lang:Perl { |
2303 |
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2304 |
$vals = []; |
2305 |
} |
2306 |
|
2307 |
~ (REFC) { |
2308 |
?lexmode EntityValue; |
2309 |
} else { |
2310 |
?lexmode EntityValue; |
2311 |
} |
2312 |
} (CRO) { |
2313 |
&_NumericCharacterReferenceV_ |
2314 |
($doc => $doc, $vals => $vals); |
2315 |
|
2316 |
lang:Perl { |
2317 |
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2318 |
$vals = []; |
2319 |
} |
2320 |
|
2321 |
~ (REFC) { |
2322 |
?lexmode EntityValue; |
2323 |
} else { |
2324 |
?lexmode EntityValue; |
2325 |
} |
2326 |
} (ERO) { |
2327 |
&_GeneralEntityReferenceEV_ |
2328 |
($doc => $doc, $vals => $vals); |
2329 |
|
2330 |
lang:Perl { |
2331 |
$reptxt .= '&' . $vals->[0] . ';'; |
2332 |
$vals = []; |
2333 |
} |
2334 |
|
2335 |
~ (REFC) { |
2336 |
?lexmode EntityValue; |
2337 |
} else { |
2338 |
?lexmode EntityValue; |
2339 |
} |
2340 |
} |
2341 |
|
2342 |
~ (LIT) { |
2343 |
?lexmode MarkupDeclaration; |
2344 |
} (LITA) { |
2345 |
?lexmode MarkupDeclaration; |
2346 |
} else { |
2347 |
?lexmode MarkupDeclaration; |
2348 |
} |
2349 |
|
2350 |
lang:Perl { |
2351 |
$decl->{reptxt} = \$reptxt; |
2352 |
} |
2353 |
} // _EntityValue |
2354 |
|
2355 |
rule _EntityValueA ($doc, $decl) { |
2356 |
?lexmode EntityValueA; |
2357 |
|
2358 |
my $vals; |
2359 |
my $reptxt; |
2360 |
lang:Perl { |
2361 |
$vals = []; |
2362 |
$reptxt = ''; |
2363 |
} |
2364 |
|
2365 |
~* (STRING) { |
2366 |
lang:Perl ($v => $token.value) { |
2367 |
$reptxt .= $v; |
2368 |
} |
2369 |
} (PERO) { |
2370 |
?lexmode EntityDeclaration; |
2371 |
|
2372 |
// TODO: implement this |
2373 |
~ (Name) { |
2374 |
|
2375 |
} |
2376 |
|
2377 |
~ (REFC) { |
2378 |
?lexmode EntityValueA; |
2379 |
} else { |
2380 |
?lexmode EntityValueA; |
2381 |
} |
2382 |
} (HCRO) { |
2383 |
&_HexadecimalCharacterReferenceV_ |
2384 |
($doc => $doc, $vals => $vals); |
2385 |
|
2386 |
lang:Perl { |
2387 |
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2388 |
$vals = []; |
2389 |
} |
2390 |
|
2391 |
|
2392 |
~ (REFC) { |
2393 |
?lexmode EntityValueA; |
2394 |
} else { |
2395 |
?lexmode EntityValueA; |
2396 |
} |
2397 |
} (CRO) { |
2398 |
&_NumericCharacterReferenceV_ |
2399 |
($doc => $doc, $vals => $vals); |
2400 |
|
2401 |
lang:Perl { |
2402 |
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2403 |
$vals = []; |
2404 |
} |
2405 |
|
2406 |
~ (REFC) { |
2407 |
?lexmode EntityValueA; |
2408 |
} else { |
2409 |
?lexmode EntityValueA; |
2410 |
} |
2411 |
} (ERO) { |
2412 |
&_GeneralEntityReferenceEV_ |
2413 |
($doc => $doc, $vals => $vals); |
2414 |
|
2415 |
lang:Perl { |
2416 |
$reptxt .= '&' . $vals->[0] . ';'; |
2417 |
$vals = []; |
2418 |
} |
2419 |
|
2420 |
~ (REFC) { |
2421 |
?lexmode EntityValueA; |
2422 |
} else { |
2423 |
?lexmode EntityValueA; |
2424 |
} |
2425 |
} |
2426 |
|
2427 |
~ (LITA) { |
2428 |
?lexmode MarkupDeclaration; |
2429 |
} else { |
2430 |
?lexmode MarkupDeclaration; |
2431 |
} |
2432 |
|
2433 |
lang:Perl { |
2434 |
$decl->{reptxt} = \$reptxt; |
2435 |
} |
2436 |
} // _EntityValueA |
2437 |
|
2438 |
|
2439 |
/* |
2440 |
XML Name |
2441 |
*/ |
2442 |
lexmode NameChar { |
2443 |
$NameStartChar10 := [ |
2444 |
'_' ':' |
2445 |
// Letter |
2446 |
// BaseChar |
2447 |
U+0041..U+005A U+0061..U+007A U+00C0..U+00D6 |
2448 |
U+00D8..U+00F6 U+00F8..U+00FF U+0100..U+0131 |
2449 |
U+0134..U+013E U+0141..U+0148 U+014A..U+017E |
2450 |
U+0180..U+01C3 U+01CD..U+01F0 U+01F4..U+01F5 |
2451 |
U+01FA..U+0217 U+0250..U+02A8 U+02BB..U+02C1 |
2452 |
U+0386 U+0388..U+038A U+038C U+038E..U+03A1 |
2453 |
U+03A3..U+03CE U+03D0..U+03D6 U+03DA U+03DC |
2454 |
U+03DE U+03E0 U+03E2..U+03F3 U+0401..U+040C |
2455 |
U+040E..U+044F U+0451..U+045C U+045E..U+0481 |
2456 |
U+0490..U+04C4 U+04C7..U+04C8 U+04CB..U+04CC |
2457 |
U+04D0..U+04EB U+04EE..U+04F5 U+04F8..U+04F9 |
2458 |
U+0531..U+0556 U+0559 U+0561..U+0586 |
2459 |
U+05D0..U+05EA U+05F0..U+05F2 U+0621..U+063A |
2460 |
U+0641..U+064A U+0671..U+06B7 U+06BA..U+06BE |
2461 |
U+06C0..U+06CE U+06D0..U+06D3 U+06D5 |
2462 |
U+06E5..U+06E6 U+0905..U+0939 U+093D |
2463 |
U+0958..U+0961 U+0985..U+098C U+098F..U+0990 |
2464 |
U+0993..U+09A8 U+09AA..U+09B0 U+09B2 |
2465 |
U+09B6..U+09B9 U+09DC..U+09DD U+09DF..U+09E1 |
2466 |
U+09F0..U+09F1 U+0A05..U+0A0A U+0A0F..U+0A10 |
2467 |
U+0A13..U+0A28 U+0A2A..U+0A30 U+0A32..U+0A33 |
2468 |
U+0A35..U+0A36 U+0A38..U+0A39 U+0A59..U+0A5C |
2469 |
U+0A5E U+0A72..U+0A74 U+0A85..U+0A8B U+0A8D |
2470 |
U+0A8F..U+0A91 U+0A93..U+0AA8 U+0AAA..U+0AB0 |
2471 |
U+0AB2..U+0AB3 U+0AB5..U+0AB9 U+0ABD U+0AE0 |
2472 |
U+0B05..U+0B0C U+0B0F..U+0B10 U+0B13..U+0B28 |
2473 |
U+0B2A..U+0B30 U+0B32..U+0B33 U+0B36..U+0B39 |
2474 |
U+0B3D U+0B5C..U+0B5D U+0B5F..U+0B61 |
2475 |
U+0B85..U+0B8A U+0B8E..U+0B90 U+0B92..U+0B95 |
2476 |
U+0B99..U+0B9A U+0B9C U+0B9E..U+0B9F |
2477 |
U+0BA3..U+0BA4 U+0BA8..U+0BAA U+0BAE..U+0BB5 |
2478 |
U+0BB7..U+0BB9 U+0C05..U+0C0C U+0C0E..U+0C10 |
2479 |
U+0C12..U+0C28 U+0C2A..U+0C33 U+0C35..U+0C39 |
2480 |
U+0C60..U+0C61 U+0C85..U+0C8C U+0C8E..U+0C90 |
2481 |
U+0C92..U+0CA8 U+0CAA..U+0CB3 U+0CB5..U+0CB9 |
2482 |
U+0CDE U+0CE0..U+0CE1 U+0D05..U+0D0C |
2483 |
U+0D0E..U+0D10 U+0D12..U+0D28 U+0D2A..U+0D39 |
2484 |
U+0D60..U+0D61 U+0E01..U+0E2E U+0E30 |
2485 |
U+0E32..U+0E33 U+0E40..U+0E45 U+0E81..U+0E82 |
2486 |
U+0E84 U+0E87..U+0E88 U+0E8A U+0E8D |
2487 |
U+0E94..U+0E97 U+0E99..U+0E9F U+0EA1..U+0EA3 |
2488 |
U+0EA5 U+0EA7 U+0EAA..U+0EAB U+0EAD..U+0EAE |
2489 |
U+0EB0 U+0EB2..U+0EB3 U+0EBD U+0EC0..U+0EC4 |
2490 |
U+0F40..U+0F47 U+0F49..U+0F69 U+10A0..U+10C5 |
2491 |
U+10D0..U+10F6 U+1100 U+1102..U+1103 |
2492 |
U+1105..U+1107 U+1109 U+110B..U+110C |
2493 |
U+110E..U+1112 U+113C U+113E U+1140 U+114C |
2494 |
U+114E U+1150 U+1154..U+1155 U+1159 |
2495 |
U+115F..U+1161 U+1163 U+1165 U+1167 U+1169 |
2496 |
U+116D..U+116E U+1172..U+1173 U+1175 U+119E |
2497 |
U+11A8 U+11AB U+11AE..U+11AF U+11B7..U+11B8 |
2498 |
U+11BA U+11BC..U+11C2 U+11EB U+11F0 U+11F9 |
2499 |
U+1E00..U+1E9B U+1EA0..U+1EF9 U+1F00..U+1F15 |
2500 |
U+1F18..U+1F1D U+1F20..U+1F45 U+1F48..U+1F4D |
2501 |
U+1F50..U+1F57 U+1F59 U+1F5B U+1F5D |
2502 |
U+1F5F..U+1F7D U+1F80..U+1FB4 U+1FB6..U+1FBC |
2503 |
U+1FBE U+1FC2..U+1FC4 U+1FC6..U+1FCC |
2504 |
U+1FD0..U+1FD3 U+1FD6..U+1FDB U+1FE0..U+1FEC |
2505 |
U+1FF2..U+1FF4 U+1FF6..U+1FFC U+2126 |
2506 |
U+212A..U+212B U+212E U+2180..U+2182 |
2507 |
U+3041..U+3094 U+30A1..U+30FA U+3105..U+312C |
2508 |
U+AC00..U+D7A3 |
2509 |
// Ideographic |
2510 |
U+4E00..U+9FA5 U+3007 U+3021..U+3029 |
2511 |
]; |
2512 |
$NameChar10 := [ |
2513 |
'.' '-' '_' ':' |
2514 |
// Letter |
2515 |
// BaseChar |
2516 |
U+0041..U+005A U+0061..U+007A U+00C0..U+00D6 |
2517 |
U+00D8..U+00F6 U+00F8..U+00FF U+0100..U+0131 |
2518 |
U+0134..U+013E U+0141..U+0148 U+014A..U+017E |
2519 |
U+0180..U+01C3 U+01CD..U+01F0 U+01F4..U+01F5 |
2520 |
U+01FA..U+0217 U+0250..U+02A8 U+02BB..U+02C1 |
2521 |
U+0386 U+0388..U+038A U+038C U+038E..U+03A1 |
2522 |
U+03A3..U+03CE U+03D0..U+03D6 U+03DA U+03DC |
2523 |
U+03DE U+03E0 U+03E2..U+03F3 U+0401..U+040C |
2524 |
U+040E..U+044F U+0451..U+045C U+045E..U+0481 |
2525 |
U+0490..U+04C4 U+04C7..U+04C8 U+04CB..U+04CC |
2526 |
U+04D0..U+04EB U+04EE..U+04F5 U+04F8..U+04F9 |
2527 |
U+0531..U+0556 U+0559 U+0561..U+0586 |
2528 |
U+05D0..U+05EA U+05F0..U+05F2 U+0621..U+063A |
2529 |
U+0641..U+064A U+0671..U+06B7 U+06BA..U+06BE |
2530 |
U+06C0..U+06CE U+06D0..U+06D3 U+06D5 |
2531 |
U+06E5..U+06E6 U+0905..U+0939 U+093D |
2532 |
U+0958..U+0961 U+0985..U+098C U+098F..U+0990 |
2533 |
U+0993..U+09A8 U+09AA..U+09B0 U+09B2 |
2534 |
U+09B6..U+09B9 U+09DC..U+09DD U+09DF..U+09E1 |
2535 |
U+09F0..U+09F1 U+0A05..U+0A0A U+0A0F..U+0A10 |
2536 |
U+0A13..U+0A28 U+0A2A..U+0A30 U+0A32..U+0A33 |
2537 |
U+0A35..U+0A36 U+0A38..U+0A39 U+0A59..U+0A5C |
2538 |
U+0A5E U+0A72..U+0A74 U+0A85..U+0A8B U+0A8D |
2539 |
U+0A8F..U+0A91 U+0A93..U+0AA8 U+0AAA..U+0AB0 |
2540 |
U+0AB2..U+0AB3 U+0AB5..U+0AB9 U+0ABD U+0AE0 |
2541 |
U+0B05..U+0B0C U+0B0F..U+0B10 U+0B13..U+0B28 |
2542 |
U+0B2A..U+0B30 U+0B32..U+0B33 U+0B36..U+0B39 |
2543 |
U+0B3D U+0B5C..U+0B5D U+0B5F..U+0B61 |
2544 |
U+0B85..U+0B8A U+0B8E..U+0B90 U+0B92..U+0B95 |
2545 |
U+0B99..U+0B9A U+0B9C U+0B9E..U+0B9F |
2546 |
U+0BA3..U+0BA4 U+0BA8..U+0BAA U+0BAE..U+0BB5 |
2547 |
U+0BB7..U+0BB9 U+0C05..U+0C0C U+0C0E..U+0C10 |
2548 |
U+0C12..U+0C28 U+0C2A..U+0C33 U+0C35..U+0C39 |
2549 |
U+0C60..U+0C61 U+0C85..U+0C8C U+0C8E..U+0C90 |
2550 |
U+0C92..U+0CA8 U+0CAA..U+0CB3 U+0CB5..U+0CB9 |
2551 |
U+0CDE U+0CE0..U+0CE1 U+0D05..U+0D0C |
2552 |
U+0D0E..U+0D10 U+0D12..U+0D28 U+0D2A..U+0D39 |
2553 |
U+0D60..U+0D61 U+0E01..U+0E2E U+0E30 |
2554 |
U+0E32..U+0E33 U+0E40..U+0E45 U+0E81..U+0E82 |
2555 |
U+0E84 U+0E87..U+0E88 U+0E8A U+0E8D |
2556 |
U+0E94..U+0E97 U+0E99..U+0E9F U+0EA1..U+0EA3 |
2557 |
U+0EA5 U+0EA7 U+0EAA..U+0EAB U+0EAD..U+0EAE |
2558 |
U+0EB0 U+0EB2..U+0EB3 U+0EBD U+0EC0..U+0EC4 |
2559 |
U+0F40..U+0F47 U+0F49..U+0F69 U+10A0..U+10C5 |
2560 |
U+10D0..U+10F6 U+1100 U+1102..U+1103 |
2561 |
U+1105..U+1107 U+1109 U+110B..U+110C |
2562 |
U+110E..U+1112 U+113C U+113E U+1140 U+114C |
2563 |
U+114E U+1150 U+1154..U+1155 U+1159 |
2564 |
U+115F..U+1161 U+1163 U+1165 U+1167 U+1169 |
2565 |
U+116D..U+116E U+1172..U+1173 U+1175 U+119E |
2566 |
U+11A8 U+11AB U+11AE..U+11AF U+11B7..U+11B8 |
2567 |
U+11BA U+11BC..U+11C2 U+11EB U+11F0 U+11F9 |
2568 |
U+1E00..U+1E9B U+1EA0..U+1EF9 U+1F00..U+1F15 |
2569 |
U+1F18..U+1F1D U+1F20..U+1F45 U+1F48..U+1F4D |
2570 |
U+1F50..U+1F57 U+1F59 U+1F5B U+1F5D |
2571 |
U+1F5F..U+1F7D U+1F80..U+1FB4 U+1FB6..U+1FBC |
2572 |
U+1FBE U+1FC2..U+1FC4 U+1FC6..U+1FCC |
2573 |
U+1FD0..U+1FD3 U+1FD6..U+1FDB U+1FE0..U+1FEC |
2574 |
U+1FF2..U+1FF4 U+1FF6..U+1FFC U+2126 |
2575 |
U+212A..U+212B U+212E U+2180..U+2182 |
2576 |
U+3041..U+3094 U+30A1..U+30FA U+3105..U+312C |
2577 |
U+AC00..U+D7A3 |
2578 |
// Ideographic |
2579 |
U+4E00..U+9FA5 U+3007 U+3021..U+3029 |
2580 |
// Digit |
2581 |
U+0030..U+0039 U+0660..U+0669 U+06F0..U+06F9 |
2582 |
U+0966..U+096F U+09E6..U+09EF U+0A66..U+0A6F |
2583 |
U+0AE6..U+0AEF U+0B66..U+0B6F U+0BE7..U+0BEF |
2584 |
U+0C66..U+0C6F U+0CE6..U+0CEF U+0D66..U+0D6F |
2585 |
U+0E50..U+0E59 U+0ED0..U+0ED9 U+0F20..U+0F29 |
2586 |
// CombiningChar |
2587 |
U+0300..U+0345 U+0360..U+0361 U+0483..U+0486 |
2588 |
U+0591..U+05A1 U+05A3..U+05B9 U+05BB..U+05BD |
2589 |
U+05BF U+05C1..U+05C2 U+05C4 U+064B..U+0652 |
2590 |
U+0670 U+06D6..U+06DC U+06DD..U+06DF |
2591 |
U+06E0..U+06E4 U+06E7..U+06E8 U+06EA..U+06ED |
2592 |
U+0901..U+0903 U+093C U+093E..U+094C U+094D |
2593 |
U+0951..U+0954 U+0962..U+0963 U+0981..U+0983 |
2594 |
U+09BC U+09BE U+09BF U+09C0..U+09C4 |
2595 |
U+09C7..U+09C8 U+09CB..U+09CD U+09D7 |
2596 |
U+09E2..U+09E3 U+0A02 U+0A3C U+0A3E U+0A3F |
2597 |
U+0A40..U+0A42 U+0A47..U+0A48 U+0A4B..U+0A4D |
2598 |
U+0A70..U+0A71 U+0A81..U+0A83 U+0ABC |
2599 |
U+0ABE..U+0AC5 U+0AC7..U+0AC9 U+0ACB..U+0ACD |
2600 |
U+0B01..U+0B03 U+0B3C U+0B3E..U+0B43 |
2601 |
U+0B47..U+0B48 U+0B4B..U+0B4D U+0B56..U+0B57 |
2602 |
U+0B82..U+0B83 U+0BBE..U+0BC2 U+0BC6..U+0BC8 |
2603 |
U+0BCA..U+0BCD U+0BD7 U+0C01..U+0C03 |
2604 |
U+0C3E..U+0C44 U+0C46..U+0C48 U+0C4A..U+0C4D |
2605 |
U+0C55..U+0C56 U+0C82..U+0C83 U+0CBE..U+0CC4 |
2606 |
U+0CC6..U+0CC8 U+0CCA..U+0CCD U+0CD5..U+0CD6 |
2607 |
U+0D02..U+0D03 U+0D3E..U+0D43 U+0D46..U+0D48 |
2608 |
U+0D4A..U+0D4D U+0D57 U+0E31 U+0E34..U+0E3A |
2609 |
U+0E47..U+0E4E U+0EB1 U+0EB4..U+0EB9 |
2610 |
U+0EBB..U+0EBC U+0EC8..U+0ECD U+0F18..U+0F19 |
2611 |
U+0F35 U+0F37 U+0F39 U+0F3E U+0F3F |
2612 |
U+0F71..U+0F84 U+0F86..U+0F8B U+0F90..U+0F95 |
2613 |
U+0F97 U+0F99..U+0FAD U+0FB1..U+0FB7 U+0FB9 |
2614 |
U+20D0..U+20DC U+20E1 U+302A..U+302F U+3099 |
2615 |
U+309A |
2616 |
// Extender |
2617 |
U+00B7 U+02D0 U+02D1 U+0387 U+0640 U+0E46 |
2618 |
U+0EC6 U+3005 U+3031..U+3035 U+309D..U+309E |
2619 |
U+30FC..U+30FE |
2620 |
]; |
2621 |
|
2622 |
$NameStartChar11 := [ |
2623 |
':' '_' |
2624 |
'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' |
2625 |
'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' |
2626 |
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' |
2627 |
'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' |
2628 |
U+00C0..U+00D6 U+00D8..U+00F6 U+00F8..U+02FF |
2629 |
U+0370..U+037D U+037F..U+1FFF U+200C..U+200D |
2630 |
U+2070..U+218F U+2C00..U+2FEF U+3001..U+D7FF |
2631 |
U+F900..U+FDCF U+FDF0..U+FFFD U+10000..U+EFFFF |
2632 |
]; |
2633 |
$NameChar11 := [ |
2634 |
'-' '.' '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' |
2635 |
U+00B7 U+0300..U+036F U+203F..U+2040 |
2636 |
// NameStartChar |
2637 |
':' '_' |
2638 |
'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' |
2639 |
'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' |
2640 |
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' |
2641 |
'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' |
2642 |
U+00C0..U+00D6 U+00D8..U+00F6 U+00F8..U+02FF |
2643 |
U+0370..U+037D U+037F..U+1FFF U+200C..U+200D |
2644 |
U+2070..U+218F U+2C00..U+2FEF U+3001..U+D7FF |
2645 |
U+F900..U+FDCF U+FDF0..U+FFFD U+10000..U+EFFFF |
2646 |
]; |
2647 |
} // NameChar |
2648 |
|
2649 |
lexmode Name |
2650 |
: extends => 'NameChar' |
2651 |
{ |
2652 |
Name : value := $NameStartChar11 $NameChar11*; |
2653 |
} // Name |
2654 |
|
2655 |
lexmode Nmtoken |
2656 |
: extends => 'NameChar' |
2657 |
{ |
2658 |
Nmtoken : value := $NameChar11*; |
2659 |
} // Nmtoken |
2660 |
|
2661 |
/* |
2662 |
Space |
2663 |
*/ |
2664 |
lexmode S { |
2665 |
S := [U+0009 U+000A U+000D U+0020]+; |
2666 |
} // S |
2667 |
|
2668 |
/* |
2669 |
Document end scanning mode |
2670 |
*/ |
2671 |
lexmode DocumentEnd |
2672 |
: standalone |
2673 |
: extends => 'S' |
2674 |
{ |
2675 |
/* |
2676 |
Processing instruction |
2677 |
*/ |
2678 |
PIO := ['<'] ['?']; |
2679 |
|
2680 |
/* |
2681 |
Comment declaration |
2682 |
*/ |
2683 |
CDO := ['<'] ['!'] ['-'] ['-']; |
2684 |
} // DocumentEnd |
2685 |
|
2686 |
/* |
2687 |
Document misc scanning mode |
2688 |
|
2689 |
This mode scans |Misc| constructions as well |
2690 |
as document element's start tag. |
2691 |
*/ |
2692 |
lexmode DocumentMisc |
2693 |
: standalone |
2694 |
: extends => 'DocumentEnd' |
2695 |
{ |
2696 |
/* |
2697 |
Document element start tag |
2698 |
*/ |
2699 |
STAGO := ['<']; |
2700 |
} // DocumentMisc |
2701 |
|
2702 |
/* |
2703 |
Document prolog scanning mode |
2704 |
*/ |
2705 |
lexmode DocumentProlog |
2706 |
: standalone |
2707 |
: extends => 'DocumentMisc' |
2708 |
{ |
2709 |
/* |
2710 |
|DOCTYPE| declaration |
2711 |
*/ |
2712 |
MDO := ['<'] ['!']; |
2713 |
} // DocumentProlog |
2714 |
|
2715 |
/* |
2716 |
Document start scanning mode |
2717 |
*/ |
2718 |
lexmode DocumentStart |
2719 |
: initial |
2720 |
: standalone |
2721 |
: extends => 'DocumentProlog' |
2722 |
{ |
2723 |
/* |
2724 |
XML declaration |
2725 |
*/ |
2726 |
XDO := ['<'] ['?'] ['x'] ['m'] ['l']; |
2727 |
} // DocumentStart |
2728 |
|
2729 |
/* |
2730 |
Comment declaration scanning mode |
2731 |
*/ |
2732 |
lexmode CommentDeclaration |
2733 |
: standalone |
2734 |
{ |
2735 |
/* |
2736 |
Comment close |
2737 |
*/ |
2738 |
COM := ['-'] ['-']; |
2739 |
|
2740 |
/* |
2741 |
Comment data |
2742 |
*/ |
2743 |
$string := ['-']? [^'-']; |
2744 |
STRING : value := $string+; |
2745 |
} // CommentDeclaration |
2746 |
|
2747 |
/* |
2748 |
Processing instruction name and |S| scanning mode |
2749 |
*/ |
2750 |
lexmode PIName |
2751 |
: standalone |
2752 |
: extends => 'Name' |
2753 |
: extends => 'S' |
2754 |
{ |
2755 |
/* |
2756 |
Processing instruction close |
2757 |
*/ |
2758 |
PIC := ['?'] ['>']; |
2759 |
} // PIName |
2760 |
|
2761 |
/* |
2762 |
Processing instruction data scanning mode |
2763 |
*/ |
2764 |
lexmode PIData |
2765 |
: standalone |
2766 |
{ |
2767 |
/* |
2768 |
Processing instruction close |
2769 |
*/ |
2770 |
PIC := ['?'] ['>']; |
2771 |
|
2772 |
/* |
2773 |
Processing instruction target data |
2774 |
*/ |
2775 |
?default-token DATA : value; |
2776 |
} // PIData |
2777 |
|
2778 |
/* |
2779 |
Content of element scanning mode |
2780 |
*/ |
2781 |
lexmode ElementContent |
2782 |
: standalone |
2783 |
{ |
2784 |
/* |
2785 |
Start tag open |
2786 |
*/ |
2787 |
STAGO := ['<']; |
2788 |
|
2789 |
/* |
2790 |
End tag open |
2791 |
*/ |
2792 |
ETAGO := ['<'] ['/']; |
2793 |
|
2794 |
/* |
2795 |
Hexadecimal character reference open |
2796 |
*/ |
2797 |
HCRO := ['&'] ['#'] ['x']; |
2798 |
|
2799 |
/* |
2800 |
Numeric character reference open |
2801 |
*/ |
2802 |
CRO := ['&'] ['#']; |
2803 |
|
2804 |
/* |
2805 |
General entity reference open |
2806 |
*/ |
2807 |
ERO := ['&']; |
2808 |
|
2809 |
/* |
2810 |
Comment declaration open |
2811 |
*/ |
2812 |
CDO := ['<'] ['!'] ['-'] ['-']; |
2813 |
|
2814 |
/* |
2815 |
CDATA section open |
2816 |
*/ |
2817 |
CDSO := ['<'] ['!'] ['['] |
2818 |
['C'] ['D'] ['A'] ['T'] ['A'] ['[']; |
2819 |
|
2820 |
/* |
2821 |
Processing instruction open |
2822 |
*/ |
2823 |
PIO := ['<'] ['?']; |
2824 |
|
2825 |
/* |
2826 |
Markup section end |
2827 |
*/ |
2828 |
MSE := [']'] [']'] ['>']; |
2829 |
|
2830 |
/* |
2831 |
Character data |
2832 |
*/ |
2833 |
/* |
2834 |
Character data and/or |MSE| |
2835 |
*/ |
2836 |
?default-token CharData : value; |
2837 |
} // ElementContent |
2838 |
|
2839 |
/* |
2840 |
CDATA section content scanning mode |
2841 |
*/ |
2842 |
lexmode CDATASectionContent |
2843 |
: standalone |
2844 |
{ |
2845 |
/* |
2846 |
Markup section end |
2847 |
*/ |
2848 |
MSE := [']'] [']'] ['>']; |
2849 |
|
2850 |
/* |
2851 |
Character data |
2852 |
*/ |
2853 |
?default-token CData : value; |
2854 |
} // CDATASectionContent |
2855 |
|
2856 |
lexmode EntityReference |
2857 |
: standalone |
2858 |
: extends => 'Name' |
2859 |
{ |
2860 |
/* |
2861 |
Reference close |
2862 |
*/ |
2863 |
REFC := [';']; |
2864 |
} // EntityReference |
2865 |
|
2866 |
lexmode NumericCharacterReference |
2867 |
: standalone |
2868 |
{ |
2869 |
/* |
2870 |
Decimal number |
2871 |
*/ |
2872 |
$digit := ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9']; |
2873 |
NUMBER : value := $digit+; |
2874 |
|
2875 |
/* |
2876 |
Reference close |
2877 |
*/ |
2878 |
REFC := [';']; |
2879 |
} // NumericCharacterReference |
2880 |
|
2881 |
lexmode HexadecimalCharacterReference |
2882 |
: standalone |
2883 |
{ |
2884 |
/* |
2885 |
Hexadecimal number |
2886 |
*/ |
2887 |
$hexdigit := ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9' |
2888 |
'A' 'B' 'C' 'D' 'E' 'F' |
2889 |
'a' 'b' 'c' 'd' 'e' 'f']; |
2890 |
Hex : value := $hexdigit+; |
2891 |
|
2892 |
/* |
2893 |
Reference close |
2894 |
*/ |
2895 |
REFC := [';']; |
2896 |
} // HexadecimalCharacterReference |
2897 |
|
2898 |
lexmode XMLDeclaration |
2899 |
: standalone |
2900 |
: extends => 'Name' |
2901 |
: extends => 'S' |
2902 |
{ |
2903 |
|
2904 |
/* |
2905 |
Value indicator |
2906 |
*/ |
2907 |
VI := ['=']; |
2908 |
|
2909 |
/* |
2910 |
Literal open |
2911 |
*/ |
2912 |
LIT := ['"']; |
2913 |
LITA := [U+0027]; |
2914 |
|
2915 |
/* |
2916 |
Processing instruction close |
2917 |
*/ |
2918 |
PIC := ['?'] ['>']; |
2919 |
} // XMLDeclaration |
2920 |
|
2921 |
lexmode StartTag |
2922 |
: standalone |
2923 |
: extends => 'Name' |
2924 |
: extends => 'S' |
2925 |
{ |
2926 |
|
2927 |
/* |
2928 |
Value indicator |
2929 |
*/ |
2930 |
VI := ['=']; |
2931 |
|
2932 |
/* |
2933 |
Literal open |
2934 |
*/ |
2935 |
LIT := ['"']; |
2936 |
LITA := [U+0027]; |
2937 |
|
2938 |
/* |
2939 |
Tag close |
2940 |
*/ |
2941 |
TAGC := ['>']; |
2942 |
|
2943 |
/* |
2944 |
Null end-tag enabled start-tag close |
2945 |
*/ |
2946 |
NESTC := ['/']; |
2947 |
} // StartTag |
2948 |
|
2949 |
lexmode EndTag |
2950 |
: standalone |
2951 |
: extends => 'Name' |
2952 |
: extends => 'S' |
2953 |
{ |
2954 |
/* |
2955 |
Tag close |
2956 |
*/ |
2957 |
TAGC := ['>']; |
2958 |
} // EndTag |
2959 |
|
2960 |
lexmode AttributeValueLiteral_ { |
2961 |
ERO := ['&']; |
2962 |
CRO := ['&'] ['#']; |
2963 |
HCRO := ['&'] ['#'] ['x']; |
2964 |
} // AttributeValueLiteral_ |
2965 |
|
2966 |
lexmode AttributeValueLiteral |
2967 |
: standalone |
2968 |
: extends => 'AttributeValueLiteral_' |
2969 |
{ |
2970 |
LIT := ['"']; |
2971 |
STRING : value := [^'"' '&' '<']+; |
2972 |
} // AttributeValueLiteral |
2973 |
|
2974 |
lexmode AttributeValueLiteralA |
2975 |
: standalone |
2976 |
: extends => 'AttributeValueLiteral_' |
2977 |
{ |
2978 |
LITA := [U+0027]; |
2979 |
STRING : value := [^U+0027 '&' '<']+; |
2980 |
} // AttributeValueLiteralA |
2981 |
|
2982 |
lexmode EntityValue_ { |
2983 |
PERO := ['%']; |
2984 |
ERO := ['&']; |
2985 |
CRO := ['&'] ['#']; |
2986 |
HCRO := ['&'] ['#'] ['x']; |
2987 |
} // EntityValue_ |
2988 |
|
2989 |
lexmode EntityValue |
2990 |
: standalone |
2991 |
: extends => 'EntityValue_' |
2992 |
{ |
2993 |
LIT := ['"']; |
2994 |
STRING : value := [^'"' '&' '%']+; |
2995 |
} // EntityValue |
2996 |
|
2997 |
lexmode EntityValueA |
2998 |
: standalone |
2999 |
: extends => 'EntityValue_' |
3000 |
{ |
3001 |
LITA := [U+0027]; |
3002 |
STRING : value := [^U+0027 '&' '%']+; |
3003 |
} // EntityValueA |
3004 |
|
3005 |
lexmode SystemLiteral |
3006 |
: standalone |
3007 |
{ |
3008 |
LIT := ['"']; |
3009 |
?default-token STRING : value; |
3010 |
} // SystemLiteral |
3011 |
|
3012 |
lexmode SystemLiteralA |
3013 |
: standalone |
3014 |
{ |
3015 |
LITA := [U+0027]; |
3016 |
?default-token STRING : value; |
3017 |
} // SystemLiteralA |
3018 |
|
3019 |
lexmode DTD |
3020 |
: standalone |
3021 |
: extends => 'S' |
3022 |
{ |
3023 |
/* |
3024 |
Markup declaration open |
3025 |
*/ |
3026 |
MDO := ['<'] ['!']; |
3027 |
|
3028 |
/* |
3029 |
Comment declaration open |
3030 |
*/ |
3031 |
CDO := ['<'] ['!'] ['-'] ['-']; |
3032 |
|
3033 |
/* |
3034 |
Processing instruction open |
3035 |
*/ |
3036 |
PIO := ['<'] ['?']; |
3037 |
|
3038 |
/* |
3039 |
Parameter entity reference open |
3040 |
*/ |
3041 |
PERO := ['%']; |
3042 |
|
3043 |
/* |
3044 |
Declaration subset close |
3045 |
*/ |
3046 |
DSC := [']']; |
3047 |
|
3048 |
/* |
3049 |
Contition section open |
3050 |
*/ |
3051 |
CSO := ['<'] ['!'] ['[']; |
3052 |
} // DTD |
3053 |
|
3054 |
/* |
3055 |
Markup declaration scanning mode |
3056 |
|
3057 |
This mode is used to recognize |MDC| that terminates |
3058 |
a comment declaration as well as the base |lexmode| |
3059 |
for e.g. document type declaration scanning mode. |
3060 |
*/ |
3061 |
lexmode MarkupDeclaration |
3062 |
: standalone |
3063 |
: extends => 'Name' |
3064 |
: extends => 'S' |
3065 |
{ |
3066 |
/* |
3067 |
Markup declaration close |
3068 |
*/ |
3069 |
MDC := ['>']; |
3070 |
|
3071 |
/* |
3072 |
Literal open |
3073 |
*/ |
3074 |
LIT := ['"']; |
3075 |
|
3076 |
/* |
3077 |
Alternative literal open |
3078 |
*/ |
3079 |
LITA := [U+0027]; |
3080 |
|
3081 |
/* |
3082 |
Parameter entity reference open |
3083 |
*/ |
3084 |
PERO := ['%']; |
3085 |
|
3086 |
/* |
3087 |
Declaration subset open |
3088 |
*/ |
3089 |
DSO := ['[']; |
3090 |
} // MarkupDeclaration |
3091 |
|
3092 |
lexmode ElementDeclaration |
3093 |
: standalone |
3094 |
: extends => 'MarkupDeclaration' |
3095 |
{ |
3096 |
/* |
3097 |
Model group open |
3098 |
*/ |
3099 |
MGO := ['(']; |
3100 |
|
3101 |
/* |
3102 |
Model group close |
3103 |
*/ |
3104 |
MGC := [')']; |
3105 |
|
3106 |
/* |
3107 |
Reserved name indicator |
3108 |
*/ |
3109 |
RNI := ['#']; |
3110 |
|
3111 |
/* |
3112 |
Occurence indicators |
3113 |
*/ |
3114 |
OPT := ['?']; |
3115 |
REP := ['*']; |
3116 |
PLUS := ['+']; |
3117 |
|
3118 |
/* |
3119 |
Connectors |
3120 |
*/ |
3121 |
OR := ['|']; |
3122 |
SEQ := [',']; |
3123 |
} // ElementDeclaration |
3124 |
|
3125 |
lexmode AttlistDeclaration |
3126 |
: standalone |
3127 |
: extends => 'MarkupDeclaration' |
3128 |
{ |
3129 |
/* |
3130 |
Enumeration group open |
3131 |
*/ |
3132 |
EGO := ['(']; |
3133 |
|
3134 |
/* |
3135 |
Enumeration group close |
3136 |
*/ |
3137 |
EGC := [')']; |
3138 |
|
3139 |
/* |
3140 |
Enumeration choice delimiter |
3141 |
*/ |
3142 |
OR := ['|']; |
3143 |
|
3144 |
/* |
3145 |
Reserved name indicator |
3146 |
*/ |
3147 |
RNI := ['#']; |
3148 |
} // AttlistDeclaration |
3149 |
|
3150 |
lexmode Enumeration |
3151 |
: standalone |
3152 |
: extends => 'Nmtoken' |
3153 |
: extends => 'S' |
3154 |
{ |
3155 |
/* |
3156 |
Enumeration group close |
3157 |
*/ |
3158 |
EGC := [')']; |
3159 |
|
3160 |
/* |
3161 |
Enumeration choice delimiter |
3162 |
*/ |
3163 |
OR := ['|']; |
3164 |
} // Enumeration |
3165 |
|
3166 |
|
3167 |
token-error default : default { |
3168 |
lang:Perl { |
3169 |
my $location; |
3170 |
__CODE{xp|get-location-from-token:: |
3171 |
$token => {$token}, |
3172 |
$result => {$location}, |
3173 |
}__; |
3174 |
my $continue = __DOMCore:ERROR{xp|wf-syntax-error:: |
3175 |
xp|error-token => {$token}, |
3176 |
DOMCore|location => {$location}, |
3177 |
}__; |
3178 |
unless ($continue) { |
3179 |
__EXCEPTION{DOMLS|PARSE_ERR:: |
3180 |
}__; |
3181 |
} |
3182 |
$self->{has_error} = true; |
3183 |
} |
3184 |
} // default |
3185 |
|
3186 |
@XMLTests: |
3187 |
@@XMLTest: |
3188 |
@@@QName: xp.only.docel.test |
3189 |
@@@DEnt: |
3190 |
@@@@test:value: |
3191 |
<p></p> |
3192 |
@@@test:domTree: |
3193 |
document { |
3194 |
xml-version: '1.0'; |
3195 |
xml-encoding: null; |
3196 |
xml-standalone: false; |
3197 |
element { |
3198 |
namespace-uri: null; |
3199 |
prefix: null; |
3200 |
local-name: 'p'; |
3201 |
text-content: ''; |
3202 |
} |
3203 |
} |
3204 |
@@XMLTest: |
3205 |
@@@QName: xp.only.docel.emptyelemtag.test |
3206 |
@@@DEnt: |
3207 |
@@@@test:value: |
3208 |
<p/> |
3209 |
@@@test:domTree: |
3210 |
document { |
3211 |
xml-version: '1.0'; |
3212 |
xml-encoding: null; |
3213 |
xml-standalone: false; |
3214 |
element { |
3215 |
namespace-uri: null; |
3216 |
prefix: null; |
3217 |
local-name: 'p'; |
3218 |
text-content: ''; |
3219 |
} |
3220 |
} |
3221 |
|
3222 |
@@XMLTest: |
3223 |
@@@QName: xp.doctype.empty.test |
3224 |
@@@DEnt: |
3225 |
@@@@test:value: |
3226 |
<!DOCTYPE a> |
3227 |
<a></a> |
3228 |
@@@test:domTree: |
3229 |
document { |
3230 |
xml-version: '1.0'; |
3231 |
xml-encoding: null; |
3232 |
xml-standalone: false; |
3233 |
document-type { |
3234 |
node-name: 'a'; |
3235 |
} |
3236 |
element { |
3237 |
namespace-uri: null; |
3238 |
prefix: null; |
3239 |
local-name: 'a'; |
3240 |
text-content: ''; |
3241 |
} |
3242 |
} |
3243 |
|
3244 |
@@XMLTest: |
3245 |
@@@QName: xp.doctype.intsubset.empty.test |
3246 |
@@@DEnt: |
3247 |
@@@@test:value: |
3248 |
<!DOCTYPE a [ |
3249 |
|
3250 |
]> |
3251 |
<a></a> |
3252 |
@@@test:domTree: |
3253 |
document { |
3254 |
xml-version: '1.0'; |
3255 |
xml-encoding: null; |
3256 |
xml-standalone: false; |
3257 |
document-type { |
3258 |
node-name: 'a'; |
3259 |
} |
3260 |
element { |
3261 |
namespace-uri: null; |
3262 |
prefix: null; |
3263 |
local-name: 'a'; |
3264 |
text-content: ''; |
3265 |
} |
3266 |
} |
3267 |
|
3268 |
@@XMLTest: |
3269 |
@@@QName: xp.doctype.intsubset.pi.test |
3270 |
@@@DEnt: |
3271 |
@@@@test:value: |
3272 |
<!DOCTYPE a [ |
3273 |
<?pi data ?> |
3274 |
]> |
3275 |
<a></a> |
3276 |
@@@test:domTree: |
3277 |
document { |
3278 |
xml-version: '1.0'; |
3279 |
xml-encoding: null; |
3280 |
xml-standalone: false; |
3281 |
document-type { |
3282 |
node-name: 'a'; |
3283 |
pi { |
3284 |
target: 'pi'; |
3285 |
data: 'data '; |
3286 |
} |
3287 |
} |
3288 |
element { |
3289 |
namespace-uri: null; |
3290 |
prefix: null; |
3291 |
local-name: 'a'; |
3292 |
text-content: ''; |
3293 |
} |
3294 |
} |
3295 |
@@@enImplNote: |
3296 |
A DOM PI node in doctype node is a manakai extension. |
3297 |
|
3298 |
|
3299 |
@@XMLTest: |
3300 |
@@@QName: xp.doctype.intsubset.entity.general.internal.test |
3301 |
@@@DEnt: |
3302 |
@@@@test:value: |
3303 |
<!DOCTYPE a [ |
3304 |
<!ENTITY entity "entity value"> |
3305 |
]> |
3306 |
<a></a> |
3307 |
@@@test:domTree: |
3308 |
document { |
3309 |
xml-version: '1.0'; |
3310 |
xml-encoding: null; |
3311 |
xml-standalone: false; |
3312 |
document-type { |
3313 |
node-name: 'a'; |
3314 |
} |
3315 |
element { |
3316 |
namespace-uri: null; |
3317 |
prefix: null; |
3318 |
local-name: 'a'; |
3319 |
text-content: ''; |
3320 |
} |
3321 |
} |
3322 |
@@XMLTest: |
3323 |
@@@QName: xp.doctype.intsubset.entity.parameter.internal.test |
3324 |
@@@DEnt: |
3325 |
@@@@test:value: |
3326 |
<!DOCTYPE a [ |
3327 |
<!ENTITY % entity "entity value"> |
3328 |
]> |
3329 |
<a></a> |
3330 |
@@@test:domTree: |
3331 |
document { |
3332 |
xml-version: '1.0'; |
3333 |
xml-encoding: null; |
3334 |
xml-standalone: false; |
3335 |
document-type { |
3336 |
node-name: 'a'; |
3337 |
} |
3338 |
element { |
3339 |
namespace-uri: null; |
3340 |
prefix: null; |
3341 |
local-name: 'a'; |
3342 |
text-content: ''; |
3343 |
} |
3344 |
} |
3345 |
|
3346 |
@@XMLTest: |
3347 |
@@@QName: xp.doctype.internal.entity.root.element.text.only.test |
3348 |
@@@DEnt: |
3349 |
@@@@test:value: |
3350 |
<!DOCTYPE a [ |
3351 |
<!ENTITY entity "entity value"> |
3352 |
]> |
3353 |
<a>&entity;</a> |
3354 |
@@@test:domTree: |
3355 |
document { |
3356 |
xml-version: '1.0'; |
3357 |
xml-encoding: null; |
3358 |
xml-standalone: false; |
3359 |
document-type { |
3360 |
node-name: 'a'; |
3361 |
} |
3362 |
element { |
3363 |
namespace-uri: null; |
3364 |
prefix: null; |
3365 |
local-name: 'a'; |
3366 |
general-entity-reference { |
3367 |
node-name: 'entity'; |
3368 |
text { |
3369 |
data: 'entity value'; |
3370 |
} |
3371 |
} |
3372 |
} |
3373 |
} |
3374 |
@@XMLTest: |
3375 |
@@@QName: xp.doctype.internal.entity.root.element.text.mult.test |
3376 |
@@@DEnt: |
3377 |
@@@@test:value: |
3378 |
<!DOCTYPE a [ |
3379 |
<!ENTITY entity "entity value"> |
3380 |
]> |
3381 |
<a>&entity; and &entity;</a> |
3382 |
@@@test:domTree: |
3383 |
document { |
3384 |
xml-version: '1.0'; |
3385 |
xml-encoding: null; |
3386 |
xml-standalone: false; |
3387 |
document-type { |
3388 |
node-name: 'a'; |
3389 |
} |
3390 |
element { |
3391 |
namespace-uri: null; |
3392 |
prefix: null; |
3393 |
local-name: 'a'; |
3394 |
general-entity-reference { |
3395 |
node-name: 'entity'; |
3396 |
text { |
3397 |
data: 'entity value'; |
3398 |
} |
3399 |
} |
3400 |
text { data: ' and '; } |
3401 |
general-entity-reference { |
3402 |
node-name: 'entity'; |
3403 |
text { |
3404 |
data: 'entity value'; |
3405 |
} |
3406 |
} |
3407 |
} |
3408 |
} |
3409 |
@@XMLTest: |
3410 |
@@@QName: xp.doctype.internal.entity.root.element.text.element.test |
3411 |
@@@DEnt: |
3412 |
@@@@test:value: |
3413 |
<!DOCTYPE a [ |
3414 |
<!ENTITY entity "entity <p>value</p> with <e>element</e> "> |
3415 |
]> |
3416 |
<a>&entity;</a> |
3417 |
@@@test:domTree: |
3418 |
document { |
3419 |
xml-version: '1.0'; |
3420 |
xml-encoding: null; |
3421 |
xml-standalone: false; |
3422 |
document-type { |
3423 |
node-name: 'a'; |
3424 |
} |
3425 |
element { |
3426 |
namespace-uri: null; |
3427 |
prefix: null; |
3428 |
local-name: 'a'; |
3429 |
general-entity-reference { |
3430 |
node-name: 'entity'; |
3431 |
text { |
3432 |
data: 'entity '; |
3433 |
} |
3434 |
element { |
3435 |
namespace-uri: null; |
3436 |
prefix: null; |
3437 |
local-name: 'p'; |
3438 |
text { |
3439 |
data: 'value'; |
3440 |
} |
3441 |
} |
3442 |
text { |
3443 |
data: ' with '; |
3444 |
} |
3445 |
element { |
3446 |
namespace-uri: null; |
3447 |
prefix: null; |
3448 |
local-name: 'e'; |
3449 |
text { |
3450 |
data: 'element'; |
3451 |
} |
3452 |
} |
3453 |
text { |
3454 |
data: ' '; |
3455 |
} |
3456 |
} |
3457 |
} |
3458 |
} |
3459 |
@@XMLTest: |
3460 |
@@@QName: xp.doctype.internal.entity.root.element.text.in.ent.test |
3461 |
@@@DEnt: |
3462 |
@@@@test:value: |
3463 |
<!DOCTYPE a [ |
3464 |
<!ENTITY entity1 "entity value"> |
3465 |
<!ENTITY entity2 "e&entity1;n"> |
3466 |
]> |
3467 |
<a>&entity2;</a> |
3468 |
@@@test:domTree: |
3469 |
document { |
3470 |
xml-version: '1.0'; |
3471 |
xml-encoding: null; |
3472 |
xml-standalone: false; |
3473 |
document-type { |
3474 |
node-name: 'a'; |
3475 |
} |
3476 |
element { |
3477 |
namespace-uri: null; |
3478 |
prefix: null; |
3479 |
local-name: 'a'; |
3480 |
general-entity-reference { |
3481 |
node-name: 'entity2'; |
3482 |
text { data: 'e'; } |
3483 |
general-entity-reference { |
3484 |
node-name: 'entity1'; |
3485 |
text { |
3486 |
data: 'entity value'; |
3487 |
} |
3488 |
} |
3489 |
text { data: 'n'; } |
3490 |
} |
3491 |
} |
3492 |
} |
3493 |
|
3494 |
@@PerlDef: |
3495 |
my $impl = $Message::DOM::ImplementationRegistry->get_implementation ({ |
3496 |
'Core' => '3.0', |
3497 |
'XML' => '3.0', |
3498 |
'XMLVersion' => ['1.0', '1.1'], |
3499 |
}); |
3500 |
my $parser = <Class::ManakaiXMLParser>->new ($impl); |
3501 |
|
3502 |
for my $test_data (@$TestData) { |
3503 |
$test->start_new_test ($test_data->{uri}); |
3504 |
my $doc_ent = $test_data->{entity}->{$test_data->{root_uri}}; |
3505 |
my $doc = $parser->parse_string ($doc_ent->{<H::test:value>}); |
3506 |
try { |
3507 |
$test->assert_dom_tree_equals |
3508 |
(actual_value => $doc, |
3509 |
expected_hash => $test_data->{dom_tree}); |
3510 |
$test->ok; |
3511 |
} catch Message::Util::IF::DTException with { }; |
3512 |
} |
3513 |
|
3514 |
@ResourceDef: |
3515 |
@@QName: getCopyOfEntityState |
3516 |
@@rdf:type: DISPerl|InlineCode |
3517 |
@@ForCheck: ManakaiDOM|ForClass |
3518 |
@@PerlDef: |
3519 |
{%{$self->{$entity_type}->{$entity_name}}, |
3520 |
line => 1, column => 1, pos => 0} |
3521 |
##ManakaiXMLParser |
3522 |
|
3523 |
ElementTypeBinding: |
3524 |
@Name: XMLTests |
3525 |
@ElementType: |
3526 |
dis:ResourceDef |
3527 |
@ShadowContent: |
3528 |
@@ForCheck: ManakaiDOM|ForClass |
3529 |
@@rdf:type: test|ParserTestSet |
3530 |
|
3531 |
ElementTypeBinding: |
3532 |
@Name: XMLTest |
3533 |
@ElementType: |
3534 |
dis:ResourceDef |
3535 |
@ShadowContent: |
3536 |
@@ForCheck: ManakaiDOM|ForClass |
3537 |
@@rdf:type: test|ParserTest |
3538 |
|
3539 |
ElementTypeBinding: |
3540 |
@Name: DEnt |
3541 |
@ElementType: |
3542 |
dis:ResourceDef |
3543 |
@ShadowContent: |
3544 |
@@rdf:type: test|RootEntity |
3545 |
|
3546 |
ElementTypeBinding: |
3547 |
@Name: Ent |
3548 |
@ElementType: |
3549 |
dis:ResourceDef |
3550 |
@ShadowContent: |
3551 |
@@rdf:type: test|Entity |
3552 |
|
3553 |
ResourceDef: |
3554 |
@QName: xp|get-location-from-token |
3555 |
@rdf:type: DISPerl|BlockCode |
3556 |
@enDesc: |
3557 |
Creates a <IF::DOMCore:DOMLocator> object from a token. |
3558 |
@PerlDef: |
3559 |
$result = { |
3560 |
utf32_offset => $self->{entity}->[-1]->{pos}, |
3561 |
}; |
3562 |
@For: ManakaiDOM|ManakaiDOM3 |
3563 |
|
3564 |
ElementTypeBinding: |
3565 |
@Name: RuleDef |
3566 |
@ElementType: |
3567 |
dis:ResourceDef |
3568 |
@ShadowContent: |
3569 |
@@ForCheck: ManakaiDOM|ForClass |
3570 |
@@rdf:type: Muf2003|RuleDefClass |
3571 |
|
3572 |
ElementTypeBinding: |
3573 |
@Name: RuleParam |
3574 |
@ElementType: |
3575 |
dis:ResourceDef |
3576 |
@ShadowContent: |
3577 |
@@rdf:type: Muf2003|RuleParameter |
3578 |
|
3579 |
ElementTypeBinding: |
3580 |
@Name: enImplNote |
3581 |
@ElementType: |
3582 |
dis:ImplNote |
3583 |
@ShadowContent: |
3584 |
@@lang:en |
3585 |
|
3586 |
ElementTypeBinding: |
3587 |
@Name: ErrDef |
3588 |
@ElementType: |
3589 |
dis:ResourceDef |
3590 |
@ShadowContent: |
3591 |
@@rdf:type: DOMCore|DOMErrorType |
3592 |
@@For: ManakaiDOM|DOM3 |
3593 |
@@ecore:textFormatter: ManakaiXMLParserExceptionFormatter |
3594 |
|
3595 |
ElementTypeBinding: |
3596 |
@Name: WFErrDef |
3597 |
@ElementType: |
3598 |
dis:ResourceDef |
3599 |
@ShadowContent: |
3600 |
@@rdf:type: DOMCore|DOMErrorType |
3601 |
@@For: ManakaiDOM|DOM3 |
3602 |
@@ecore:textFormatter: ManakaiXMLParserExceptionFormatter |
3603 |
|
3604 |
WFErrDef: |
3605 |
@QName: xp|wf-syntax-error |
3606 |
@enDesc: |
3607 |
The entity does not match to the production rule; it is not |
3608 |
well-formed. |
3609 |
@DOMCore:severity: DOMCore|SEVERITY_FATAL_ERROR |
3610 |
@enMufDef: |
3611 |
|%xp-error-token-type;|%xp-error-token-value |
3612 |
(prefix => { (|}, suffix => {|)}); is not |
3613 |
allowed%xp-error-lines (prefix => { (|}, suffix => {|)}); |
3614 |
@ecore:hasParameter: |
3615 |
@@@: xp|error-token |
3616 |
@@enDesc: |
3617 |
The token that is not allowed. |
3618 |
|
3619 |
WFErrDef: |
3620 |
@QName: xp|wf-pi-target-is-xml |
3621 |
@enDesc: |
3622 |
A processing instruction has its <CODE::PITarget> of |
3623 |
<XML::xml> (in any case) which is not allowed. |
3624 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3625 |
@enMufDef: |
3626 |
Processing instruction target name cannot be |%p |
3627 |
(name => {<Q::xp|name>});| |
3628 |
@ecore:hasParameter: |
3629 |
@@@: xp|error-token |
3630 |
@@enDesc: |
3631 |
The token that contains the name. |
3632 |
@ecore:hasParameter: |
3633 |
@@@: xp|name |
3634 |
@@enDesc: |
3635 |
A string that is specified as target name of the |
3636 |
processing instruction. |
3637 |
@ecore:hasParameter: xp|parent |
3638 |
|
3639 |
WFErrDef: |
3640 |
@QName: xp|wf-no-end-tag |
3641 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3642 |
@enDesc: |
3643 |
An end-tag is not found. |
3644 |
@enMufDef: |
3645 |
End-tag |</%p (name => {<Q::xp|expected-element-type>});>| is required |
3646 |
@ecore:hasParameter: xp|error-token |
3647 |
@ecore:hasParameter: |
3648 |
@@@: xp|node |
3649 |
@@enDesc: |
3650 |
The element node that is not closed. |
3651 |
@ecore:hasParameter: |
3652 |
@@@: xp|expected-element-type |
3653 |
@@enDesc: |
3654 |
The element type name of the element that is not closed. |
3655 |
|
3656 |
WFErrDef: |
3657 |
@QName: xp|wf-unsupported-xml-version |
3658 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3659 |
@enDesc: |
3660 |
The XML version specified in the version declaration is not supported. |
3661 |
@enMufDef: |
3662 |
XML version |%p (name => {<Q::infoset|version>});| is not supported |
3663 |
@ecore:hasParameter: xp|bad-token |
3664 |
@ecore:hasParameter: |
3665 |
@@@: xp|parent |
3666 |
@@enDesc: |
3667 |
The document node. |
3668 |
@ecore:hasParameter: |
3669 |
@@@: infoset|version |
3670 |
@@enDesc: |
3671 |
The specified XML version. |
3672 |
|
3673 |
WFErrDef: |
3674 |
@QName: xp|wf-malformed-enc-name |
3675 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3676 |
@enDesc: |
3677 |
An <XA::encoding> pseudo-attribute value does not match |
3678 |
to the procduction rule <CODE::EncName>. |
3679 |
@enMufDef: |
3680 |
Encoding name |%p (name => {<Q::xp|name>});| is not allowed |
3681 |
@ecore:hasParameter: xp|error-token |
3682 |
@ecore:hasParameter: |
3683 |
@@@: xp|parent |
3684 |
@@enDesc: The document node. |
3685 |
@ecore:hasParameter: |
3686 |
@@@: xp|name |
3687 |
@@enDesc: |
3688 |
The <XA::encoding> value. |
3689 |
|
3690 |
WFErrDef: |
3691 |
@QName: xp|wf-malformed-xml-standalone |
3692 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3693 |
@enDesc: |
3694 |
An <XA::standalone> pseudo-attribute value is neither <XML::yes> |
3695 |
or <XML::no>. |
3696 |
@enMufDef: |
3697 |
|standalone| pseudo-attribute value |%p (name => {<Q::xp|name>});| |
3698 |
is not allowed |
3699 |
@ecore:hasParameter: xp|error-token |
3700 |
@ecore:hasParameter: |
3701 |
@@@: xp|parent |
3702 |
@@enDesc: The document node. |
3703 |
@ecore:hasParameter: |
3704 |
@@@: xp|name |
3705 |
@@enDesc: |
3706 |
The <XA::standalone> value. |
3707 |
|
3708 |
WFErrDef: |
3709 |
@QName: xp|wf-legal-literal-character |
3710 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3711 |
@enDesc: |
3712 |
Each character in XML entity must match to the production |
3713 |
rule <CODE::Char - RestrictedChar>. |
3714 |
@enMufDef: |
3715 |
Character %character-code-point |
3716 |
(v => {<Q::xp|character-number>}); is not allowed |
3717 |
@ecore:hasParameter: |
3718 |
@@@: xp|character-number |
3719 |
@@enDesc: |
3720 |
The code position of the character being referred. |
3721 |
|
3722 |
WFErrDef: |
3723 |
@QName: xp|wf-element-type-match |
3724 |
@DOMCore:severity: DOMCore|SEVERITY_FATAL_ERROR |
3725 |
@enDesc: |
3726 |
The <CODE::Name> in an element's end-tag must match the element type |
3727 |
in the start-tag. |
3728 |
@enMufDef: |
3729 |
End-tag |</%p (name => {<Q::xp|actual-element-type>});>| does |
3730 |
not match to start-tag |<%p (name => {<Q::xp|expected-element-type>});>| |
3731 |
@ecore:hasParameter: xp|error-token |
3732 |
@ecore:hasParameter: |
3733 |
@@@: xp|node |
3734 |
@@enDesc: |
3735 |
The current opening element node. |
3736 |
@ecore:hasParameter: |
3737 |
@@@: xp|expected-element-type |
3738 |
@@enDesc: |
3739 |
The element type name of the current element. |
3740 |
@ecore:hasParameter: |
3741 |
@@@: xp|actual-element-type |
3742 |
@@enDesc: |
3743 |
The <CODE::Name> occurs in the end-tag. |
3744 |
|
3745 |
WFErrDef: |
3746 |
@QName: xp|wf-unique-att-spec |
3747 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3748 |
@enDesc: |
3749 |
An attribute name <kwd:MUST-NOT> appear more than once in |
3750 |
the same start-tag or empty-element tag. |
3751 |
@enMufDef: |
3752 |
Attribute |%p (name => {<Q::xp|name>});| is specified more |
3753 |
than once in the same tag |
3754 |
@ecore:hasParameter: xp|error-token |
3755 |
@ecore:hasParameter: |
3756 |
@@@: xp|name |
3757 |
@@enDesc: |
3758 |
The name of the attribute. |
3759 |
|
3760 |
WFErrDef: |
3761 |
@QName: xp|wf-legal-character |
3762 |
@DOMCore:severity: DOMCore|SEVERITY_ERROR |
3763 |
@enDesc: |
3764 |
Characters referred to using character references <kwd:MUST> |
3765 |
match the production for <CODE::Char>. |
3766 |
@enMufDef: |
3767 |
Reference to character %character-code-point |
3768 |
(v => {<Q::xp|character-number>}); is not allowed |
3769 |
@ecore:hasParameter: xp|error-token |
3770 |
@ecore:hasParameter: |
3771 |
@@@: xp|character-number |
3772 |
@@enDesc: |
3773 |
The code position of the character being referred. |
3774 |
@ecore:hasParameter: |
3775 |
@@@: xp|parent |
3776 |
@@enDesc: |
3777 |
The parent node in which the character reference has |
3778 |
occurred, if available. |
3779 |
|
3780 |
XWParam: |
3781 |
@QName: xp|error-token |
3782 |
@enDesc: |
3783 |
The token where the parser found an error. |
3784 |
|
3785 |
XWParam: |
3786 |
@QName: xp|name |
3787 |
@enDesc: |
3788 |
A name. |
3789 |
|
3790 |
XWParam: |
3791 |
@QName: xp|parent |
3792 |
@enDesc: |
3793 |
The parent node in which the error occurs. |
3794 |
|
3795 |
XWParam: |
3796 |
@QName: xp|node |
3797 |
@enDesc: |
3798 |
The current node. |
3799 |
|
3800 |
XWParam: |
3801 |
@QName: xp|actual-element-type |
3802 |
@enDesc: |
3803 |
The actual element type name occured in the source. |
3804 |
|
3805 |
XWParam: |
3806 |
@QName: xp|expected-element-type |
3807 |
@enDesc: |
3808 |
The element type name expected. |
3809 |
|
3810 |
XWParam: |
3811 |
@QName: xp|character-number |
3812 |
@enDesc: |
3813 |
The character code position. |
3814 |
|
3815 |
ElementTypeBinding: |
3816 |
@Name: XWParam |
3817 |
@ElementType: |
3818 |
dis:ResourceDef |
3819 |
@ShadowContent: |
3820 |
@@For: =ManakaiDOM|all |
3821 |
@@rdf:type: ecore|Parameter |
3822 |
|
3823 |
ElementTypeBinding: |
3824 |
@Name:enMufDef |
3825 |
@ElementType: |
3826 |
ecore:defaultMessage |
3827 |
@ShadowContent: |
3828 |
@@lang:en |
3829 |
@@ContentType: |
3830 |
lang:muf |
3831 |
|
3832 |
ResourceDef: |
3833 |
@QName: DOMImpl |
3834 |
@AliasFor: DOMCore|DOMImplementation |
3835 |
@For: ManakaiDOM|DOM |
3836 |
|
3837 |
ElementTypeBinding: |
3838 |
@Name: Attr |
3839 |
@ElementType: |
3840 |
dis:ResourceDef |
3841 |
@ShadowContent: |
3842 |
@@rdf:type: DISLang|Attribute |
3843 |
@@ForCheck: !=ManakaiDOM|ManakaiDOM |
3844 |
|
3845 |
ElementTypeBinding: |
3846 |
@Name: Get |
3847 |
@ElementType: |
3848 |
dis:ResourceDef |
3849 |
@ShadowContent: |
3850 |
@@rdf:type: DISLang|AttributeGet |
3851 |
|
3852 |
ElementTypeBinding: |
3853 |
@Name: Set |
3854 |
@ElementType: |
3855 |
dis:ResourceDef |
3856 |
@ShadowContent: |
3857 |
@@rdf:type: DISLang|AttributeSet |
3858 |
|
3859 |
ElementTypeBinding: |
3860 |
@Name: enDesc |
3861 |
@ElementType: |
3862 |
dis:Description |
3863 |
@ShadowContent: |
3864 |
@@lang:en |
3865 |
|
3866 |
ElementTypeBinding: |
3867 |
@Name: Method |
3868 |
@ElementType: |
3869 |
dis:ResourceDef |
3870 |
@ShadowContent: |
3871 |
@@rdf:type: DISLang|Method |
3872 |
@@For: !=ManakaiDOM|ManakaiDOM |
3873 |
|
3874 |
ElementTypeBinding: |
3875 |
@Name: Return |
3876 |
@ElementType: |
3877 |
dis:ResourceDef |
3878 |
@ShadowContent: |
3879 |
@@rdf:type: DISLang|MethodReturn |
3880 |
|
3881 |
ElementTypeBinding: |
3882 |
@Name: Param |
3883 |
@ElementType: |
3884 |
dis:ResourceDef |
3885 |
@ShadowContent: |
3886 |
@@rdf:type: DISLang|MethodParameter |
3887 |
|
3888 |
ElementTypeBinding: |
3889 |
@Name: PerlDef |
3890 |
@ElementType: |
3891 |
dis:Def |
3892 |
@ShadowContent: |
3893 |
@@ContentType: lang|Perl |
3894 |
|
3895 |
ElementTypeBinding: |
3896 |
@Name: PropDef |
3897 |
@ElementType: |
3898 |
dis:ResourceDef |
3899 |
@ShadowContent: |
3900 |
@@rdf:type: rdf|Property |
3901 |
|
3902 |
ClsDef: |
3903 |
@ClsQName: ManakaiXMLParserExceptionFormatter |
3904 |
|
3905 |
@ClsISA: ecore|MUErrorFormatter||ManakaiDOM|Perl |
3906 |
|
3907 |
@RuleDef: |
3908 |
@@Name: xp-error-token-type |
3909 |
@@enDesc: |
3910 |
The type of the token the parser is encountered. |
3911 |
|
3912 |
@@Method: |
3913 |
@@@Name: after |
3914 |
@@@Param: |
3915 |
@@@@Name: name |
3916 |
@@@@Type: DOMString |
3917 |
@@@@enDesc: The name of the method. |
3918 |
@@@Param: |
3919 |
@@@@Name: p |
3920 |
@@@@Type: DISPerl|HASH |
3921 |
@@@@enDesc: The set of the parameters to the method. |
3922 |
@@@Param: |
3923 |
@@@@Name: o |
3924 |
@@@@Type: DISPerl|HASH |
3925 |
@@@@enDesc: The option value. |
3926 |
@@@Return: |
3927 |
@@@@PerlDef: |
3928 |
$p->{-result} = $o->{<H::xp|error-token>}->{type} |
3929 |
if defined $o->{<H::xp|error-token>}->{type}; |
3930 |
|
3931 |
@RuleDef: |
3932 |
@@Name: xp-error-token-value |
3933 |
@@enDesc: |
3934 |
The value of the token the parser is encountered, if any. |
3935 |
|
3936 |
@@Method: |
3937 |
@@@Name: after |
3938 |
@@@Param: |
3939 |
@@@@Name: name |
3940 |
@@@@Type: DOMString |
3941 |
@@@@enDesc: The name of the method. |
3942 |
@@@Param: |
3943 |
@@@@Name: p |
3944 |
@@@@Type: DISPerl|HASH |
3945 |
@@@@enDesc: The set of the parameters to the method. |
3946 |
@@@Param: |
3947 |
@@@@Name: o |
3948 |
@@@@Type: DISPerl|HASH |
3949 |
@@@@enDesc: The option value. |
3950 |
@@@Return: |
3951 |
@@@@PerlDef: |
3952 |
$p->{-result} = $o->{<H::xp|error-token>}->{value} |
3953 |
if defined $o->{<H::xp|error-token>}->{value}; |
3954 |
|
3955 |
@RuleDef: |
3956 |
@@Name: xp-error-lines |
3957 |
@@enDesc: |
3958 |
A copy of fragment of the source text that contains the line |
3959 |
where the error occurred, if available. |
3960 |
|
3961 |
@@Method: |
3962 |
@@@Name: after |
3963 |
@@@Param: |
3964 |
@@@@Name: name |
3965 |
@@@@Type: DOMString |
3966 |
@@@@enDesc: The name of the method. |
3967 |
@@@Param: |
3968 |
@@@@Name: p |
3969 |
@@@@Type: DISPerl|HASH |
3970 |
@@@@enDesc: The set of the parameters to the method. |
3971 |
@@@Param: |
3972 |
@@@@Name: o |
3973 |
@@@@Type: DISPerl|HASH |
3974 |
@@@@enDesc: The option value. |
3975 |
@@@Return: |
3976 |
@@@@PerlDef: |
3977 |
my $pos = $o-><AG::DOMCore|DOMError.location> |
3978 |
-><AG::DOMCore|DOMLocator.utf32Offset>; |
3979 |
if ($pos > -1) { |
3980 |
my $src = $o->{<H::ecore|object>}->{entity}->[-1]->{reptxt}; |
3981 |
my $start = $pos; |
3982 |
$start = rindex ($$src, "\x0A", $start - 1) for 0..2; |
3983 |
$start++; |
3984 |
my $end = $pos; |
3985 |
$end = index ($$src, "\x0A", $end + 1) for 0..2; |
3986 |
$end = length $$src if $end < 0; |
3987 |
$p->{-result} = substr $$src, $start, $end - $start; |
3988 |
} |
3989 |
|
3990 |
@RuleDef: |
3991 |
@@Name: character-code-point |
3992 |
@@enDesc: |
3993 |
The character code position, in <CODE::U+<VAR::HHHH>> notation. |
3994 |
|
3995 |
@@Method: |
3996 |
@@@Name: after |
3997 |
@@@Param: |
3998 |
@@@@Name: name |
3999 |
@@@@Type: DOMString |
4000 |
@@@@enDesc: The name of the method. |
4001 |
@@@Param: |
4002 |
@@@@Name: p |
4003 |
@@@@Type: DISPerl|HASH |
4004 |
@@@@enDesc: The set of the parameters to the method. |
4005 |
@@@Param: |
4006 |
@@@@Name: o |
4007 |
@@@@Type: DISPerl|HASH |
4008 |
@@@@enDesc: The option value. |
4009 |
@@@RuleParam: |
4010 |
@@@@Name: v |
4011 |
@@@@Type: DISPerl|Number |
4012 |
@@@@enDesc: |
4013 |
The name of the error parameter that contains the character code. |
4014 |
@@@Return: |
4015 |
@@@@PerlDef: |
4016 |
$p->{-result} = sprintf 'U+%04X', $o->{$p->{v}}; |
4017 |
##XMLParserExceptionFormatter |