/[suikacvs]/messaging/manakai/lib/Message/DOM/XMLParser.dis
Suika

Contents of /messaging/manakai/lib/Message/DOM/XMLParser.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Sun Jan 29 07:09:25 2006 UTC (18 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.9: +108 -1 lines
++ manakai/t/ChangeLog	29 Jan 2006 07:08:33 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* Makefile (dom-xml.t): New test.

++ manakai/lib/Message/Util/ChangeLog	29 Jan 2006 07:07:32 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (skipLines): Its code was incorrect.
	(createPCLiteral): Creates a |undef| keyword node
	for an |undef| value.  Tests added.

++ manakai/lib/Message/Util/DIS/ChangeLog	29 Jan 2006 07:08:09 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* Test.dis (assertDOMTreeEquals): |attributes| and |generalEntities|
	are implemented.

++ manakai/lib/Message/DOM/ChangeLog	29 Jan 2006 07:00:55 -0000
2006-01-29  Wakaba  <wakaba@suika.fam.cx>

	* XMLParser.dis: Tests on default attributes and their |specified|
	attribute are added.

	* XDoctype.dis (createGeneralEntity): New method.
	(generalEntities): New attribute.
	(getGeneralEntityNode, setGeneralEntityNode): New methods.

	* Tree.dis (ManakaiDOMEntities): Removed.
	(ManakaiDOMEntityMap): New class.
	(ManakaiDOM:entity-reference-read-only): New configuration parameter.
	(createEntityReference): If there is a corresponding |Entity|
	node in the document type definition, then copies its
	subtree.

	* DOMXML.dis (Entity): Documentation updated.
	(publicId, systemId, notationName, xmlEncoding,
	xmlVersion): These attributes are now settable
	if |ManakaiDOM:ManakaiDOMLatest| mode.
	(hasReplacementTree): New attribute for |ManakaiDOM:ManakaiDOMLatest|
	mode.
	(ownerDocumentTypeDefinition): New attribute
	for |ManakaiDOM:ManakaiDOMLatest| mode.
	(isExpanded): New attribute for |ManakaiDOM:ManakaiDOMLatest| mode.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24