/[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.14 - (show annotations) (download)
Wed Feb 8 16:37:35 2006 UTC (18 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.13: +520 -17 lines
++ manakai/lib/Message/Util/ChangeLog	8 Feb 2006 16:31:15 -0000
	* PerlCode.dis (PCReference.stringify): Reference operator |\|
	was missing.

2006-02-08  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/Util/DIS/ChangeLog	8 Feb 2006 16:37:10 -0000
	* DPG.dis (state_to_code): An |unshift|-overread-character
	code was missing in case that an accept state has next state
	but it does not result in acception.  Copy |$self->{location}|
	at the beginning of the scanning of a token and |return|s
	it as part of the token information.

	* Test.dis (assertDOMLocatorEquals): New |_line_column|
	type support is added.
	(RANGE): New token type.
	(tdterr): |position| syntax is extended to allow
	range specification.

2006-02-08  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	8 Feb 2006 16:30:20 -0000
	* Tree.dis (createProcessingInstruction): Don't
	throw |MDOMX:MDOM_BAD_NAME| exception if |Document.strictErrorChecking|
	is |false|.

	* XMLParser.dis (parseString): Initializes |$self->{location}|.
	It enables improved error position report.
	(XDO): It now includes |S+| following target name |xml| as
	part of the token.  (PI with target starting with |xml|
	was unable to be placed at the beginning of the document entity.)
	(_ProcessingInstruction, _ProcessingInstructionDTD): Creates
	a processing instruction node with |#INVALID| node name
	if target name is not given and recovered from the error.
	(S): Variable |$s| added.
	(XMLTests): Tests for XML declarations and processing
	instructions are added.  Prints error type name if unexpected
	error with severity of error or fatal error has been reported.
	Catch unexpected exceptions thrown in parser (different
	from |LSException|), prints its message, and invoke |$test->not_ok|
	for the ease of testing.
	(xp:get-location-from-token): Location values now take |$self->{char}|
	stack into acount.

2006-02-08  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24