/[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.15 - (hide annotations) (download)
Thu Feb 9 10:23:19 2006 UTC (18 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.14: +546 -8 lines
++ manakai/bin/ChangeLog	9 Feb 2006 10:13:54 -0000
2006-02-09  Wakaba  <wakaba@suika.fam.cx>

	* dac2test.pl: Set |pc:preserve-line-break| configuration
	parameter |true|.

++ manakai/lib/Message/Util/ChangeLog	9 Feb 2006 10:20:03 -0000
2006-02-09  Wakaba  <wakaba@suika.fam.cx>

	* PerlCode.dis (PerlStringLiteral.stringify): |pc:preserve-line-break|
	configuration parameter support is added.
	(pc:preserve-line-break): New configuration option.

	* DIS.dis (readProperties): |DISCore:UString| lextype support added.

++ manakai/lib/Message/Util/DIS/ChangeLog	9 Feb 2006 10:22:14 -0000
2006-02-09  Wakaba  <wakaba@suika.fam.cx>

	* Test.dis (printComment): Escapes non-ASCII-printable characters.

	* DPG.dis (state_to_code): Adds set-|$token->{location_d}|-code
	to adjast column number when |@dch| is in use.

++ manakai/lib/Message/DOM/ChangeLog	9 Feb 2006 10:18:41 -0000
2006-02-09  Wakaba  <wakaba@suika.fam.cx>

	* XMLParser.dis (CommentDeclaration): |STRING| is now
	defined as a |?default-token|.
	(XMLTests): Tests for |Char - RestrictedChar| matchness,
	comment declarations, cdata sections, and |MSE| in |content|
	added.
	(XMLTests/PerlDef): Bug fixed: |pop| -> |shift|.
	(get-location-from-token): |$token->{location_d}|
	for |?default-token| column counting support added.

	* DOMCore.dis (c:erred): It is now a |DISCore:OrderedList| property.

++ manakai/lib/manakai/ChangeLog	9 Feb 2006 10:23:11 -0000
2006-02-09  Wakaba  <wakaba@suika.fam.cx>

	* DISCore.dis (DISCore:UString): New lextype.

	* Test.dis (test:value): Default |dis:dataType| changed
	to |DISCore:UString|.
	(test:EntityValueString): Removed (it was never used).

1 wakaba 1.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 wakaba 1.15 $Date: 2006/02/08 16:37:35 $
14 wakaba 1.1
15     @DefaultFor: ManakaiDOM|ManakaiDOMLatest
16    
17     @Require:
18     @@Module:
19     @@@QName: MDOM|DOMLS
20     @@@WithFor: ManakaiDOM|ManakaiDOMLatest
21 wakaba 1.6 @@Module:
22     @@@QName: MDOM|XDoctype
23     @@@WithFor: ManakaiDOM|ManakaiDOMLatest
24 wakaba 1.1
25     Namespace:
26 wakaba 1.8 @c:
27     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
28 wakaba 1.11 @cfg:
29     http://suika.fam.cx/www/2006/dom-config/
30 wakaba 1.6 @d:
31     http://suika.fam.cx/~wakaba/archive/2004/dom/xdt#
32 wakaba 1.1 @dis:
33     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
34 wakaba 1.5 @dtest:
35     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#Test/
36 wakaba 1.1 @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 wakaba 1.11 @fe:
43     http://suika.fam.cx/www/2006/feature/
44     @gls:
45     http://suika.fam.cx/~wakaba/archive/2004/dom/gls#
46 wakaba 1.1 @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 wakaba 1.11 @mn:
65     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/ManakaiNode#
66 wakaba 1.1 @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 wakaba 1.5 @test:
73     http://suika.fam.cx/~wakaba/archive/2004/dis/Test#
74 wakaba 1.8 @x:
75     http://suika.fam.cx/~wakaba/archive/2004/dom/xml#
76 wakaba 1.1 @xml:
77     http://www.w3.org/XML/1998/namespace
78 wakaba 1.9 @xml-dtd:
79     http://www.w3.org/TR/REC-xml
80 wakaba 1.1 @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 wakaba 1.6 ResourceDef:
130     @QName: DocumentXDoctype
131     @AliasFor: d|DocumentXDoctype
132     @For: ManakaiDOM|DOM
133    
134 wakaba 1.8 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 wakaba 1.1 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 wakaba 1.11 @DISLang:role: gls|ParserRole
205 wakaba 1.1
206 wakaba 1.3 @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 wakaba 1.1 @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 wakaba 1.11 @@@Type: gls|GLSImplementation
247 wakaba 1.1 @@@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 wakaba 1.6 $self->{entity} = [{
280     reptxt => \$sourceText,
281     line => 1,
282     column => 1,
283     pos => 0,
284     }];
285 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
286 wakaba 1.6 $self->{entity_char} = [];
287     $self->{entity_token} = [];
288 wakaba 1.3 $self->{xml_version} = '1.0';
289     $self->{standalone} = false;
290 wakaba 1.11 $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 wakaba 1.6 $self->{param_entity} = {};
298 wakaba 1.9 $self->{attr} = {};
299     # $self->{attr}->{$element_type_name}->{$attr_name} = $attr_def
300 wakaba 1.6 $self->{has_error} = false;
301 wakaba 1.3 ## Well-formedness constraint Entity Declared takes effect?
302 wakaba 1.1
303     __DEEP{
304 wakaba 1.11 $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 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
326 wakaba 1.11 $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 wakaba 1.1 }__;
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 wakaba 1.6 or <CODE::-1>.
350 wakaba 1.1 @@@PerlDef:
351     if (@{$self->{char}}) {
352     $r = shift @{$self->{char}};
353     } else {
354 wakaba 1.7 no warnings 'substr';
355     ## substr outside length warnings at the end of the string
356 wakaba 1.6 GETCHAR: {
357     my $char = substr (${$self->{entity}->[-1]->{reptxt}},
358     $self->{entity}->[-1]->{pos}, 1);
359    
360 wakaba 1.7 if (defined $char and length $char) {
361 wakaba 1.13 $self->{entity}->[-1]->{pos}++;
362 wakaba 1.6 $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 wakaba 1.13 $self->{entity}->[-1]->{line}++;
372 wakaba 1.6 $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 wakaba 1.13 $self->{entity}->[-1]->{line}++;
377 wakaba 1.6 $self->{entity}->[-1]->{column} = 1;
378     } else {
379 wakaba 1.13 $self->{entity}->[-1]->{column}++;
380     ## Line number will be increased by next |shiftChar| call.
381 wakaba 1.6 }
382 wakaba 1.3 } else {
383 wakaba 1.13 $self->{entity}->[-1]->{line}++;
384 wakaba 1.6 $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 wakaba 1.13 utf32_offset => $self->{entity}->[-1]->{pos} - 1,
398 wakaba 1.6 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 wakaba 1.3 }
408 wakaba 1.6 $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 wakaba 1.13 ## Even in XML 1.0 it increases the line number.
413 wakaba 1.6 $self->{entity}->[-1]->{line}++;
414     $self->{entity}->[-1]->{column} = 1;
415 wakaba 1.3 } else {
416 wakaba 1.6 $self->{entity}->[-1]->{column}++;
417 wakaba 1.3 }
418     } else {
419 wakaba 1.6 $r = -1;
420 wakaba 1.3 }
421 wakaba 1.6 } # GETCHAR
422 wakaba 1.1 }
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 wakaba 1.11 rule DocumentEntity : standalone {
473 wakaba 1.1 /*
474     prolog := XMLDecl? *Misc [doctypedecl *Misc] ;; [22]
475     */
476     ?lexmode 'DocumentStart';
477 wakaba 1.11
478     my $doc;
479     lang:Perl {
480     $doc = $self->{doc};
481     }
482 wakaba 1.1
483 wakaba 1.3 ~? (XDO) {
484     &_XMLDeclaration_ ($doc => $doc);
485    
486     ~ (PIC) {
487     ?lexmode DocumentProlog;
488     } else {
489     ?lexmode DocumentProlog;
490     }
491     } else {
492     ?lexmode 'DocumentProlog';
493     }
494 wakaba 1.1
495     // *Misc
496 wakaba 1.2 ~* (CDO) {
497 wakaba 1.1 &_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 wakaba 1.3 ~ (MDC) {
521     ?lexmode DocumentMisc;
522     } else {
523     ?lexmode DocumentMisc;
524     }
525     } else {
526     lang:Perl {
527     $self->{standalone} = true;
528     }
529     ?lexmode DocumentMisc;
530 wakaba 1.1 }
531    
532     // *Misc
533 wakaba 1.2 ~* (CDO) {
534 wakaba 1.1 &_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 wakaba 1.2 ~* (CDO) {
568 wakaba 1.1 &_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 wakaba 1.11
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 wakaba 1.1 /*
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 wakaba 1.3 rule _XMLDeclaration_ ($doc) {
630     ?lexmode XMLDeclaration;
631    
632 wakaba 1.14 // ~ (XDO) { }
633     // ~ (S) { }
634 wakaba 1.3
635     ~ (Name == 'version') {
636     ~? (S) { }
637     ~ (VI) { }
638     ~? (S) { }
639 wakaba 1.1
640 wakaba 1.3 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 wakaba 1.1 }
695    
696 wakaba 1.3 ~? (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 wakaba 1.1 }
755 wakaba 1.3
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 wakaba 1.1
787 wakaba 1.3 ~ (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 wakaba 1.13 if ($ver eq 'yes') {
811     $doc-><AS::Document.xmlStandalone> (true);
812     $self->{standalone} = true;
813     }
814 wakaba 1.3 }
815    
816     ~? (S) { }
817     }
818    
819     // ~ (PIC) { }
820     } // _XMLDeclaration_
821 wakaba 1.1
822     /*
823     Comment Declaration
824    
825     Comment := '<!--' *(Char - '-' / '-' (Char - '-'))
826     '-->' ;; [15]
827 wakaba 1.4 */
828 wakaba 1.1 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 wakaba 1.4 } // _CommentDeclaration
851 wakaba 1.15
852     rule _CommentDeclarationDTD {
853     ?lexmode CommentDeclaration;
854 wakaba 1.4
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 wakaba 1.1 /*
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 wakaba 1.3 lang:Perl ($name => $token.value) : has-error {
885 wakaba 1.1 if (lc $name eq 'xml') {
886 wakaba 1.3 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 wakaba 1.1 }
902     ## TODO: Namespace well-formedness
903     $pi = $doc-><M::Document.createProcessingInstruction>
904     ($name);
905     }
906 wakaba 1.14 } else {
907     lang:Perl {
908     $pi = $doc-><M::Document.createProcessingInstruction> ('#INVALID');
909     }
910 wakaba 1.1 }
911    
912 wakaba 1.14 ~? (S) {
913 wakaba 1.1 ?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 wakaba 1.4
939 wakaba 1.6 /*
940     Processing instruction in DTD
941     */
942     rule _ProcessingInstructionDTD ($doc, $doctype) {
943 wakaba 1.4 ?lexmode 'PIName';
944 wakaba 1.6
945     my $pi;
946 wakaba 1.4
947     ~ (Name) {
948 wakaba 1.6 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 wakaba 1.14 } else {
971     lang:Perl {
972     $pi = $doc-><M::Document.createProcessingInstruction> ('#INVALID');
973     }
974 wakaba 1.4 }
975    
976 wakaba 1.14 ~? (S) {
977 wakaba 1.4 ?lexmode 'PIData';
978    
979 wakaba 1.6 my $tdata;
980    
981 wakaba 1.4 ~? (DATA) {
982 wakaba 1.6 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 wakaba 1.4 }
994     }
995    
996 wakaba 1.6 lang:Perl {
997     $doctype-><M::Node.appendChild> ($pi);
998     }
999    
1000 wakaba 1.4 ~ (PIC) {
1001     ?lexmode DTD;
1002     } else {
1003     ?lexmode DTD;
1004     }
1005     } // _ProcessingInstructionDTD
1006 wakaba 1.1
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 wakaba 1.6 rule Element_ ($doc, $parent, $ns) : standalone {
1016 wakaba 1.1 ?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 wakaba 1.6 //my $ns; // Current in-scope namespace bindings
1023 wakaba 1.1 my $nses; // Namespace binding stack (w/o $current_ns)
1024    
1025     lang:Perl {
1026     $node = $parent;
1027     $nodes = [];
1028     $type = '';
1029     $types = [];
1030 wakaba 1.6 $ns ||= {
1031 wakaba 1.1 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 wakaba 1.9
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 wakaba 1.1
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 wakaba 1.9 $attrs->{$atqname}->{def} = $self->{attr}->{$type}->{$atqname};
1089 wakaba 1.1 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 wakaba 1.9 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 wakaba 1.1 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 wakaba 1.9 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 wakaba 1.1 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 wakaba 1.9 if ($attrs->{xmlns}->{def}) {
1195     __CODE{t|setAttrType::
1196     $attr => $attr,
1197     $type => {$attrs->{xmlns}->{def}-><AG::ATDef.declaredType>},
1198     }__;
1199     }
1200 wakaba 1.1 $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 wakaba 1.9 if ($attrs->{$lname}->{def}) {
1210     __CODE{t|setAttrType::
1211     $attr => $attr,
1212     $type => {$attrs->{$lname}->{def}-><AG::ATDef.declaredType>},
1213     }__;
1214     }
1215 wakaba 1.1 $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 wakaba 1.9 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 wakaba 1.1 $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 wakaba 1.6 } (NESTC) {
1246     my $is_docel;
1247 wakaba 1.1 lang:Perl {
1248     $ns = pop @{$nses};
1249     $type = pop @{$types};
1250 wakaba 1.6 $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 wakaba 1.1 }
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 wakaba 1.3 lang:Perl ($name => $token.value) : has-error {
1278 wakaba 1.1 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 wakaba 1.3 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 wakaba 1.1 }
1303     }
1304     }
1305    
1306     ~? (S) { }
1307    
1308     if-true ($is_docel) {
1309 wakaba 1.3 lang:Perl : has-error {
1310 wakaba 1.1 if (@{$types}) {
1311 wakaba 1.3 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 wakaba 1.1 }
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 wakaba 1.6 &_GeneralEntityReferenceEC
1360     ($doc => $doc, $parent => $node, $ns => $ns);
1361 wakaba 1.1 } (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 wakaba 1.3
1387     ~ (#NONE) { }
1388 wakaba 1.1 } // Element_
1389 wakaba 1.11
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 wakaba 1.1
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 wakaba 1.3 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 wakaba 1.1 }
1497    
1498     $vals = $attrs->{$atqname} = {
1499     nodes => [],
1500     value => '',
1501     index => $i++,
1502     };
1503     }
1504 wakaba 1.3
1505     ~? (S) { }
1506     ~ (VI) { }
1507     ~? (S) { }
1508 wakaba 1.1
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 wakaba 1.11 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 wakaba 1.1 CDATA Section Content Parsing Mode
1668     */
1669     rule _CDATASection_ ($doc, $parent) {
1670     ?lexmode 'CDATASectionContent';
1671    
1672     my $cdata;
1673    
1674 wakaba 1.2 ~? (CData) {
1675 wakaba 1.1 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 wakaba 1.3 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 wakaba 1.1 $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 wakaba 1.3 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 wakaba 1.1 my $ncr = $doc-><M::Document.createTextNode>
1767 wakaba 1.9 (my $char = chr $num);
1768 wakaba 1.1 push @{$vals->{nodes}}, $ncr;
1769     $vals->{value} .= $char;
1770     }
1771     }
1772    
1773     // ~ (REFC) { }
1774     } // _NumericCharacterReferenceV_
1775    
1776 wakaba 1.11 /*
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 wakaba 1.1 rule _HexadecimalCharacterReference_ ($doc, $parent) {
1864     ?lexmode 'HexadecimalCharacterReference';
1865    
1866     ~ (Hex) {
1867 wakaba 1.9 lang:Perl ($v => $token.value) : has-error {
1868     my $num = hex $v;
1869 wakaba 1.3 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 wakaba 1.1 my $ncr = $doc-><M::Document.createTextNode>
1897 wakaba 1.9 (chr $num);
1898 wakaba 1.1 $parent-><M::Node.appendChild> ($ncr);
1899     }
1900     }
1901    
1902     // ~ (REFC) { }
1903     } // _HexadecimalCharacterReference_
1904    
1905 wakaba 1.3 rule _HexadecimalCharacterReferenceV_ ($doc, $vals) {
1906 wakaba 1.1 ?lexmode 'HexadecimalCharacterReference';
1907    
1908     ~ (Hex) {
1909 wakaba 1.9 lang:Perl ($v => $token.value) : has-error {
1910     my $num = hex $v;
1911 wakaba 1.3 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 wakaba 1.1 my $ncr = $doc-><M::Document.createTextNode>
1938 wakaba 1.9 (my $char = chr $num);
1939 wakaba 1.1 push @{$vals->{nodes}}, $ncr;
1940     $vals->{value} .= $char;
1941     }
1942     }
1943    
1944     // ~ (REFC) { }
1945 wakaba 1.11 } // _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 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2078 wakaba 1.11 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 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2092 wakaba 1.11 }
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 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2155 wakaba 1.11 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 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2169 wakaba 1.11 }
2170    
2171     // TODO: Set read-only flag
2172    
2173     ?lexmode EntityReference;
2174     ?requires-next-token;
2175     }
2176    
2177     // ~ (REFC) { }
2178     } // _GeneralEntityReferenceV_
2179 wakaba 1.1
2180 wakaba 1.6 /*
2181 wakaba 1.11 General entity reference in the replacement text
2182     of the entity referenced in an attribute value literal
2183 wakaba 1.6 */
2184 wakaba 1.11 rule _GeneralEntityReferenceAE_ ($parent, $vals)
2185 wakaba 1.6 {
2186 wakaba 1.11 ?lexmode EntityReference;
2187 wakaba 1.1
2188 wakaba 1.11 ~ (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 wakaba 1.6 my $er;
2220 wakaba 1.1 lang:Perl ($name => $token.value) {
2221     ## TODO: Namespace well-formedness
2222     ## TODO: Entity declared constraints
2223 wakaba 1.11 ## TODO: No external entity constraint
2224     $er = $self->{doc}-><M::Document.createEntityReference> ($name);
2225 wakaba 1.1 $parent-><M::Node.appendChild> ($er);
2226 wakaba 1.6 push @{$self->{entity}}, <Code::getCopyOfEntityState::
2227     $entity_type = 'general_entity',
2228     $entity_name = $name>;
2229 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2230 wakaba 1.6 push @{$self->{entity_token}}, $self->{token};
2231     $self->{token} = [];
2232     push @{$self->{entity_char}}, $self->{char};
2233     $self->{char} = [];
2234     }
2235    
2236 wakaba 1.11 ?lexmode AttributeValueLiteralE;
2237     &AttributeValueLiteralE_ ($parent => $er, $vals => $vals);
2238 wakaba 1.6 ~ (#EOF) { }
2239     lang:Perl {
2240     $self->{token} = pop @{$self->{entity_token}};
2241     $self->{char} = pop @{$self->{entity_char}};
2242     pop @{$self->{entity}};
2243 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2244 wakaba 1.6 }
2245    
2246 wakaba 1.11 // TODO: Set read-only flag
2247    
2248 wakaba 1.6 ?lexmode EntityReference;
2249     ?requires-next-token;
2250 wakaba 1.1 }
2251    
2252     // ~ (REFC) { }
2253 wakaba 1.11 } // _GeneralEntityReferenceAE_
2254 wakaba 1.6
2255     /*
2256     General entity reference in literal entity value
2257     */
2258 wakaba 1.11 rule _GeneralEntityReferenceEV_ ($vals) {
2259 wakaba 1.6 ?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 wakaba 1.11
2269     // No expansion
2270 wakaba 1.6
2271     // ~ (REFC) { }
2272     } // _GeneralEntityReferenceEV_
2273 wakaba 1.1
2274     /*
2275 wakaba 1.4 Document Type Declaration
2276 wakaba 1.1 */
2277 wakaba 1.4 rule _DocumentTypeDeclaration_ ($doc) {
2278     ?lexmode MarkupDeclaration;
2279    
2280     ~ (Name == 'DOCTYPE') { }
2281    
2282     ~ (S) { }
2283    
2284 wakaba 1.6 my $node;
2285 wakaba 1.4 // Document type name
2286 wakaba 1.6 my $name;
2287 wakaba 1.4 ~ (Name) {
2288 wakaba 1.6 lang:Perl ($v => $token.value) {
2289     $name = $v;
2290     }
2291     }
2292     lang:Perl {
2293 wakaba 1.11 $self->{docx} = $self->{doc}
2294     -><M::Node.getFeature> (<Q::fe:XDoctype>, '3.0');
2295     $node = $self->{docx}-><M::DocumentXDoctype.createDocumentTypeDefinition>
2296     ($name);
2297 wakaba 1.4 }
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 wakaba 1.11 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 wakaba 1.4 ~? (DSO) {
2328 wakaba 1.6 &InternalSubset ($doc => $doc, $doctype => $node);
2329 wakaba 1.4
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 wakaba 1.6 rule InternalSubset ($doc, $doctype) {
2405 wakaba 1.4 ?lexmode DTD;
2406    
2407     ~* (MDO) {
2408     ?lexmode MarkupDeclaration;
2409    
2410     ~ (Name == 'ELEMENT') {
2411     &_ElementDeclaration ($doc => $doc);
2412     } (Name == 'ATTLIST') {
2413 wakaba 1.8 &_AttlistDeclaration ($doc => $doc, $doctype => $doctype);
2414 wakaba 1.4 } (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 wakaba 1.6 &_ProcessingInstructionDTD ($doc => $doc, $doctype => $doctype);
2425 wakaba 1.4 } (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 wakaba 1.8 /*
2594     Attribute list declaration
2595     */
2596     rule _AttlistDeclaration ($doc, $doctype) {
2597 wakaba 1.4 // ~ (MDO) { }
2598     // ~ (Name == 'ATTLIST') { }
2599    
2600     ?lexmode AttlistDeclaration;
2601    
2602     ~ (S) { }
2603    
2604 wakaba 1.8 my $name;
2605 wakaba 1.4 ~ (Name) {
2606 wakaba 1.8 lang:Perl ($v => $token.value) {
2607     $name = $v;
2608     }
2609     } else {
2610     lang:Perl { $name = '#ILLEGAL' }
2611     }
2612 wakaba 1.4
2613 wakaba 1.8 my $docxd;
2614     my $et;
2615     lang:Perl {
2616     $et = $doctype-><M::DTDef.getElementTypeDefinitionNode> ($name);
2617     unless ($et) {
2618 wakaba 1.11 $docxd = $doc-><M::Node.getFeature> (<Q::fe:XDoctype>, '3.0');
2619 wakaba 1.8 $et = $docxd-><M::DocumentXDoctype.createElementTypeDefinition>
2620     ($name);
2621     $doctype-><M::DTDef.setElementTypeDefinitionNode> ($et)
2622     unless $name eq '#ILLEGAL';
2623     }
2624 wakaba 1.4 }
2625    
2626     ~? (S) { }
2627    
2628     ~* (Name) {
2629 wakaba 1.8 my $at;
2630     lang:Perl ($v => $token.value) {
2631     $docxd ||= $doc-><M::Node.getFeature>
2632 wakaba 1.11 (<Q::fe:XDoctype>, '3.0');
2633 wakaba 1.8 $at = $docxd-><M::DocumentXDoctype.createAttributeDefinition> ($v);
2634 wakaba 1.9 unless (exists $et-><AG::ETDef.attributeDefinitions>->{$v}) {
2635     $et-><M::ETDef.setAttributeDefinitionNode> ($at);
2636     $self->{attr}->{$name}->{$v} = $at;
2637     }
2638 wakaba 1.8 }
2639 wakaba 1.4
2640     ~ (S) { }
2641    
2642     // AttType
2643     ~ (Name == 'NOTATION') {
2644     ~ (S) { }
2645    
2646 wakaba 1.8 my $kwd;
2647     lang:Perl {
2648     $at-><AS::ATDef.declaredType> (<C::ATDef.NOTATION_ATTR>);
2649     $kwd = $at-><AG::ATDef.allowedTokens>;
2650     }
2651    
2652 wakaba 1.4 ~ (EGO) {
2653     ~? (S) { }
2654    
2655 wakaba 1.8 ~+ (Name) {
2656     lang:Perl ($v => $token.value) {
2657     push @$kwd, $v;
2658     }
2659 wakaba 1.4
2660     ~? (S) { }
2661     } (OR) : separator {
2662     ~? (S) { }
2663     }
2664    
2665     ~ (EGC) { }
2666     }
2667 wakaba 1.8
2668 wakaba 1.4 } (Name) {
2669 wakaba 1.8 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 wakaba 1.4
2688     } (EGO) {
2689     ?lexmode Enumeration;
2690    
2691     ~? (S) { }
2692    
2693 wakaba 1.8 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 wakaba 1.4
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 wakaba 1.8 lang:Perl {
2723     $at-><AS::ATDef.defaultType> (<C::ATDef.REQUIRED_DEFAULT>);
2724     }
2725 wakaba 1.4 } (Name == 'IMPLIED') {
2726 wakaba 1.8 lang:Perl {
2727     $at-><AS::ATDef.defaultType> (<C::ATDef.IMPLIED_DEFAULT>);
2728     }
2729 wakaba 1.4 } (Name == 'FIXED') {
2730     ~ (S) { }
2731 wakaba 1.8
2732     lang:Perl {
2733     $at-><AS::ATDef.defaultType> (<C::ATDef.FIXED_DEFAULT>);
2734     }
2735 wakaba 1.4
2736     ~ (LIT) {
2737     my $vals;
2738     lang:Perl {
2739 wakaba 1.8 $vals = {nodes => [], value => ''};
2740 wakaba 1.4 }
2741    
2742     &_AttributeValueSpecification_ ($doc => $doc, $vals => $vals);
2743    
2744 wakaba 1.8 lang:Perl {
2745     for (@{$vals->{nodes}}) {
2746     $at-><M::Node.appendChild> ($_);
2747     }
2748     }
2749    
2750 wakaba 1.4 ~ (LIT) {
2751     ?lexmode AttlistDeclaration;
2752     } else {
2753     ?lexmode AttlistDeclaration;
2754     }
2755     } (LITA) {
2756     my $vals;
2757     lang:Perl {
2758 wakaba 1.8 $vals = {nodes => [], value => ''};
2759 wakaba 1.4 }
2760    
2761     &_AttributeValueSpecificationA_ ($doc => $doc, $vals => $vals);
2762    
2763 wakaba 1.8 lang:Perl {
2764     for (@{$vals->{nodes}}) {
2765     $at-><M::Node.appendChild> ($_);
2766     }
2767     }
2768    
2769     ~ (LITA) {
2770 wakaba 1.4 ?lexmode AttlistDeclaration;
2771     } else {
2772     ?lexmode AttlistDeclaration;
2773     }
2774     }
2775     }
2776    
2777     } (LIT) {
2778     my $vals;
2779     lang:Perl {
2780 wakaba 1.8 $at-><AS::ATDef.defaultType> (<C::ATDef.EXPLICIT_DEFAULT>);
2781     $vals = {nodes => [], value => ''};
2782 wakaba 1.4 }
2783    
2784     &_AttributeValueSpecification_ ($doc => $doc, $vals => $vals);
2785    
2786 wakaba 1.8 lang:Perl {
2787     for (@{$vals->{nodes}}) {
2788     $at-><M::Node.appendChild> ($_);
2789     }
2790     }
2791    
2792 wakaba 1.4 ~ (LIT) {
2793     ?lexmode AttlistDeclaration;
2794     } else {
2795     ?lexmode AttlistDeclaration;
2796     }
2797     } (LITA) {
2798     my $vals;
2799     lang:Perl {
2800 wakaba 1.8 $at-><AS::ATDef.defaultType> (<C::ATDef.EXPLICIT_DEFAULT>);
2801     $vals = {nodes => [], value => ''};
2802 wakaba 1.4 }
2803    
2804     &_AttributeValueSpecificationA_ ($doc => $doc, $vals => $vals);
2805    
2806 wakaba 1.8 lang:Perl {
2807     for (@{$vals->{nodes}}) {
2808     $at-><M::Node.appendChild> ($_);
2809     }
2810     }
2811    
2812 wakaba 1.4 ~ (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 wakaba 1.11 /*
2831     Entity declaration
2832     */
2833 wakaba 1.4 rule _EntityDeclaration ($doc) {
2834     // ~ (MDO) { }
2835     // ~ (Name == ENTITY) { }
2836    
2837     ~ (S) { }
2838    
2839 wakaba 1.6 my $decl;
2840 wakaba 1.11 lang:Perl { $decl = { name => '#ILLEGAL' }; }
2841 wakaba 1.6
2842 wakaba 1.4 ~? (PERO) {
2843     ~ (S) { }
2844 wakaba 1.6 lang:Perl {
2845     $decl->{is_param_entity} = true;
2846     }
2847 wakaba 1.4 }
2848    
2849     ~ (Name) {
2850 wakaba 1.6 lang:Perl ($v => $token.value) {
2851     $decl->{name} = $v;
2852     }
2853 wakaba 1.4 }
2854    
2855 wakaba 1.11 lang:Perl {
2856     $decl->{node} = $self->{docx}-><M::DocumentXDoctype.createGeneralEntity>
2857     ($decl->{name});
2858     ## TODO: Parameter entity...
2859     }
2860    
2861 wakaba 1.4 ~ (S) { }
2862    
2863     ~ (LIT) {
2864 wakaba 1.6 &_EntityValue ($doc => $doc, $decl => $decl);
2865 wakaba 1.4 } (LITA) {
2866 wakaba 1.6 &_EntityValueA ($doc => $doc, $decl => $decl);
2867 wakaba 1.4 } (Name == 'PUBLIC') {
2868     ~ (S) { }
2869    
2870 wakaba 1.6 &PubidLiteral ($doc => $doc, $decl => $decl);
2871 wakaba 1.4
2872     ~ (S) { }
2873    
2874 wakaba 1.6 &SystemLiteral ($doc => $doc, $decl => $decl);
2875 wakaba 1.4 } (Name == 'SYSTEM') {
2876     ~ (S) { }
2877    
2878 wakaba 1.6 &SystemLiteral ($doc => $doc, $decl => $decl);
2879 wakaba 1.4 }
2880    
2881     ~? (S) {
2882     ~? (Name == 'NDATA') {
2883     // TODO: error if parameter entity
2884    
2885     ~ (S) { }
2886    
2887     ~ (Name) {
2888 wakaba 1.6 lang:Perl ($v => $token.value) {
2889     $decl->{notation} = $v;
2890 wakaba 1.11 $decl->{node}-><AG::x|Entity.notationName> ($v);
2891 wakaba 1.6 }
2892 wakaba 1.4 }
2893    
2894     ~? (S) { }
2895     }
2896     }
2897    
2898 wakaba 1.6 lang:Perl {
2899     if ($self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'}
2900     ->{$decl->{name}}) {
2901 wakaba 1.11 ## TODO: warning
2902     ## TODO: predefined entity error check
2903 wakaba 1.6 } else {
2904     $self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'}
2905     ->{$decl->{name}} = $decl;
2906 wakaba 1.11 $self->{dtdef}-><M::DTDef.setGeneralEntityNode> ($decl->{node})
2907     unless $decl->{is_param_entity};
2908 wakaba 1.6 }
2909     }
2910    
2911 wakaba 1.4 ~ (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 wakaba 1.11 rule _EntityValue ($decl) {
2964 wakaba 1.4 ?lexmode EntityValue;
2965    
2966     my $vals;
2967 wakaba 1.6 my $reptxt;
2968 wakaba 1.4 lang:Perl {
2969     $vals = [];
2970 wakaba 1.6 $reptxt = '';
2971 wakaba 1.4 }
2972    
2973     ~* (STRING) {
2974 wakaba 1.6 lang:Perl ($v => $token.value) {
2975     $reptxt .= $v;
2976     }
2977 wakaba 1.4 } (PERO) {
2978     ?lexmode EntityDeclaration;
2979 wakaba 1.6
2980     // TODO: Expand or wferror if internal subset
2981 wakaba 1.4
2982     ~ (Name) {
2983    
2984     }
2985    
2986     ~ (REFC) {
2987     ?lexmode EntityValue;
2988     } else {
2989     ?lexmode EntityValue;
2990     }
2991     } (HCRO) {
2992 wakaba 1.11 &_HexadecimalCharacterReferenceEV_ ($vals => $vals);
2993 wakaba 1.4
2994 wakaba 1.6 lang:Perl {
2995 wakaba 1.11 $reptxt .= $vals->[-1];
2996 wakaba 1.6 }
2997    
2998 wakaba 1.4 ~ (REFC) {
2999     ?lexmode EntityValue;
3000     } else {
3001     ?lexmode EntityValue;
3002     }
3003     } (CRO) {
3004 wakaba 1.11 &_NumericCharacterReferenceEV_ ($vals => $vals);
3005 wakaba 1.6
3006     lang:Perl {
3007 wakaba 1.11 $reptxt .= $vals->[-1];
3008 wakaba 1.6 }
3009 wakaba 1.4
3010     ~ (REFC) {
3011     ?lexmode EntityValue;
3012     } else {
3013     ?lexmode EntityValue;
3014     }
3015     } (ERO) {
3016 wakaba 1.11 &_GeneralEntityReferenceEV_ ($vals => $vals);
3017 wakaba 1.4
3018 wakaba 1.6 lang:Perl {
3019 wakaba 1.11 $reptxt .= '&' . $vals->[-1] . ';';
3020 wakaba 1.6 }
3021    
3022 wakaba 1.4 ~ (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 wakaba 1.6
3037     lang:Perl {
3038     $decl->{reptxt} = \$reptxt;
3039     }
3040 wakaba 1.4 } // _EntityValue
3041    
3042 wakaba 1.11 rule _EntityValueA ($decl) {
3043 wakaba 1.4 ?lexmode EntityValueA;
3044    
3045     my $vals;
3046 wakaba 1.6 my $reptxt;
3047 wakaba 1.4 lang:Perl {
3048     $vals = [];
3049 wakaba 1.6 $reptxt = '';
3050 wakaba 1.4 }
3051    
3052     ~* (STRING) {
3053 wakaba 1.6 lang:Perl ($v => $token.value) {
3054     $reptxt .= $v;
3055     }
3056 wakaba 1.4 } (PERO) {
3057     ?lexmode EntityDeclaration;
3058    
3059 wakaba 1.6 // TODO: implement this
3060 wakaba 1.4 ~ (Name) {
3061    
3062     }
3063    
3064     ~ (REFC) {
3065     ?lexmode EntityValueA;
3066     } else {
3067     ?lexmode EntityValueA;
3068     }
3069     } (HCRO) {
3070 wakaba 1.11 &_HexadecimalCharacterReferenceEV_ ($vals => $vals);
3071 wakaba 1.4
3072 wakaba 1.6 lang:Perl {
3073 wakaba 1.11 $reptxt .= $vals->[-1];
3074 wakaba 1.6 }
3075    
3076    
3077 wakaba 1.4 ~ (REFC) {
3078     ?lexmode EntityValueA;
3079     } else {
3080     ?lexmode EntityValueA;
3081     }
3082     } (CRO) {
3083 wakaba 1.11 &_NumericCharacterReferenceEV_ ($vals => $vals);
3084 wakaba 1.4
3085 wakaba 1.6 lang:Perl {
3086 wakaba 1.11 $reptxt .= $vals->[-1];
3087 wakaba 1.6 }
3088    
3089 wakaba 1.4 ~ (REFC) {
3090     ?lexmode EntityValueA;
3091     } else {
3092     ?lexmode EntityValueA;
3093     }
3094     } (ERO) {
3095 wakaba 1.11 &_GeneralEntityReferenceEV_ ($vals => $vals);
3096 wakaba 1.4
3097 wakaba 1.6 lang:Perl {
3098 wakaba 1.11 $reptxt .= '&' . $vals->[-1] . ';';
3099 wakaba 1.6 }
3100    
3101 wakaba 1.4 ~ (REFC) {
3102     ?lexmode EntityValueA;
3103     } else {
3104     ?lexmode EntityValueA;
3105     }
3106     }
3107    
3108     ~ (LITA) {
3109     ?lexmode MarkupDeclaration;
3110     } else {
3111     ?lexmode MarkupDeclaration;
3112     }
3113 wakaba 1.6
3114     lang:Perl {
3115     $decl->{reptxt} = \$reptxt;
3116     }
3117 wakaba 1.4 } // _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 wakaba 1.1
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 wakaba 1.4 } // NameChar
3329    
3330     lexmode Name
3331     : extends => 'NameChar'
3332     {
3333 wakaba 1.1 Name : value := $NameStartChar11 $NameChar11*;
3334     } // Name
3335 wakaba 1.4
3336     lexmode Nmtoken
3337     : extends => 'NameChar'
3338     {
3339     Nmtoken : value := $NameChar11*;
3340     } // Nmtoken
3341 wakaba 1.1
3342     /*
3343 wakaba 1.14 S
3344 wakaba 1.1 */
3345     lexmode S {
3346 wakaba 1.14 $s := [U+0009 U+000A U+000D U+0020];
3347     S := $s+;
3348 wakaba 1.1 } // 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 wakaba 1.14 XDO := ['<'] ['?'] ['x'] ['m'] ['l'] $s+;
3409 wakaba 1.1 } // 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 wakaba 1.15 ?default-token STRING : value;
3426 wakaba 1.1 } // CommentDeclaration
3427    
3428     /*
3429     Processing instruction name and |S| scanning mode
3430     */
3431     lexmode PIName
3432     : standalone
3433     : extends => 'Name'
3434     : extends => 'S'
3435     {
3436     /*
3437     Processing instruction close
3438     */
3439     PIC := ['?'] ['>'];
3440     } // PIName
3441    
3442     /*
3443     Processing instruction data scanning mode
3444     */
3445     lexmode PIData
3446     : standalone
3447     {
3448     /*
3449     Processing instruction close
3450     */
3451     PIC := ['?'] ['>'];
3452    
3453     /*
3454     Processing instruction target data
3455     */
3456 wakaba 1.2 ?default-token DATA : value;
3457 wakaba 1.1 } // PIData
3458    
3459     /*
3460     Content of element scanning mode
3461     */
3462     lexmode ElementContent
3463     : standalone
3464     {
3465     /*
3466     Start tag open
3467     */
3468     STAGO := ['<'];
3469    
3470     /*
3471     End tag open
3472     */
3473     ETAGO := ['<'] ['/'];
3474    
3475     /*
3476     Hexadecimal character reference open
3477     */
3478     HCRO := ['&'] ['#'] ['x'];
3479    
3480     /*
3481     Numeric character reference open
3482     */
3483     CRO := ['&'] ['#'];
3484    
3485     /*
3486     General entity reference open
3487     */
3488     ERO := ['&'];
3489    
3490     /*
3491     Comment declaration open
3492     */
3493     CDO := ['<'] ['!'] ['-'] ['-'];
3494    
3495     /*
3496     CDATA section open
3497     */
3498     CDSO := ['<'] ['!'] ['[']
3499     ['C'] ['D'] ['A'] ['T'] ['A'] ['['];
3500    
3501     /*
3502     Processing instruction open
3503     */
3504     PIO := ['<'] ['?'];
3505 wakaba 1.2
3506     /*
3507     Markup section end
3508     */
3509     MSE := [']'] [']'] ['>'];
3510    
3511     /*
3512     Character data
3513     */
3514     /*
3515     Character data and/or |MSE|
3516     */
3517     ?default-token CharData : value;
3518 wakaba 1.1 } // ElementContent
3519    
3520     /*
3521     CDATA section content scanning mode
3522     */
3523     lexmode CDATASectionContent
3524     : standalone
3525     {
3526     /*
3527     Markup section end
3528     */
3529     MSE := [']'] [']'] ['>'];
3530    
3531     /*
3532     Character data
3533 wakaba 1.2 */
3534     ?default-token CData : value;
3535 wakaba 1.1 } // CDATASectionContent
3536    
3537     lexmode EntityReference
3538     : standalone
3539     : extends => 'Name'
3540     {
3541     /*
3542     Reference close
3543     */
3544     REFC := [';'];
3545     } // EntityReference
3546    
3547     lexmode NumericCharacterReference
3548     : standalone
3549     {
3550     /*
3551     Decimal number
3552     */
3553     $digit := ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9'];
3554     NUMBER : value := $digit+;
3555    
3556     /*
3557     Reference close
3558     */
3559     REFC := [';'];
3560     } // NumericCharacterReference
3561    
3562     lexmode HexadecimalCharacterReference
3563     : standalone
3564     {
3565     /*
3566     Hexadecimal number
3567     */
3568     $hexdigit := ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
3569     'A' 'B' 'C' 'D' 'E' 'F'
3570     'a' 'b' 'c' 'd' 'e' 'f'];
3571     Hex : value := $hexdigit+;
3572    
3573     /*
3574     Reference close
3575     */
3576     REFC := [';'];
3577     } // HexadecimalCharacterReference
3578    
3579 wakaba 1.3 lexmode XMLDeclaration
3580     : standalone
3581     : extends => 'Name'
3582     : extends => 'S'
3583     {
3584    
3585     /*
3586     Value indicator
3587     */
3588     VI := ['='];
3589    
3590     /*
3591     Literal open
3592     */
3593     LIT := ['"'];
3594     LITA := [U+0027];
3595    
3596     /*
3597     Processing instruction close
3598     */
3599     PIC := ['?'] ['>'];
3600     } // XMLDeclaration
3601    
3602 wakaba 1.1 lexmode StartTag
3603     : standalone
3604     : extends => 'Name'
3605     : extends => 'S'
3606     {
3607    
3608     /*
3609     Value indicator
3610     */
3611     VI := ['='];
3612    
3613     /*
3614     Literal open
3615     */
3616     LIT := ['"'];
3617     LITA := [U+0027];
3618    
3619     /*
3620     Tag close
3621     */
3622     TAGC := ['>'];
3623    
3624     /*
3625 wakaba 1.6 Null end-tag enabled start-tag close
3626 wakaba 1.1 */
3627 wakaba 1.6 NESTC := ['/'];
3628 wakaba 1.1 } // StartTag
3629    
3630     lexmode EndTag
3631     : standalone
3632     : extends => 'Name'
3633     : extends => 'S'
3634     {
3635     /*
3636     Tag close
3637     */
3638     TAGC := ['>'];
3639     } // EndTag
3640    
3641     lexmode AttributeValueLiteral_ {
3642     ERO := ['&'];
3643     CRO := ['&'] ['#'];
3644     HCRO := ['&'] ['#'] ['x'];
3645     } // AttributeValueLiteral_
3646    
3647     lexmode AttributeValueLiteral
3648     : standalone
3649     : extends => 'AttributeValueLiteral_'
3650     {
3651     LIT := ['"'];
3652 wakaba 1.3 STRING : value := [^'"' '&' '<']+;
3653 wakaba 1.1 } // AttributeValueLiteral
3654    
3655     lexmode AttributeValueLiteralA
3656     : standalone
3657     : extends => 'AttributeValueLiteral_'
3658     {
3659 wakaba 1.4 LITA := [U+0027];
3660 wakaba 1.3 STRING : value := [^U+0027 '&' '<']+;
3661 wakaba 1.1 } // AttributeValueLiteralA
3662 wakaba 1.11
3663     lexmode AttributeValueLiteralE
3664     : standalone
3665     : extends => 'AttributeValueLiteral_'
3666     {
3667     STRING : value := [^'&' '<']+;
3668     } // AttributeValueLiteralE
3669 wakaba 1.4
3670     lexmode EntityValue_ {
3671     PERO := ['%'];
3672     ERO := ['&'];
3673     CRO := ['&'] ['#'];
3674     HCRO := ['&'] ['#'] ['x'];
3675     } // EntityValue_
3676    
3677     lexmode EntityValue
3678     : standalone
3679     : extends => 'EntityValue_'
3680     {
3681     LIT := ['"'];
3682     STRING : value := [^'"' '&' '%']+;
3683     } // EntityValue
3684    
3685     lexmode EntityValueA
3686     : standalone
3687     : extends => 'EntityValue_'
3688     {
3689     LITA := [U+0027];
3690     STRING : value := [^U+0027 '&' '%']+;
3691     } // EntityValueA
3692    
3693     lexmode SystemLiteral
3694     : standalone
3695     {
3696     LIT := ['"'];
3697     ?default-token STRING : value;
3698     } // SystemLiteral
3699    
3700     lexmode SystemLiteralA
3701     : standalone
3702     {
3703     LITA := [U+0027];
3704     ?default-token STRING : value;
3705     } // SystemLiteralA
3706    
3707     lexmode DTD
3708     : standalone
3709     : extends => 'S'
3710     {
3711     /*
3712     Markup declaration open
3713     */
3714     MDO := ['<'] ['!'];
3715    
3716     /*
3717     Comment declaration open
3718     */
3719     CDO := ['<'] ['!'] ['-'] ['-'];
3720    
3721     /*
3722     Processing instruction open
3723     */
3724     PIO := ['<'] ['?'];
3725    
3726     /*
3727     Parameter entity reference open
3728     */
3729     PERO := ['%'];
3730    
3731     /*
3732     Declaration subset close
3733     */
3734     DSC := [']'];
3735    
3736     /*
3737     Contition section open
3738     */
3739     CSO := ['<'] ['!'] ['['];
3740     } // DTD
3741    
3742     /*
3743     Markup declaration scanning mode
3744    
3745     This mode is used to recognize |MDC| that terminates
3746     a comment declaration as well as the base |lexmode|
3747     for e.g. document type declaration scanning mode.
3748     */
3749     lexmode MarkupDeclaration
3750     : standalone
3751     : extends => 'Name'
3752     : extends => 'S'
3753     {
3754     /*
3755     Markup declaration close
3756     */
3757     MDC := ['>'];
3758    
3759     /*
3760     Literal open
3761     */
3762     LIT := ['"'];
3763    
3764     /*
3765     Alternative literal open
3766     */
3767     LITA := [U+0027];
3768    
3769     /*
3770     Parameter entity reference open
3771     */
3772     PERO := ['%'];
3773    
3774     /*
3775     Declaration subset open
3776     */
3777     DSO := ['['];
3778     } // MarkupDeclaration
3779    
3780     lexmode ElementDeclaration
3781     : standalone
3782     : extends => 'MarkupDeclaration'
3783     {
3784     /*
3785     Model group open
3786     */
3787     MGO := ['('];
3788    
3789     /*
3790     Model group close
3791     */
3792     MGC := [')'];
3793    
3794     /*
3795     Reserved name indicator
3796     */
3797     RNI := ['#'];
3798    
3799     /*
3800     Occurence indicators
3801     */
3802     OPT := ['?'];
3803     REP := ['*'];
3804     PLUS := ['+'];
3805    
3806     /*
3807     Connectors
3808     */
3809     OR := ['|'];
3810     SEQ := [','];
3811     } // ElementDeclaration
3812    
3813     lexmode AttlistDeclaration
3814     : standalone
3815     : extends => 'MarkupDeclaration'
3816     {
3817     /*
3818     Enumeration group open
3819     */
3820     EGO := ['('];
3821    
3822     /*
3823     Enumeration group close
3824     */
3825     EGC := [')'];
3826    
3827     /*
3828     Enumeration choice delimiter
3829     */
3830     OR := ['|'];
3831    
3832     /*
3833     Reserved name indicator
3834     */
3835     RNI := ['#'];
3836     } // AttlistDeclaration
3837    
3838     lexmode Enumeration
3839     : standalone
3840     : extends => 'Nmtoken'
3841     : extends => 'S'
3842     {
3843     /*
3844     Enumeration group close
3845     */
3846     EGC := [')'];
3847    
3848     /*
3849     Enumeration choice delimiter
3850     */
3851     OR := ['|'];
3852     } // Enumeration
3853    
3854 wakaba 1.1
3855     token-error default : default {
3856     lang:Perl {
3857 wakaba 1.3 my $location;
3858     __CODE{xp|get-location-from-token::
3859     $token => {$token},
3860     $result => {$location},
3861     }__;
3862     my $continue = __DOMCore:ERROR{xp|wf-syntax-error::
3863 wakaba 1.1 xp|error-token => {$token},
3864     DOMCore|location => {$location},
3865     }__;
3866     unless ($continue) {
3867     __EXCEPTION{DOMLS|PARSE_ERR::
3868     }__;
3869     }
3870     $self->{has_error} = true;
3871     }
3872     } // default
3873 wakaba 1.5
3874     @XMLTests:
3875     @@XMLTest:
3876 wakaba 1.15 @@@QName: xp.char.xml10.test
3877     @@@DEnt:
3878     @@@@test:value:
3879     <?xml version="1.0"?>
3880     <p>$u0009$u000A$u000D$u0020$uD7FF$uE000$uFFFD$U00010000$U0010FFFF</p>
3881     @@@test:domTree:
3882     document {
3883     xml-version: '1.0';
3884     element {
3885     text-content: U+0009 U+000A U+000A U+0020 U+D7FF
3886     U+E000 U+FFFD U+10000 U+10FFFF;
3887     }
3888     }
3889     @@XMLTest:
3890     @@@QName: xp.char.xml11.test
3891     @@@DEnt:
3892     @@@@test:value:
3893     <?xml version="1.1"?>
3894     <p>$u0009$u000A$u000D$u0020$uD7FF$uE000$uFFFD$U00010000$U0010FFFF</p>
3895     @@@test:domTree:
3896     document {
3897     xml-version: '1.1';
3898     element {
3899     text-content: U+0009 U+000A U+000A U+0020 U+D7FF
3900     U+E000 U+FFFD U+10000 U+10FFFF;
3901     }
3902     }
3903     @@XMLTest:
3904     @@@QName: xp.char.xml10.c0.test
3905     @@@DEnt:
3906     @@@@test:value:
3907     <?xml version="1.0"?>
3908     <p>$u0000$u0001$u0002$u0003$u0004$u0005$u0006$u0007$u0008$u000B$
3909     $u000C$u000E$u000F$u0010$u0011$u0012$u0013$u0014$u0015$u0016$
3910     $u0017$u0018$u0019$u001A$u001B$u001C$u001D$u001E$u001F</p>
3911     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 4); } /* U+0000 */
3912     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 5); } /* U+0001 */
3913     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 6); } /* U+0002 */
3914     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 7); } /* U+0003 */
3915     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 8); } /* U+0004 */
3916     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 9); } /* U+0005 */
3917     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 10); } /* U+0006 */
3918     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 11); } /* U+0007 */
3919     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 12); } /* U+0008 */
3920     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 13); } /* U+000B */
3921     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 14); } /* U+000C */
3922     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 15); } /* U+000E */
3923     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 16); } /* U+000F */
3924     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 17); } /* U+0010 */
3925     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 18); } /* U+0011 */
3926     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 19); } /* U+0012 */
3927     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 20); } /* U+0013 */
3928     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 21); } /* U+0014 */
3929     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 22); } /* U+0015 */
3930     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 23); } /* U+0016 */
3931     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 24); } /* U+0017 */
3932     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 25); } /* U+0018 */
3933     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 26); } /* U+0019 */
3934     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 27); } /* U+001A */
3935     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 28); } /* U+001B */
3936     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 29); } /* U+001C */
3937     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 30); } /* U+001D */
3938     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 31); } /* U+001E */
3939     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 32); } /* U+001F */
3940     @@XMLTest:
3941     @@@QName: xp.char.xml11.c0.test
3942     @@@DEnt:
3943     @@@@test:value:
3944     <?xml version="1.1"?>
3945     <p>$u0000$u0001$u0002$u0003$u0004$u0005$u0006$u0007$u0008$u000B$
3946     $u000C$u000E$u000F$u0010$u0011$u0012$u0013$u0014$u0015$u0016$
3947     $u0017$u0018$u0019$u001A$u001B$u001C$u001D$u001E$u001F</p>
3948     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 4); } /* U+0000 */
3949     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 5); } /* U+0001 */
3950     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 6); } /* U+0002 */
3951     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 7); } /* U+0003 */
3952     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 8); } /* U+0004 */
3953     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 9); } /* U+0005 */
3954     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 10); } /* U+0006 */
3955     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 11); } /* U+0007 */
3956     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 12); } /* U+0008 */
3957     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 13); } /* U+000B */
3958     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 14); } /* U+000C */
3959     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 15); } /* U+000E */
3960     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 16); } /* U+000F */
3961     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 17); } /* U+0010 */
3962     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 18); } /* U+0011 */
3963     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 19); } /* U+0012 */
3964     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 20); } /* U+0013 */
3965     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 21); } /* U+0014 */
3966     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 22); } /* U+0015 */
3967     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 23); } /* U+0016 */
3968     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 24); } /* U+0017 */
3969     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 25); } /* U+0018 */
3970     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 26); } /* U+0019 */
3971     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 27); } /* U+001A */
3972     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 28); } /* U+001B */
3973     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 29); } /* U+001C */
3974     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 30); } /* U+001D */
3975     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 31); } /* U+001E */
3976     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 32); } /* U+001F */
3977     @@XMLTest:
3978     @@@QName: xp.char.xml10.c1.test
3979     @@@DEnt:
3980     @@@@test:value:
3981     <?xml version="1.0"?>
3982     <p>$u007F$u0080$u0081$u0082$u0083$u0084$u0086$u0087$u0088$
3983     $u0089$u008A$u008B$u008C$
3984     $u008D$u008E$u008F$u0090$u0091$u0092$u0093$u0094$u0095$u0096$
3985     $u0097$u0098$u0099$u009A$u009B$u009C$u009D$u009E$u009F$u0085</p>
3986     @@@test:domTree:
3987     document {
3988     xml-version: '1.0';
3989     element {
3990     text-content: U+007F U+0080 U+0081 U+0082 U+0083 U+0084 U+0086
3991     U+0087 U+0088 U+0089 U+008A U+008B U+008C U+008D
3992     U+008E U+008F U+0090 U+0091 U+0092 U+0093 U+0094
3993     U+0095 U+0096 U+0097 U+0098 U+0099 U+009A U+009B
3994     U+009C U+009D U+009E U+009F U+0085;
3995     }
3996     }
3997     @@XMLTest:
3998     @@@QName: xp.char.xml11.c1.test
3999     @@@DEnt:
4000     @@@@test:value:
4001     <?xml version="1.1"?>
4002     <p>$u007F$u0080$u0081$u0082$u0083$u0084$u0086$u0087$u0088$
4003     $u0089$u008A$u008B$u008C$
4004     $u008D$u008E$u008F$u0090$u0091$u0092$u0093$u0094$u0095$u0096$
4005     $u0097$u0098$u0099$u009A$u009B$u009C$u009D$u009E$u009F$u0085</p>
4006     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 4); } /* U+007F */
4007     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 5); } /* U+0080 */
4008     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 6); } /* U+0081 */
4009     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 7); } /* U+0082 */
4010     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 8); } /* U+0083 */
4011     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 9); } /* U+0084 */
4012     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 10); } /* U+0086 */
4013     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 11); } /* U+0087 */
4014     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 12); } /* U+0088 */
4015     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 13); } /* U+0089 */
4016     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 14); } /* U+008A */
4017     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 15); } /* U+008B */
4018     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 16); } /* U+008C */
4019     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 17); } /* U+008D */
4020     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 18); } /* U+008E */
4021     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 19); } /* U+008F */
4022     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 20); } /* U+0090 */
4023     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 21); } /* U+0091 */
4024     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 22); } /* U+0092 */
4025     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 23); } /* U+0093 */
4026     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 24); } /* U+0094 */
4027     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 25); } /* U+0095 */
4028     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 26); } /* U+0096 */
4029     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 27); } /* U+0097 */
4030     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 28); } /* U+0098 */
4031     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 29); } /* U+0099 */
4032     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 30); } /* U+009A */
4033     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 31); } /* U+009B */
4034     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 32); } /* U+009C */
4035     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 33); } /* U+009D */
4036     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 34); } /* U+009E */
4037     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 35); } /* U+009F */
4038    
4039     @@XMLTest:
4040 wakaba 1.12 @@@QName: xp.syntax.empty.test
4041     @@@DEnt:
4042     @@@@test:value: \
4043     @@@c:erred:
4044     <[[xp:wf-syntax-error]]> { (1, 1); }
4045     @@XMLTest:
4046     @@@QName: xp.syntax.space.test
4047     @@@DEnt:
4048 wakaba 1.13 @@@@test:value: \
4049 wakaba 1.12 @@@c:erred:
4050     <[[xp:wf-syntax-error]]> { (1, 4); }
4051     @@XMLTest:
4052     @@@QName: xp.syntax.newlines.test
4053     @@@DEnt:
4054     @@@@test:value:
4055     \
4056     \
4057     \
4058     @@@c:erred:
4059     <[[xp:wf-syntax-error]]> { (3, 1); }
4060    
4061     @@XMLTest:
4062 wakaba 1.6 @@@QName: xp.only.docel.test
4063 wakaba 1.5 @@@DEnt:
4064     @@@@test:value:
4065     <p></p>
4066     @@@test:domTree:
4067     document {
4068     xml-version: '1.0';
4069 wakaba 1.6 xml-encoding: null;
4070     xml-standalone: false;
4071     element {
4072     namespace-uri: null;
4073     prefix: null;
4074     local-name: 'p';
4075     text-content: '';
4076     }
4077     }
4078     @@XMLTest:
4079     @@@QName: xp.only.docel.emptyelemtag.test
4080     @@@DEnt:
4081     @@@@test:value:
4082     <p/>
4083     @@@test:domTree:
4084     document {
4085     xml-version: '1.0';
4086     xml-encoding: null;
4087     xml-standalone: false;
4088 wakaba 1.5 element {
4089     namespace-uri: null;
4090     prefix: null;
4091     local-name: 'p';
4092     text-content: '';
4093     }
4094     }
4095 wakaba 1.15 @@XMLTest:
4096     @@@QName: xp.root.s.1.test
4097     @@@DEnt:
4098     @@@@test:value:
4099     <?xml version="1.0"?>$u0020$u000D$u000A$u0009
4100     <p></p>
4101     @@@test:domTree:
4102     document {
4103     element { }
4104     }
4105    
4106     @@XMLTest:
4107     @@@QName: xp.Name.1.test
4108     @@@DEnt:
4109     @@@@test:value: <name/>
4110     @@@test:domTree:
4111     document {
4112     element {
4113     node-name: 'name';
4114     }
4115     }
4116     @@XMLTest:
4117     @@@QName: xp.Name.2.test
4118     @@@DEnt:
4119     @@@@test:value: <name0/>
4120     @@@test:domTree:
4121     document {
4122     element {
4123     node-name: 'name0';
4124     }
4125     }
4126     @@enImplNote:
4127     @@@ddid: xml11name
4128     @@@@:
4129     {TODO:: XML 1.1 Name tests required
4130     }
4131    
4132     @@XMLTest:
4133     @@@QName: xp.content.mse.1.test
4134     @@@DEnt:
4135     @@@@test:value:
4136     <p>]]></p>
4137     @@@c:erred:
4138     <[[xp|wf-syntax-error]]> { (1, 4)..(1, 6); }
4139     @@XMLTest:
4140     @@@QName: xp.content.mse.2.test
4141     @@@DEnt:
4142     @@@@test:value:
4143     <p>aaa]]>bbb</p>
4144     @@@c:erred:
4145     <[[xp|wf-syntax-error]]> { (1, 7)..(1, 9); }
4146    
4147     @@XMLTest:
4148     @@@QName: xp.root.comment.1.test
4149     @@@DEnt:
4150     @@@@test:value:
4151     <!--comment data-->
4152     <p/>
4153     @@@test:domTree:
4154     document {
4155     comment {
4156     data: 'comment data';
4157     }
4158     element { }
4159     }
4160     @@XMLTest:
4161     @@@QName: xp.root.comment.2.test
4162     @@@DEnt:
4163     @@@@test:value:
4164     <!---->
4165     <p/>
4166     @@@test:domTree:
4167     document {
4168     comment {
4169     data: '';
4170     }
4171     element { }
4172     }
4173     @@XMLTest:
4174     @@@QName: xp.root.after.pi.comment.1.test
4175     @@@DEnt:
4176     @@@@test:value:
4177     <?pi?>
4178     <!--comment data-->
4179     <p/>
4180     @@@test:domTree:
4181     document {
4182     pi { }
4183     comment {
4184     data: 'comment data';
4185     }
4186     element { }
4187     }
4188     @@XMLTest:
4189     @@@QName: xp.root.after.pi.comment.2.test
4190     @@@DEnt:
4191     @@@@test:value:
4192     <?pi?>
4193     <!---->
4194     <p/>
4195     @@@test:domTree:
4196     document {
4197     pi { }
4198     comment {
4199     data: '';
4200     }
4201     element { }
4202     }
4203     @@XMLTest:
4204     @@@QName: xp.root.after.element.comment.1.test
4205     @@@DEnt:
4206     @@@@test:value:
4207     <p/>
4208     <!--comment data-->
4209     @@@test:domTree:
4210     document {
4211     element { }
4212     comment {
4213     data: 'comment data';
4214     }
4215     }
4216     @@XMLTest:
4217     @@@QName: xp.root.after.element.comment.2.test
4218     @@@DEnt:
4219     @@@@test:value:
4220     <p/>
4221     <!---->
4222     @@@test:domTree:
4223     document {
4224     element { }
4225     comment {
4226     data: '';
4227     }
4228     }
4229     @@XMLTest:
4230     @@@QName: xp.doctype.intsubset.comment.1.test
4231     @@@DEnt:
4232     @@@@test:value:
4233     <!DOCTYPE a [
4234     <!--comment data-->
4235     ]>
4236     <p/>
4237     @@@test:domTree:
4238     document {
4239     document-type { }
4240     element { }
4241     }
4242     @@XMLTest:
4243     @@@QName: xp.doctype.intsubset.comment.2.test
4244     @@@DEnt:
4245     @@@@test:value:
4246     <!DOCTYPE a [
4247     <!---->
4248     ]>
4249     <p/>
4250     @@@test:domTree:
4251     document {
4252     document-type { }
4253     element { }
4254     }
4255     @@XMLTest:
4256     @@@QName: xp.doctype.intsubset.comment.3.test
4257     @@@DEnt:
4258     @@@@test:value:
4259     <!DOCTYPE a [
4260     <?pi?>
4261     <!---->
4262     ]>
4263     <p/>
4264     @@@test:domTree:
4265     document {
4266     document-type {
4267     pi { }
4268     }
4269     element { }
4270     }
4271     @@XMLTest:
4272     @@@QName: xp.content.comment.1.test
4273     @@@DEnt:
4274     @@@@test:value:
4275     <p><!--comment data--></p>
4276     @@@test:domTree:
4277     document {
4278     element {
4279     comment {
4280     data: 'comment data';
4281     }
4282     }
4283     }
4284     @@XMLTest:
4285     @@@QName: xp.content.comment.2.test
4286     @@@DEnt:
4287     @@@@test:value:
4288     <p><!----></p>
4289     @@@test:domTree:
4290     document {
4291     element {
4292     comment {
4293     data: '';
4294     }
4295     }
4296     }
4297     @@XMLTest:
4298     @@@QName: xp.content.comment.3.test
4299     @@@DEnt:
4300     @@@@test:value:
4301     <p>aaaaa<!---->bbbbb</p>
4302     @@@test:domTree:
4303     document {
4304     element {
4305     text {
4306     data: 'aaaaa';
4307     }
4308     comment {
4309     data: '';
4310     }
4311     text {
4312     data: 'bbbbb';
4313     }
4314     }
4315     }
4316     @@XMLTest:
4317     @@@QName: xp.content.comment.--.1.test
4318     @@@DEnt:
4319     @@@@test:value:
4320     <p><!--data--data--></p>
4321     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 12)..(1, 17); }
4322     @@XMLTest:
4323     @@@QName: xp.content.comment.---gt.test
4324     @@@DEnt:
4325     @@@@test:value:
4326     <p><!--data---></p>
4327     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 12)..(1, 15); }
4328 wakaba 1.13
4329     @@XMLTest:
4330     @@@QName: xp.xmldecl.version.1.0.test
4331     @@@DEnt:
4332     @@@@test:value:
4333     <?xml version="1.0"?>
4334     <p></p>
4335     @@@test:domTree:
4336     document {
4337     xml-version: '1.0';
4338     xml-encoding: null;
4339     xml-standalone: false;
4340     element { }
4341     }
4342     @@XMLTest:
4343     @@@QName: xp.xmldecl.version.1.0.lita.test
4344     @@@DEnt:
4345     @@@@test:value:
4346     <?xml version='1.0'?>
4347     <p></p>
4348     @@@test:domTree:
4349     document {
4350     xml-version: '1.0';
4351     xml-encoding: null;
4352     xml-standalone: false;
4353     element { }
4354     }
4355     @@XMLTest:
4356     @@@QName: xp.xmldecl.version.1.0.s.test
4357     @@@DEnt:
4358     @@@@test:value:
4359     <?xml version = "1.0" ?>
4360     <p></p>
4361     @@@test:domTree:
4362     document {
4363     xml-version: '1.0';
4364     xml-encoding: null;
4365     xml-standalone: false;
4366     element { }
4367     }
4368     @@XMLTest:
4369     @@@QName: xp.xmldecl.version.1.1.test
4370     @@@DEnt:
4371     @@@@test:value:
4372     <?xml version="1.1"?>
4373     <p></p>
4374     @@@test:domTree:
4375     document {
4376     xml-version: '1.1';
4377     xml-encoding: null;
4378     xml-standalone: false;
4379     element { }
4380     }
4381    
4382     @@XMLTest:
4383     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.test
4384     @@@DEnt:
4385     @@@@test:value:
4386     <?xml version="1.0" encoding="US-ascii"?>
4387     <p></p>
4388     @@@test:domTree:
4389     document {
4390     xml-version: '1.0';
4391     xml-encoding: 'US-ascii';
4392     xml-standalone: false;
4393     element { }
4394     }
4395     @@XMLTest:
4396     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.lita.test
4397     @@@DEnt:
4398     @@@@test:value:
4399     <?xml version="1.0" encoding='US-ascii'?>
4400     <p></p>
4401     @@@test:domTree:
4402     document {
4403     xml-version: '1.0';
4404     xml-encoding: 'US-ascii';
4405     xml-standalone: false;
4406     element { }
4407     }
4408     @@XMLTest:
4409     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.s.test
4410     @@@DEnt:
4411     @@@@test:value:
4412     <?xml version="1.0" encoding = "US-ascii" ?>
4413     <p></p>
4414     @@@test:domTree:
4415     document {
4416     xml-version: '1.0';
4417     xml-encoding: 'US-ascii';
4418     xml-standalone: false;
4419     element { }
4420     }
4421    
4422     @@XMLTest:
4423     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.yes.test
4424     @@@DEnt:
4425     @@@@test:value:
4426     <?xml version="1.0" encoding="us-ascii" standalone="yes"?>
4427     <p></p>
4428     @@@test:domTree:
4429     document {
4430     xml-version: '1.0';
4431     xml-encoding: 'us-ascii';
4432     xml-standalone: true;
4433     element { }
4434     }
4435     @@XMLTest:
4436     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.no.test
4437     @@@DEnt:
4438     @@@@test:value:
4439     <?xml version="1.0" encoding="us-ascii" standalone="no"?>
4440     <p></p>
4441     @@@test:domTree:
4442     document {
4443     xml-version: '1.0';
4444     xml-encoding: 'us-ascii';
4445     xml-standalone: false;
4446     element { }
4447     }
4448     @@XMLTest:
4449     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.yes.lita.test
4450     @@@DEnt:
4451     @@@@test:value:
4452     <?xml version="1.0" encoding="us-ascii" standalone='yes'?>
4453     <p></p>
4454     @@@test:domTree:
4455     document {
4456     xml-version: '1.0';
4457     xml-encoding: 'us-ascii';
4458     xml-standalone: true;
4459     element { }
4460     }
4461     @@XMLTest:
4462     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.yes.s.test
4463     @@@DEnt:
4464     @@@@test:value:
4465     <?xml version="1.0" encoding="us-ascii" standalone = "yes" ?>
4466     <p></p>
4467     @@@test:domTree:
4468     document {
4469     xml-version: '1.0';
4470     xml-encoding: 'us-ascii';
4471     xml-standalone: true;
4472     element { }
4473     }
4474 wakaba 1.14 @@XMLTest:
4475     @@@QName: xp.xmldecl.no.encoding.but.standalone.attr.test
4476     @@@DEnt:
4477     @@@@test:value:
4478     <?xml version="1.0" standalone="yes"?>
4479     <p></p>
4480     @@@test:domTree:
4481     document {
4482     xml-version: '1.0';
4483     xml-encoding: null;
4484     xml-standalone: true;
4485     element { }
4486     }
4487     @@XMLTest:
4488     @@@QName: xp.xmldecl.encoding.encname.test
4489     @@@DEnt:
4490     @@@@test:value:
4491     <?xml version="1.0" encoding="a-._01-"?>
4492     <p></p>
4493     @@@test:domTree:
4494     document {
4495     xml-version: '1.0';
4496     xml-encoding: 'a-._01-';
4497     xml-standalone: false;
4498     element { }
4499     }
4500    
4501     @@XMLTest:
4502     @@@QName: xp.xmldecl.no.s.no.attr.test
4503     @@@DEnt:
4504     @@@@test:value:
4505     <?xml?>
4506     <p></p>
4507     @@@c:erred:
4508     <[[xp:wf-pi-target-is-xml]]> { (1, 1)..(1, 5); }
4509     @@XMLTest:
4510     @@@QName: xp.xmldecl.s.no.attr.test
4511     @@@DEnt:
4512     @@@@test:value:
4513     <?xml ?>
4514     <p></p>
4515     @@@c:erred:
4516     <[[xp:wf-syntax-error]]> { (1, 8)..(1, 9); }
4517     @@XMLTest:
4518     @@@QName: xp.xmldecl.unknown.attr.test
4519     @@@DEnt:
4520     @@@@test:value:
4521     <?xml unknown="value"?>
4522     <p></p>
4523     @@@c:erred:
4524     <[[xp:wf-syntax-error]]> { (1, 8)..(1, 22); }
4525     @@XMLTest:
4526     @@@QName: xp.xmldecl.version.unknown.attr.test
4527     @@@DEnt:
4528     @@@@test:value:
4529     <?xml version="1.0" unknown="value"?>
4530     <p></p>
4531     @@@c:erred:
4532     <[[xp:wf-syntax-error]]> { (1, 21)..(1, 35); }
4533     @@XMLTest:
4534     @@@QName: xp.xmldecl.version.encoding.unknown.attr.test
4535     @@@DEnt:
4536     @@@@test:value:
4537     <?xml version="1.0" encoding="us-ascii" unknown="value"?>
4538     <p></p>
4539     @@@c:erred:
4540     <[[xp:wf-syntax-error]]> { (1, 41)..(1, 55); }
4541     @@XMLTest:
4542     @@@QName: xp.xmldecl.version.encoding.standalone.unknown.attr.test
4543     @@@DEnt:
4544     @@@@test:value:
4545     <?xml version="1.0" encoding="us-ascii" standalone="yes"
4546     unknown="value"?>
4547     <p></p>
4548     @@@c:erred:
4549     <[[xp:wf-syntax-error]]> { (2, 1)..(2, 15); }
4550     @@XMLTest:
4551     @@@QName: xp.xmldecl.no.version.but.encoding.attr.test
4552     @@@DEnt:
4553     @@@@test:value:
4554     <?xml encoding="us-ascii"?>
4555     <p></p>
4556     @@@c:erred:
4557     <[[xp:wf-syntax-error]]> { (1, 7)..(1, 25); }
4558     @@XMLTest:
4559     @@@QName: xp.xmldecl.no.version.but.standalone.attr.test
4560     @@@DEnt:
4561     @@@@test:value:
4562     <?xml standalone="yes"?>
4563     <p></p>
4564     @@@c:erred:
4565     <[[xp:wf-syntax-error]]> { (1, 7)..(1, 24); }
4566     @@XMLTest:
4567     @@@QName: xp.xmldecl.version.unsupported.test
4568     @@@DEnt:
4569     @@@@test:value:
4570     <?xml version="1.2"?>
4571     <p></p>
4572     @@@c:erred:
4573     <[[xp:wf-unsupported-xml-version]]> { (1, 7)..(1, 19); }
4574     @@XMLTest:
4575     @@@QName: xp.xmldecl.version.unsupported.2.test
4576     @@@DEnt:
4577     @@@@test:value:
4578     <?xml version=" 1.0 "?>
4579     <p></p>
4580     @@@c:erred:
4581     <[[xp:wf-unsupported-xml-version]]> { (1, 7)..(1, 21); }
4582     @@XMLTest:
4583     @@@QName: xp.xmldecl.version.unsupported.3.test
4584     @@@DEnt:
4585     @@@@test:value:
4586     <?xml version="01.00"?>
4587     <p></p>
4588     @@@c:erred:
4589     <[[xp:wf-unsupported-xml-version]]> { (1, 7)..(1, 21); }
4590     @@XMLTest:
4591     @@@QName: xp.xmldecl.encoding.malformed.1.test
4592     @@@DEnt:
4593     @@@@test:value:
4594     <?xml version="1.0" encoding="0088"?>
4595     <p></p>
4596     @@@c:erred:
4597     <[[xp:wf-malformed-enc-name]]> { (1, 21)..(1, 35); }
4598     @@XMLTest:
4599     @@@QName: xp.xmldecl.encoding.malformed.2.test
4600     @@@DEnt:
4601     @@@@test:value:
4602     <?xml version="1.0" encoding="D.V.D!"?>
4603     <p></p>
4604     @@@c:erred:
4605     <[[xp:wf-malformed-enc-name]]> { (1, 21)..(1, 38); }
4606     @@XMLTest:
4607     @@@QName: xp.xmldecl.standalone.malformed.1.test
4608     @@@DEnt:
4609     @@@@test:value:
4610     <?xml version="1.0" standalone="true"?>
4611     <p></p>
4612     @@@c:erred:
4613     <[[xp:wf-malformed-xml-standalone]]> { (1, 21)..(1, 38); }
4614     @@XMLTest:
4615     @@@QName: xp.xmldecl.standalone.malformed.2.test
4616     @@@DEnt:
4617     @@@@test:value:
4618     <?xml version="1.0" standalone="YES"?>
4619     <p></p>
4620     @@@c:erred:
4621     <[[xp:wf-malformed-xml-standalone]]> { (1, 21)..(1, 37); }
4622     @@XMLTest:
4623     @@@QName: xp.xmldecl.standalone.malformed.3.test
4624     @@@DEnt:
4625     @@@@test:value:
4626     <?xml version="1.0" standalone="no "?>
4627     <p></p>
4628     @@@c:erred:
4629     <[[xp:wf-malformed-xml-standalone]]> { (1, 21)..(1, 38); }
4630 wakaba 1.6
4631     @@XMLTest:
4632 wakaba 1.14 @@@QName: xp.no-xmldecl.xml...-pi.test
4633     @@@DEnt:
4634     @@@@test:value:
4635     <?xmldeclaration?>
4636     <a></a>
4637     @@@test:domTree:
4638     document {
4639     pi {
4640     node-name: 'xmldeclaration';
4641     node-value: '';
4642     }
4643     element { }
4644     }
4645     @@XMLTest:
4646     @@@QName: xp.no-xmldecl.xml...-pi.after.document.element.test
4647     @@@DEnt:
4648     @@@@test:value:
4649     <a></a>
4650     <?xmldeclaration?>
4651     @@@test:domTree:
4652     document {
4653     element { }
4654     pi {
4655     node-name: 'xmldeclaration';
4656     node-value: '';
4657     }
4658     }
4659     @@XMLTest:
4660     @@@QName: xp.no-xmldecl.xml...-pi.in.document.element.test
4661     @@@DEnt:
4662     @@@@test:value:
4663     <a>
4664     <?xmldeclaration?>
4665     </a>
4666     @@@test:domTree:
4667     document {
4668     element {
4669     text { }
4670     pi {
4671     node-name: 'xmldeclaration';
4672     node-value: '';
4673     }
4674     text { }
4675     }
4676     }
4677     @@XMLTest:
4678     @@@QName: xp.no-xmldecl.xml...-pi.in.doctype.test
4679     @@@DEnt:
4680     @@@@test:value:
4681     <!DOCTYPE a [
4682     <?xmldeclaration?>
4683     ]>
4684     <a></a>
4685     @@@test:domTree:
4686     document {
4687     document-type {
4688     pi {
4689     node-name: 'xmldeclaration';
4690     node-value: '';
4691     }
4692     }
4693     element { }
4694     }
4695    
4696     @@XMLTest:
4697     @@@QName: xp.XMLdecl.test
4698     @@@DEnt:
4699     @@@@test:value:
4700     <?XML version="1.0"?>
4701     <p></p>
4702     @@@c:erred:
4703     <[[xp:wf-pi-target-is-xml]]> { (1, 1)..(1, 5); }
4704     @@XMLTest:
4705     @@@QName: xp.Xmldecl.test
4706     @@@DEnt:
4707     @@@@test:value:
4708     <?Xml version="1.0"?>
4709     <p></p>
4710     @@@c:erred:
4711     <[[xp:wf-pi-target-is-xml]]> { (1, 1)..(1, 5); }
4712     @@XMLTest:
4713     @@@QName: xp.xmldecl.after.document.element.empty.test
4714     @@@DEnt:
4715     @@@@test:value:
4716     <p></p>
4717     <?xml?>
4718     @@@c:erred:
4719     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4720     @@XMLTest:
4721     @@@QName: xp.xmldecl.after.document.element.test
4722     @@@DEnt:
4723     @@@@test:value:
4724     <p></p>
4725     <?xml version="1.0"?>
4726     @@@c:erred:
4727     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4728     @@XMLTest:
4729     @@@QName: xp.xmldecl.in.element.empty.test
4730     @@@DEnt:
4731     @@@@test:value:
4732     <p>
4733     <?xml?>
4734     </p>
4735     @@@c:erred:
4736     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4737     @@XMLTest:
4738     @@@QName: xp.xmldecl.in.element.test
4739     @@@DEnt:
4740     @@@@test:value:
4741     <p>
4742     <?xml version="1.0"?>
4743     </p>
4744     @@@c:erred:
4745     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4746     @@XMLTest:
4747     @@@QName: xp.xmldecl.after.comment.test
4748     @@@DEnt:
4749     @@@@test:value:
4750     <!---->
4751     <?xml version="1.0"?>
4752     <p></p>
4753     @@@c:erred:
4754     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4755     @@XMLTest:
4756     @@@QName: xp.xmldecl.after.comment.empty.test
4757     @@@DEnt:
4758     @@@@test:value:
4759     <!---->
4760     <?xml?>
4761     <p></p>
4762     @@@c:erred:
4763     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4764     @@XMLTest:
4765     @@@QName: xp.xmldecl.after.pi.test
4766     @@@DEnt:
4767     @@@@test:value:
4768     <?xml-declaration?>
4769     <?xml version="1.0"?>
4770     <p></p>
4771     @@@c:erred:
4772     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4773     @@XMLTest:
4774     @@@QName: xp.xmldecl.after.pi.empty.test
4775     @@@DEnt:
4776     @@@@test:value:
4777     <?xml-declaration?>
4778     <?xml?>
4779     <p></p>
4780     @@@c:erred:
4781     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4782     @@XMLTest:
4783     @@@QName: xp.xmldecl.after.doctype.test
4784     @@@DEnt:
4785     @@@@test:value:
4786     <!DOCTYPE a>
4787     <?xml version="1.0"?>
4788     <p></p>
4789     @@@c:erred:
4790     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4791     @@XMLTest:
4792     @@@QName: xp.xmldecl.after.doctype.empty.test
4793     @@@DEnt:
4794     @@@@test:value:
4795     <!DOCTYPE a>
4796     <?xml?>
4797     <p></p>
4798     @@@c:erred:
4799     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4800     @@XMLTest:
4801     @@@QName: xp.xmldecl.in.doctype.test
4802     @@@DEnt:
4803     @@@@test:value:
4804     <!DOCTYPE a [
4805     <?xml version="1.0"?>
4806     ]>
4807     <p></p>
4808     @@@c:erred:
4809     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4810     @@XMLTest:
4811     @@@QName: xp.xmldecl.in.doctype.empty.test
4812     @@@DEnt:
4813     @@@@test:value:
4814     <!DOCTYPE a [
4815     <?xml?>
4816     ]>
4817     <p></p>
4818     @@@c:erred:
4819     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4820    
4821     @@XMLTest:
4822     @@@QName: xp.pi.before.element.empty.test
4823     @@@DEnt:
4824     @@@@test:value:
4825     <?target?>
4826     <a></a>
4827     @@@test:domTree:
4828     document {
4829     pi {
4830     node-name: 'target';
4831     node-value: '';
4832     }
4833     element { }
4834     }
4835     @@XMLTest:
4836     @@@QName: xp.pi.before.element.s.test
4837     @@@DEnt:
4838     @@@@test:value:
4839     <?target ?>
4840     <a></a>
4841     @@@test:domTree:
4842     document {
4843     pi {
4844     node-name: 'target';
4845     node-value: '';
4846     }
4847     element { }
4848     }
4849     @@XMLTest:
4850     @@@QName: xp.pi.before.element.string.test
4851     @@@DEnt:
4852     @@@@test:value:
4853     <?target string?>
4854     <a></a>
4855     @@@test:domTree:
4856     document {
4857     pi {
4858     node-name: 'target';
4859     node-value: 'string';
4860     }
4861     element { }
4862     }
4863     @@XMLTest:
4864     @@@QName: xp.pi.before.element.string.s.test
4865     @@@DEnt:
4866     @@@@test:value:
4867     <?target string ?>
4868     <a></a>
4869     @@@test:domTree:
4870     document {
4871     pi {
4872     node-name: 'target';
4873     node-value: 'string ';
4874     }
4875     element { }
4876     }
4877     @@XMLTest:
4878     @@@QName: xp.pi.before.element.gt.test
4879     @@@DEnt:
4880     @@@@test:value:
4881     <?target string>string?>
4882     <a></a>
4883     @@@test:domTree:
4884     document {
4885     pi {
4886     node-name: 'target';
4887     node-value: 'string>string';
4888     }
4889     element { }
4890     }
4891     @@XMLTest:
4892     @@@QName: xp.pi.doctype.empty.test
4893     @@@DEnt:
4894     @@@@test:value:
4895     <!DOCTYPE a [
4896     <?target?>
4897     ]>
4898     <a></a>
4899     @@@test:domTree:
4900     document {
4901     document-type {
4902     pi {
4903     node-name: 'target';
4904     node-value: '';
4905     }
4906     }
4907     element { }
4908     }
4909    
4910     @@XMLTest:
4911     @@@QName: xp.pi.no.target.test
4912     @@@DEnt:
4913     @@@@test:value:
4914     <??>
4915     <p></p>
4916     @@@c:erred:
4917     <[[xp:wf-syntax-error]]> { (1, 3)..(1, 4); }
4918     @@XMLTest:
4919     @@@QName: xp.pi.no.target.2.test
4920     @@@DEnt:
4921     @@@@test:value:
4922     <? ?>
4923     <p></p>
4924     @@@c:erred:
4925     <[[xp:wf-syntax-error]]> { (1, 3)..(1, 4); }
4926     @@XMLTest:
4927     @@@QName: xp.pi.bad.target.1.test
4928     @@@DEnt:
4929     @@@@test:value:
4930     <?target! ?>
4931     <p></p>
4932     @@@c:erred:
4933     <[[xp:wf-syntax-error]]> { (1, 9)..(1, 9); }
4934     @@XMLTest:
4935     @@@QName: xp.pi.bad.target.2.test
4936     @@@DEnt:
4937     @@@@test:value:
4938     <?0target ?>
4939     <p></p>
4940     @@@c:erred:
4941     <[[xp:wf-syntax-error]]> { (1, 3)..(1, 3); }
4942    
4943     @@XMLTest:
4944 wakaba 1.15 @@@QName: xp.cdatasection.empty.1.test
4945     @@@DEnt:
4946     @@@@test:value:
4947     <p><![CDATA[]]></p>
4948     @@@test:domTree:
4949     document {
4950     element {
4951     cdata-section {
4952     data: '';
4953     }
4954     }
4955     }
4956     @@XMLTest:
4957     @@@QName: xp.cdatasection.empty.2.test
4958     @@@DEnt:
4959     @@@@test:value:
4960     <p>aa<![CDATA[]]>bb</p>
4961     @@@test:domTree:
4962     document {
4963     element {
4964     text { data: 'aa'; }
4965     cdata-section {
4966     data: '';
4967     }
4968     text { data: 'bb'; }
4969     }
4970     }
4971     @@XMLTest:
4972     @@@QName: xp.cdatasection.1.test
4973     @@@DEnt:
4974     @@@@test:value:
4975     <p><![CDATA[abcdefg]]></p>
4976     @@@test:domTree:
4977     document {
4978     element {
4979     cdata-section {
4980     data: 'abcdefg';
4981     }
4982     }
4983     }
4984     @@XMLTest:
4985     @@@QName: xp.cdatasection.2.test
4986     @@@DEnt:
4987     @@@@test:value:
4988     <p>aa<![CDATA[abcdefg]]>bb</p>
4989     @@@test:domTree:
4990     document {
4991     element {
4992     text { data: 'aa'; }
4993     cdata-section {
4994     data: 'abcdefg';
4995     }
4996     text { data: 'bb'; }
4997     }
4998     }
4999     @@XMLTest:
5000     @@@QName: xp.cdatasection.ref.1.test
5001     @@@DEnt:
5002     @@@@test:value:
5003     <p><![CDATA[a&amp;&#x32;&#32;%abc;&def;]]&gt;b]]></p>
5004     @@@test:domTree:
5005     document {
5006     element {
5007     cdata-section {
5008     data: 'a&amp;&#x32;&#32;%abc;&def;]]&gt;b';
5009     }
5010     }
5011     }
5012     @@XMLTest:
5013     @@@QName: xp.cdatasection.in.general.entity.test
5014     @@@DEnt:
5015     @@@@test:value:
5016     <!DOCTYPE p [
5017     <!ENTITY cdata "<![CDATA[text]]>">
5018     ]>
5019     <p>&cdata;</p>
5020     @@@test:domTree:
5021     document {
5022     document-type {
5023     general-entity {
5024     node-name: 'cdata';
5025     cdata-section {
5026     data: 'text';
5027     }
5028     }
5029     }
5030     element {
5031     general-entity-reference {
5032     cdata-section {
5033     data: 'text';
5034     }
5035     }
5036     }
5037     }
5038     @@XMLTest:
5039     @@@QName: xp.cdatasection.no.mse.test
5040     @@@DEnt:
5041     @@@@test:value:
5042     <p><![CDATA[text</p>
5043     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 21); }
5044     @@XMLTest:
5045     @@@QName: xp.cdatasection.nest.test
5046     @@@DEnt:
5047     @@@@test:value:
5048     <p><![CDATA[text01<![CDATA[txt2]]>text3]]></p>
5049     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 40)..(1, 42); }
5050    
5051     @@XMLTest:
5052 wakaba 1.6 @@@QName: xp.doctype.empty.test
5053     @@@DEnt:
5054     @@@@test:value:
5055     <!DOCTYPE a>
5056     <a></a>
5057     @@@test:domTree:
5058     document {
5059     xml-version: '1.0';
5060     xml-encoding: null;
5061     xml-standalone: false;
5062     document-type {
5063     node-name: 'a';
5064     }
5065     element {
5066     namespace-uri: null;
5067     prefix: null;
5068     local-name: 'a';
5069     text-content: '';
5070     }
5071     }
5072 wakaba 1.15 @@XMLTest:
5073     @@@QName: xp.doctype.empty.after.document.element.test
5074     @@@DEnt:
5075     @@@@test:value:
5076     <a></a>
5077     <!DOCTYPE a>
5078     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5079     @@XMLTest:
5080     @@@QName: xp.doctype.empty.in.element.test
5081     @@@DEnt:
5082     @@@@test:value:
5083     <a>
5084     <!DOCTYPE a>
5085     </a>
5086     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5087     @@XMLTest:
5088     @@@QName: xp.doctype.empty.dup.test
5089     @@@DEnt:
5090     @@@@test:value:
5091     <!DOCTYPE a>
5092     <!DOCTYPE a>
5093     <a></a>
5094     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5095     @@XMLTest:
5096     @@@QName: xp.doctype.empty.in.intsubset.test
5097     @@@DEnt:
5098     @@@@test:value:
5099     <!DOCTYPE a [
5100     <!DOCTYPE a>
5101     ]>
5102     <a></a>
5103     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5104    
5105 wakaba 1.6
5106     @@XMLTest:
5107     @@@QName: xp.doctype.intsubset.empty.test
5108     @@@DEnt:
5109     @@@@test:value:
5110     <!DOCTYPE a [
5111    
5112     ]>
5113     <a></a>
5114     @@@test:domTree:
5115     document {
5116     xml-version: '1.0';
5117     xml-encoding: null;
5118     xml-standalone: false;
5119     document-type {
5120     node-name: 'a';
5121     }
5122     element {
5123     namespace-uri: null;
5124     prefix: null;
5125     local-name: 'a';
5126     text-content: '';
5127     }
5128     }
5129    
5130     @@XMLTest:
5131     @@@QName: xp.doctype.intsubset.pi.test
5132     @@@DEnt:
5133     @@@@test:value:
5134     <!DOCTYPE a [
5135     <?pi data ?>
5136     ]>
5137     <a></a>
5138     @@@test:domTree:
5139     document {
5140     xml-version: '1.0';
5141     xml-encoding: null;
5142     xml-standalone: false;
5143     document-type {
5144     node-name: 'a';
5145     pi {
5146     target: 'pi';
5147     data: 'data ';
5148     }
5149     }
5150     element {
5151     namespace-uri: null;
5152     prefix: null;
5153     local-name: 'a';
5154     text-content: '';
5155     }
5156     }
5157     @@@enImplNote:
5158     A DOM PI node in doctype node is a manakai extension.
5159    
5160    
5161     @@XMLTest:
5162     @@@QName: xp.doctype.intsubset.entity.general.internal.test
5163     @@@DEnt:
5164     @@@@test:value:
5165     <!DOCTYPE a [
5166     <!ENTITY entity "entity value">
5167     ]>
5168     <a></a>
5169     @@@test:domTree:
5170     document {
5171     xml-version: '1.0';
5172     xml-encoding: null;
5173     xml-standalone: false;
5174     document-type {
5175     node-name: 'a';
5176 wakaba 1.11 general-entity {
5177     node-name: 'entity';
5178     text-content: 'entity value';
5179     has-replacement-tree: true;
5180     }
5181 wakaba 1.6 }
5182     element {
5183     namespace-uri: null;
5184     prefix: null;
5185     local-name: 'a';
5186     text-content: '';
5187     }
5188     }
5189     @@XMLTest:
5190     @@@QName: xp.doctype.intsubset.entity.parameter.internal.test
5191     @@@DEnt:
5192     @@@@test:value:
5193     <!DOCTYPE a [
5194     <!ENTITY % entity "entity value">
5195     ]>
5196     <a></a>
5197     @@@test:domTree:
5198     document {
5199     xml-version: '1.0';
5200     xml-encoding: null;
5201     xml-standalone: false;
5202     document-type {
5203     node-name: 'a';
5204     }
5205     element {
5206     namespace-uri: null;
5207     prefix: null;
5208     local-name: 'a';
5209     text-content: '';
5210     }
5211     }
5212    
5213     @@XMLTest:
5214     @@@QName: xp.doctype.internal.entity.root.element.text.only.test
5215     @@@DEnt:
5216     @@@@test:value:
5217     <!DOCTYPE a [
5218     <!ENTITY entity "entity value">
5219     ]>
5220     <a>&entity;</a>
5221     @@@test:domTree:
5222     document {
5223     xml-version: '1.0';
5224     xml-encoding: null;
5225     xml-standalone: false;
5226     document-type {
5227     node-name: 'a';
5228 wakaba 1.11 general-entity {
5229     node-name: 'entity';
5230     text-content: 'entity value';
5231     has-replacement-tree: true;
5232     }
5233 wakaba 1.6 }
5234     element {
5235     namespace-uri: null;
5236     prefix: null;
5237     local-name: 'a';
5238     general-entity-reference {
5239     node-name: 'entity';
5240     text {
5241     data: 'entity value';
5242     }
5243     }
5244     }
5245     }
5246     @@XMLTest:
5247     @@@QName: xp.doctype.internal.entity.root.element.text.mult.test
5248     @@@DEnt:
5249     @@@@test:value:
5250     <!DOCTYPE a [
5251     <!ENTITY entity "entity value">
5252     ]>
5253     <a>&entity; and &entity;</a>
5254     @@@test:domTree:
5255     document {
5256     xml-version: '1.0';
5257     xml-encoding: null;
5258     xml-standalone: false;
5259     document-type {
5260     node-name: 'a';
5261 wakaba 1.11 general-entity {
5262     node-name: 'entity';
5263     text-content: 'entity value';
5264     has-replacement-tree: true;
5265     }
5266 wakaba 1.6 }
5267     element {
5268     namespace-uri: null;
5269     prefix: null;
5270     local-name: 'a';
5271     general-entity-reference {
5272     node-name: 'entity';
5273     text {
5274     data: 'entity value';
5275     }
5276     }
5277     text { data: ' and '; }
5278     general-entity-reference {
5279     node-name: 'entity';
5280     text {
5281     data: 'entity value';
5282     }
5283     }
5284     }
5285     }
5286     @@XMLTest:
5287     @@@QName: xp.doctype.internal.entity.root.element.text.element.test
5288     @@@DEnt:
5289     @@@@test:value:
5290     <!DOCTYPE a [
5291     <!ENTITY entity "entity <p>value</p> with <e>element</e> ">
5292     ]>
5293     <a>&entity;</a>
5294     @@@test:domTree:
5295     document {
5296     xml-version: '1.0';
5297     xml-encoding: null;
5298     xml-standalone: false;
5299     document-type {
5300     node-name: 'a';
5301 wakaba 1.11 general-entity {
5302     node-name: 'entity';
5303     has-replacement-tree: true;
5304     text { data: 'entity '; }
5305     element {
5306     node-name: 'p';
5307     text-content: 'value';
5308     }
5309     text { data: ' with '; }
5310     element {
5311     node-name: 'e';
5312     text-content: 'element';
5313     }
5314     }
5315 wakaba 1.6 }
5316     element {
5317     namespace-uri: null;
5318     prefix: null;
5319     local-name: 'a';
5320     general-entity-reference {
5321     node-name: 'entity';
5322     text {
5323     data: 'entity ';
5324     }
5325     element {
5326     namespace-uri: null;
5327     prefix: null;
5328     local-name: 'p';
5329     text {
5330     data: 'value';
5331     }
5332     }
5333     text {
5334     data: ' with ';
5335     }
5336     element {
5337     namespace-uri: null;
5338     prefix: null;
5339     local-name: 'e';
5340     text {
5341     data: 'element';
5342     }
5343     }
5344     text {
5345     data: ' ';
5346     }
5347     }
5348     }
5349     }
5350     @@XMLTest:
5351     @@@QName: xp.doctype.internal.entity.root.element.text.in.ent.test
5352     @@@DEnt:
5353     @@@@test:value:
5354     <!DOCTYPE a [
5355     <!ENTITY entity1 "entity value">
5356     <!ENTITY entity2 "e&entity1;n">
5357     ]>
5358     <a>&entity2;</a>
5359     @@@test:domTree:
5360     document {
5361     xml-version: '1.0';
5362     xml-encoding: null;
5363     xml-standalone: false;
5364     document-type {
5365     node-name: 'a';
5366 wakaba 1.11 general-entity {
5367     node-name: 'entity1';
5368     text-content: 'entity value';
5369     }
5370     general-entity {
5371     node-name: 'entity2';
5372     text { data: 'e'; }
5373     general-entity-reference {
5374     node-name: 'entity1';
5375     text-content: 'entity value';
5376     is-expanded: true;
5377     }
5378     text { data: 'n'; }
5379     }
5380 wakaba 1.6 }
5381     element {
5382     namespace-uri: null;
5383     prefix: null;
5384     local-name: 'a';
5385     general-entity-reference {
5386     node-name: 'entity2';
5387     text { data: 'e'; }
5388     general-entity-reference {
5389     node-name: 'entity1';
5390     text {
5391     data: 'entity value';
5392     }
5393     }
5394     text { data: 'n'; }
5395     }
5396 wakaba 1.8 }
5397     }
5398 wakaba 1.11
5399     @@XMLTest:
5400     @@@QName: xp.doctype.entity.value.charref.test
5401     @@@DEnt:
5402     @@@@test:value:
5403     <!DOCTYPE a [
5404     <!ENTITY entity1 "entity &#x21;value&#35;">
5405     <!ENTITY entity2 '&#x21;value&#35;'>
5406     ]>
5407     <a></a>
5408     @@@test:domTree:
5409     document {
5410     document-type {
5411     general-entity {
5412     node-name: 'entity1';
5413     text-content: 'entity !value#';
5414     has-replacement-tree: true;
5415     }
5416     general-entity {
5417     node-name: 'entity2';
5418     text-content: '!value#';
5419     has-replacement-tree: true;
5420     }
5421     }
5422     element { }
5423     }
5424    
5425     @@XMLTest:
5426     @@@QName: xp.predefined.in.content.test
5427     @@@DEnt:
5428     @@@@test:value:
5429     <a>_&lt;_&gt;_&quot;_&apos;_&amp;_</a>
5430     @@@test:domTree:
5431     document {
5432     element {
5433     text-content: '_<_>_"_' U+0027 '_&_';
5434     }
5435     }
5436     @@XMLTest:
5437     @@@QName: xp.predefined.in.attr.test
5438     @@@DEnt:
5439     @@@@test:value:
5440     <a at="_&lt;_&gt;_&quot;_&apos;_&amp;_"></a>
5441     @@@test:domTree:
5442     document {
5443     element {
5444     attribute {
5445     node-name: 'at';
5446     text-content: '_<_>_"_' U+0027 '_&_';
5447     }
5448     }
5449     }
5450     @@XMLTest:
5451     @@@QName: xp.predefined.in.content.in.entity.test
5452     @@@DEnt:
5453     @@@@test:value:
5454     <!DOCTYPE a [
5455     <!ENTITY ent "_&lt;_&gt;_&quot;_&apos;_&amp;_">
5456     ]>
5457     <a>&ent;</a>
5458     @@@test:domTree:
5459     document {
5460     document-type {
5461     general-entity {
5462     node-name: 'ent';
5463     text-content: '_<_>_"_' U+0027 '_&_';
5464     }
5465     }
5466     element {
5467     text-content: '_<_>_"_' U+0027 '_&_';
5468     }
5469     }
5470     @@XMLTest:
5471     @@@QName: xp.predefined.decl.ignore.test
5472     @@@DEnt:
5473     @@@@test:value:
5474     <!DOCTYPE a [
5475     <!ENTITY lt "&#x26;#x3C;">
5476     <!ENTITY gt "&#x3E;">
5477     <!ENTITY amp "&#x26;#x26;">
5478     <!ENTITY quot "&#x22;">
5479     <!ENTITY apos "&#x27;">
5480     <!ENTITY other "other">
5481     ]>
5482     <a>_&lt;_&gt;_&quot;_&apos;_&amp;_&other;_</a>
5483     @@@test:domTree:
5484     document {
5485     document-type {
5486     general-entity {
5487     node-name: 'other';
5488     text-content: 'other';
5489     }
5490     }
5491     element {
5492     text-content: '_<_>_"_' U+0027 '_&_other_';
5493     }
5494     }
5495    
5496 wakaba 1.8 @@XMLTest:
5497     @@@QName: xp.doctype.internal.attr.empty.test
5498     @@@DEnt:
5499     @@@@test:value:
5500     <!DOCTYPE a [
5501     <!ATTLIST a>
5502     ]>
5503     <a></a>
5504     @@@test:domTree:
5505     document {
5506     xml-version: '1.0';
5507     xml-encoding: null;
5508     xml-standalone: false;
5509     document-type {
5510     node-name: 'a';
5511     element-type-definition {
5512     node-name: 'a';
5513     }
5514     }
5515     element {
5516     namespace-uri: null;
5517     local-name: 'a';
5518     }
5519     }
5520     @@XMLTest:
5521     @@@QName: xp.doctype.internal.attr.cdata.implied.test
5522     @@@DEnt:
5523     @@@@test:value:
5524     <!DOCTYPE a [
5525     <!ATTLIST a
5526     at CDATA #IMPLIED
5527     >
5528     ]>
5529     <a></a>
5530     @@@test:domTree:
5531     document {
5532     xml-version: '1.0';
5533     xml-encoding: null;
5534     xml-standalone: false;
5535     document-type {
5536     node-name: 'a';
5537     element-type-definition {
5538     node-name: 'a';
5539     attribute-definition {
5540     node-name: 'at';
5541     declared-type: const (CDATA_ATTR);
5542     allowed-tokens: DOMStringList ();
5543     default-type: const (IMPLIED_DEFAULT);
5544     text-content: '';
5545     }
5546     }
5547     }
5548     element {
5549     namespace-uri: null;
5550     local-name: 'a';
5551     }
5552     }
5553     @@XMLTest:
5554     @@@QName: xp.doctype.internal.attr.types.implied.test
5555     @@@DEnt:
5556     @@@@test:value:
5557     <!DOCTYPE a [
5558     <!ATTLIST a
5559     at1 ID #IMPLIED
5560     at2 IDREF #IMPLIED
5561     at3 IDREFS #IMPLIED
5562     at4 ENTITY #IMPLIED
5563     at5 ENTITIES #IMPLIED
5564     at6 NMTOKEN #IMPLIED
5565     at7 NMTOKENS #IMPLIED
5566     at8 NOTATION (n1 | n2|n3) #IMPLIED
5567     at9 (e1| e2| e3 ) #IMPLIED
5568     >
5569     ]>
5570     <a></a>
5571     @@@test:domTree:
5572     document {
5573     xml-version: '1.0';
5574     xml-encoding: null;
5575     xml-standalone: false;
5576     document-type {
5577     node-name: 'a';
5578     element-type-definition {
5579     node-name: 'a';
5580     attribute-definition {
5581     node-name: 'at1';
5582     declared-type: const (ID_ATTR);
5583     allowed-tokens: DOMStringList ();
5584     default-type: const (IMPLIED_DEFAULT);
5585     text-content: '';
5586     }
5587     attribute-definition {
5588     node-name: 'at2';
5589     declared-type: const (IDREF_ATTR);
5590     allowed-tokens: DOMStringList ();
5591     default-type: const (IMPLIED_DEFAULT);
5592     text-content: '';
5593     }
5594     attribute-definition {
5595     node-name: 'at3';
5596     declared-type: const (IDREFS_ATTR);
5597     allowed-tokens: DOMStringList ();
5598     default-type: const (IMPLIED_DEFAULT);
5599     text-content: '';
5600     }
5601     attribute-definition {
5602     node-name: 'at4';
5603     declared-type: const (ENTITY_ATTR);
5604     allowed-tokens: DOMStringList ();
5605     default-type: const (IMPLIED_DEFAULT);
5606     text-content: '';
5607     }
5608     attribute-definition {
5609     node-name: 'at5';
5610     declared-type: const (ENTITIES_ATTR);
5611     allowed-tokens: DOMStringList ();
5612     default-type: const (IMPLIED_DEFAULT);
5613     text-content: '';
5614     }
5615     attribute-definition {
5616     node-name: 'at6';
5617     declared-type: const (NMTOKEN_ATTR);
5618     allowed-tokens: DOMStringList ();
5619     default-type: const (IMPLIED_DEFAULT);
5620     text-content: '';
5621     }
5622     attribute-definition {
5623     node-name: 'at7';
5624     declared-type: const (NMTOKENS_ATTR);
5625     allowed-tokens: DOMStringList ();
5626     default-type: const (IMPLIED_DEFAULT);
5627     text-content: '';
5628     }
5629     attribute-definition {
5630     node-name: 'at8';
5631     declared-type: const (NOTATION_ATTR);
5632     allowed-tokens: DOMStringList ('n1', 'n2', 'n3');
5633     default-type: const (IMPLIED_DEFAULT);
5634     text-content: '';
5635     }
5636     attribute-definition {
5637     node-name: 'at9';
5638     declared-type: const (ENUMERATION_ATTR);
5639     allowed-tokens: DOMStringList ('e1', 'e2', 'e3');
5640     default-type: const (IMPLIED_DEFAULT);
5641     text-content: '';
5642     }
5643     }
5644     }
5645     element {
5646     namespace-uri: null;
5647     local-name: 'a';
5648     }
5649     }
5650     @@XMLTest:
5651     @@@QName: xp.doctype.internal.attr.cdata.defaults.test
5652     @@@DEnt:
5653     @@@@test:value:
5654     <!DOCTYPE a [
5655     <!ATTLIST a
5656     at1 CDATA #IMPLIED
5657     at2 CDATA #REQUIRED
5658     at3 CDATA #FIXED "value3"
5659     at4 CDATA "value4"
5660     at5 CDATA #FIXED 'value5'
5661     at6 CDATA 'value6'
5662     >
5663     ]>
5664     <a></a>
5665     @@@test:domTree:
5666     document {
5667     xml-version: '1.0';
5668     xml-encoding: null;
5669     xml-standalone: false;
5670     document-type {
5671     node-name: 'a';
5672     element-type-definition {
5673     node-name: 'a';
5674     attribute-definition {
5675     node-name: 'at1';
5676     declared-type: const (CDATA_ATTR);
5677     allowed-tokens: DOMStringList ();
5678     default-type: const (IMPLIED_DEFAULT);
5679     text-content: '';
5680     }
5681     attribute-definition {
5682     node-name: 'at2';
5683     declared-type: const (CDATA_ATTR);
5684     allowed-tokens: DOMStringList ();
5685     default-type: const (REQUIRED_DEFAULT);
5686     text-content: '';
5687     }
5688     attribute-definition {
5689     node-name: 'at3';
5690     declared-type: const (CDATA_ATTR);
5691     allowed-tokens: DOMStringList ();
5692     default-type: const (FIXED_DEFAULT);
5693     text-content: 'value3';
5694     }
5695     attribute-definition {
5696     node-name: 'at4';
5697     declared-type: const (CDATA_ATTR);
5698     allowed-tokens: DOMStringList ();
5699     default-type: const (EXPLICIT_DEFAULT);
5700     text-content: 'value4';
5701     }
5702     attribute-definition {
5703     node-name: 'at5';
5704     declared-type: const (CDATA_ATTR);
5705     allowed-tokens: DOMStringList ();
5706     default-type: const (FIXED_DEFAULT);
5707     text-content: 'value5';
5708     }
5709     attribute-definition {
5710     node-name: 'at6';
5711     declared-type: const (CDATA_ATTR);
5712     allowed-tokens: DOMStringList ();
5713     default-type: const (EXPLICIT_DEFAULT);
5714     text-content: 'value6';
5715     }
5716     }
5717     }
5718     element {
5719     namespace-uri: null;
5720     local-name: 'a';
5721 wakaba 1.10 attribute {
5722     node-name: 'at3';
5723     text-content: 'value3';
5724     specified: false;
5725     }
5726     attribute {
5727     node-name: 'at4';
5728     text-content: 'value4';
5729     specified: false;
5730     }
5731     attribute {
5732     node-name: 'at5';
5733     text-content: 'value5';
5734     specified: false;
5735     }
5736     attribute {
5737     node-name: 'at6';
5738     text-content: 'value6';
5739     specified: false;
5740     }
5741 wakaba 1.9 }
5742     }
5743    
5744     @@XMLTest:
5745     @@@QName: xp.doctype.internal.attr.cdata.default.normalize.test
5746     @@@DEnt:
5747     @@@@test:value:
5748     <!DOCTYPE a [
5749     <!ATTLIST a
5750     at CDATA " default &#x0A;value "
5751     >
5752     ]>
5753     <a></a>
5754     @@@test:domTree:
5755     document {
5756     xml-version: '1.0';
5757     xml-encoding: null;
5758     xml-standalone: false;
5759     document-type {
5760     node-name: 'a';
5761     element-type-definition {
5762     node-name: 'a';
5763     attribute-definition {
5764     node-name: 'at';
5765     declared-type: const (CDATA_ATTR);
5766     allowed-tokens: DOMStringList ();
5767     default-type: const (EXPLICIT_DEFAULT);
5768     text-content: ' default ' U+000A 'value ';
5769     }
5770     }
5771     }
5772     element {
5773     namespace-uri: null;
5774     local-name: 'a';
5775 wakaba 1.10 attribute {
5776     node-name: 'at';
5777     text-content: ' default ' U+000A 'value ';
5778     specified: false;
5779     }
5780 wakaba 1.9 }
5781     }
5782     @@XMLTest:
5783     @@@QName: xp.doctype.internal.attr.nmtoken.default.normalize.test
5784     @@@DEnt:
5785     @@@@test:value:
5786     <!DOCTYPE a [
5787     <!ATTLIST a
5788     at NMTOKEN " default &#x0A;value "
5789     >
5790     ]>
5791     <a></a>
5792     @@@test:domTree:
5793     document {
5794     xml-version: '1.0';
5795     xml-encoding: null;
5796     xml-standalone: false;
5797     document-type {
5798     node-name: 'a';
5799     element-type-definition {
5800     node-name: 'a';
5801     attribute-definition {
5802     node-name: 'at';
5803     declared-type: const (NMTOKEN_ATTR);
5804     allowed-tokens: DOMStringList ();
5805     default-type: const (EXPLICIT_DEFAULT);
5806     text-content: ' default ' U+000A 'value ';
5807     }
5808     }
5809     }
5810     element {
5811     namespace-uri: null;
5812     local-name: 'a';
5813 wakaba 1.10 attribute {
5814     node-name: 'at';
5815     text-content: ' default ' U+000A 'value ';
5816     specified: false;
5817     }
5818 wakaba 1.9 }
5819     }
5820    
5821     @@XMLTest:
5822     @@@QName: xp.doctype.attrtype.no-value.test
5823     @@@DEnt:
5824     @@@@test:value:
5825     <!DOCTYPE a>
5826     <a at=" at value "></a>
5827     @@@test:domTree:
5828     document {
5829     xml-version: '1.0';
5830     xml-encoding: null;
5831     xml-standalone: false;
5832     document-type { }
5833     element {
5834     namespace-uri: null;
5835     local-name: 'a';
5836     attribute {
5837     namespace-uri: null;
5838     local-name: 'at';
5839     value: ' at value ';
5840     text {
5841     data: ' at value ';
5842     }
5843     schema-type-info: TypeInfo (null, null);
5844 wakaba 1.10 specified: true;
5845 wakaba 1.9 }
5846     }
5847     }
5848     @@XMLTest:
5849     @@@QName: xp.doctype.attrtype.cdata.test
5850     @@@DEnt:
5851     @@@@test:value:
5852     <!DOCTYPE a [
5853     <!ATTLIST a
5854     at CDATA #IMPLIED
5855     >
5856     ]>
5857     <a at=" at value "></a>
5858     @@@test:domTree:
5859     document {
5860     xml-version: '1.0';
5861     xml-encoding: null;
5862     xml-standalone: false;
5863     document-type { }
5864     element {
5865     namespace-uri: null;
5866     local-name: 'a';
5867     attribute {
5868     namespace-uri: null;
5869     local-name: 'at';
5870     value: ' at value ';
5871     text {
5872     data: ' at value ';
5873     }
5874     schema-type-info:
5875     TypeInfo ('http://www.w3.org/TR/REC-xml', 'CDATA');
5876 wakaba 1.10 specified: true;
5877 wakaba 1.9 }
5878     }
5879     }
5880     @@XMLTest:
5881     @@@QName: xp.doctype.attrtype.nmtoken.test
5882     @@@DEnt:
5883     @@@@test:value:
5884     <!DOCTYPE a [
5885     <!ATTLIST a
5886     at NMTOKEN #IMPLIED
5887     >
5888     ]>
5889     <a at=" at value "></a>
5890     @@@test:domTree:
5891     document {
5892     xml-version: '1.0';
5893     xml-encoding: null;
5894     xml-standalone: false;
5895     document-type { }
5896     element {
5897     namespace-uri: null;
5898     local-name: 'a';
5899     attribute {
5900     namespace-uri: null;
5901     local-name: 'at';
5902     value: 'at value';
5903     text {
5904     data: ' at value ';
5905     }
5906     schema-type-info:
5907     TypeInfo ('http://www.w3.org/TR/REC-xml', 'NMTOKEN');
5908 wakaba 1.10 specified: true;
5909 wakaba 1.9 }
5910     }
5911     }
5912    
5913     @@XMLTest:
5914     @@@QName: xp.doctype.attr.normalization.1.test
5915     @@@DEnt:
5916     @@@@test:value:
5917     <a at=" at &#xA;value "></a>
5918     @@@test:domTree:
5919     document {
5920     element {
5921     attribute {
5922 wakaba 1.10 node-name: 'at';
5923 wakaba 1.9 value: ' at ' U+000A 'value ';
5924     schema-type-info: TypeInfo (null, null);
5925 wakaba 1.10 specified: true;
5926 wakaba 1.9 }
5927     }
5928     }
5929     @@XMLTest:
5930     @@@QName: xp.doctype.attr.normalization.2.test
5931     @@@DEnt:
5932     @@@@test:value:
5933     <a at=" at &#xD;value "></a>
5934     @@@test:domTree:
5935     document {
5936     element {
5937     attribute {
5938     value: ' at ' U+000D 'value ';
5939     schema-type-info: TypeInfo (null, null);
5940 wakaba 1.10 specified: true;
5941 wakaba 1.9 }
5942     }
5943     }
5944     @@XMLTest:
5945     @@@QName: xp.doctype.attr.normalization.3.test
5946     @@@DEnt:
5947     @@@@test:value:
5948     <a at=" at &#x9;value "></a>
5949     @@@test:domTree:
5950     document {
5951     element {
5952     attribute {
5953 wakaba 1.10 node-name: 'at';
5954 wakaba 1.9 value: ' at ' U+0009 'value ';
5955     schema-type-info: TypeInfo (null, null);
5956 wakaba 1.10 specified: true;
5957     }
5958     }
5959     }
5960    
5961     @@XMLTest:
5962     @@@QName: xp.doctype.attr.specified.1.test
5963     @@@DEnt:
5964     @@@@test:value:
5965     <!DOCTYPE a [
5966     <!ATTLIST a
5967     at CDATA "default"
5968     >
5969     ]>
5970     <a></a>
5971     @@@test:domTree:
5972     document {
5973     document-type { }
5974     element {
5975     attribute {
5976     node-name: 'at';
5977     value: 'default';
5978     specified: false;
5979     }
5980     }
5981     }
5982     @@XMLTest:
5983     @@@QName: xp.doctype.attr.specified.2.test
5984     @@@DEnt:
5985     @@@@test:value:
5986     <!DOCTYPE a [
5987     <!ATTLIST a
5988     at CDATA "default"
5989     >
5990     ]>
5991     <a at2="specified"></a>
5992     @@@test:domTree:
5993     document {
5994     document-type { }
5995     element {
5996     attribute {
5997     node-name: 'at';
5998     value: 'default';
5999     specified: false;
6000     }
6001     attribute {
6002     node-name: 'at2';
6003     value: 'specified';
6004     specified: true;
6005     }
6006     }
6007     }
6008     @@XMLTest:
6009     @@@QName: xp.doctype.attr.specified.3.test
6010     @@@DEnt:
6011     @@@@test:value:
6012     <!DOCTYPE a [
6013     <!ATTLIST a
6014     at CDATA "default"
6015     >
6016     ]>
6017     <a at="specified"></a>
6018     @@@test:domTree:
6019     document {
6020     document-type { }
6021     element {
6022     attribute {
6023     node-name: 'at';
6024     value: 'specified';
6025     specified: true;
6026 wakaba 1.11 }
6027     }
6028     }
6029    
6030     @@XMLTest:
6031     @@@QName: xp.attr.literal.charref.test
6032     @@@DEnt:
6033     @@@@test:value:
6034     <a at1 = "value&#33;_&#x25;value"
6035     at2 = 'value&#x25;_&#33;value'></a>
6036     @@@test:domTree:
6037     document {
6038     element {
6039     attribute {
6040     node-name: 'at1';
6041     text-content: 'value!_%value';
6042     }
6043     attribute {
6044     node-name: 'at2';
6045     text-content: 'value%_!value';
6046     }
6047     }
6048     }
6049     @@XMLTest:
6050     @@@QName: xp.attr.literal.entref.test
6051     @@@DEnt:
6052     @@@@test:value:
6053     <!DOCTYPE a [
6054     <!ENTITY ent "entity&#x26;#33;_&#x26;#x29;value">
6055     ]>
6056     <a at1 = "value&ent;value"
6057     at2 = 'value&ent;value'></a>
6058     @@@test:domTree:
6059     document {
6060     document-type {
6061     general-entity {
6062     node-name: 'ent';
6063     text-content: 'entity!_)value';
6064     }
6065     }
6066     element {
6067     attribute {
6068     node-name: 'at1';
6069     text-content: 'valueentity!_)valuevalue';
6070     }
6071     attribute {
6072     node-name: 'at2';
6073     text-content: 'valueentity!_)valuevalue';
6074     }
6075     }
6076     }
6077     @@XMLTest:
6078     @@@QName: xp.attr.literal.entref.nest.test
6079     @@@DEnt:
6080     @@@@test:value:
6081     <!DOCTYPE a [
6082     <!ENTITY ent1 "entity&#x26;#33;_&#x26;#x29;value">
6083     <!ENTITY ent2 "@&ent1;@">
6084     ]>
6085     <a at1 = "value&ent2;value"
6086     at2 = 'value&ent2;value'></a>
6087     @@@test:domTree:
6088     document {
6089     document-type {
6090     general-entity {
6091     node-name: 'ent1';
6092     text-content: 'entity!_)value';
6093     }
6094     general-entity {
6095     node-name: 'ent2';
6096     text-content: '@entity!_)value@';
6097     }
6098     }
6099     element {
6100     attribute {
6101     node-name: 'at1';
6102     text-content: 'value@entity!_)value@value';
6103     }
6104     attribute {
6105     node-name: 'at2';
6106     text-content: 'value@entity!_)value@value';
6107 wakaba 1.9 }
6108 wakaba 1.6 }
6109     }
6110    
6111 wakaba 1.5 @@PerlDef:
6112     my $impl = $Message::DOM::ImplementationRegistry->get_implementation ({
6113     'Core' => '3.0',
6114     'XML' => '3.0',
6115     'XMLVersion' => ['1.0', '1.1'],
6116     });
6117     my $parser = <Class::ManakaiXMLParser>->new ($impl);
6118    
6119     for my $test_data (@$TestData) {
6120     $test->start_new_test ($test_data->{uri});
6121     my $doc_ent = $test_data->{entity}->{$test_data->{root_uri}};
6122 wakaba 1.14 my $not_ok;
6123 wakaba 1.12
6124     $parser->dom_config->set_parameter ('error-handler' => sub ($$) {
6125     my (undef, $err) = @_;
6126     my $err_type = $err->type;
6127     if ($test_data->{dom_error}->{$err_type}) {
6128     $test->assert_error_equals
6129     (actual_value => $err,
6130 wakaba 1.15 expected_hash => shift @{$test_data->{dom_error}
6131     ->{$err_type}});
6132 wakaba 1.12 } else { # Uncatched error
6133     warn $err;
6134 wakaba 1.14 unless ($err->severity == <C::c|DOMError.SEVERITY_WARNING>) {
6135     $test->failure_comment ('Unexpected error |'.$err->type.'|');
6136     $not_ok = true;
6137     }
6138 wakaba 1.12 }
6139     return true; # continue as far as possible
6140     });
6141    
6142     if ($test_data->{dom_tree}) { # Successful test
6143     try {
6144     my $doc = $parser->parse_string ($doc_ent->{<H::test:value>});
6145     $test->assert_dom_tree_equals
6146     (actual_value => $doc,
6147     expected_hash => $test_data->{dom_tree});
6148     for (values %{$test_data->{dom_error}||{}}) {
6149     if (@$_) {
6150     $test->failure_comment
6151     (@$_.' |DOMError|s of type |'.
6152 wakaba 1.13 $_->[0]->{type}->{value}.'| are not reported');
6153 wakaba 1.14 $not_ok = true;
6154 wakaba 1.12 }
6155     }
6156 wakaba 1.14 $not_ok ? $test->not_ok : $test->ok;
6157 wakaba 1.12 } catch Message::Util::IF::DTException with {
6158     #
6159     } catch Message::DOM::IF::LSException with {
6160 wakaba 1.14 # not_ok
6161     } otherwise {
6162     my $err = shift;
6163     warn $err;
6164     $test->not_ok;
6165 wakaba 1.12 };
6166     } else {
6167     try {
6168     my $doc = $parser->parse_string ($doc_ent->{<H::test:value>});
6169     $test->assert_never;
6170     } catch Message::Util::IF::DTException with {
6171     #
6172     } catch Message::DOM::IF::LSException with {
6173     #
6174 wakaba 1.14 } otherwise {
6175     my $err = shift;
6176     warn $err;
6177     $test->not_ok;
6178 wakaba 1.12 };
6179     for (values %{$test_data->{dom_error}||{}}) {
6180     if (@$_) {
6181     $test->failure_comment
6182     (@$_.' |DOMError|s of type |'.
6183 wakaba 1.13 $_->[0]->{type}->{value}.'| are not reported');
6184 wakaba 1.14 $not_ok = true;
6185 wakaba 1.12 }
6186     }
6187 wakaba 1.14 $not_ok ? $test->not_ok : $test->ok;
6188 wakaba 1.12 }
6189 wakaba 1.5 }
6190 wakaba 1.6
6191     @ResourceDef:
6192     @@QName: getCopyOfEntityState
6193     @@rdf:type: DISPerl|InlineCode
6194     @@ForCheck: ManakaiDOM|ForClass
6195     @@PerlDef:
6196     {%{$self->{$entity_type}->{$entity_name}},
6197     line => 1, column => 1, pos => 0}
6198 wakaba 1.1 ##ManakaiXMLParser
6199 wakaba 1.5
6200     ElementTypeBinding:
6201     @Name: XMLTests
6202     @ElementType:
6203     dis:ResourceDef
6204     @ShadowContent:
6205     @@ForCheck: ManakaiDOM|ForClass
6206     @@rdf:type: test|ParserTestSet
6207    
6208     ElementTypeBinding:
6209     @Name: XMLTest
6210     @ElementType:
6211     dis:ResourceDef
6212     @ShadowContent:
6213     @@ForCheck: ManakaiDOM|ForClass
6214     @@rdf:type: test|ParserTest
6215    
6216     ElementTypeBinding:
6217     @Name: DEnt
6218     @ElementType:
6219     dis:ResourceDef
6220     @ShadowContent:
6221     @@rdf:type: test|RootEntity
6222    
6223     ElementTypeBinding:
6224     @Name: Ent
6225     @ElementType:
6226     dis:ResourceDef
6227     @ShadowContent:
6228     @@rdf:type: test|Entity
6229 wakaba 1.1
6230 wakaba 1.3 ResourceDef:
6231     @QName: xp|get-location-from-token
6232     @rdf:type: DISPerl|BlockCode
6233     @enDesc:
6234     Creates a <IF::DOMCore:DOMLocator> object from a token.
6235     @PerlDef:
6236 wakaba 1.14 my $__d = $token->{type} ne '#EOF'
6237     ? $token->{location}->{char_d}
6238     : 0;
6239 wakaba 1.15 $__d -= $token->{location_d} if $token->{location_d};
6240 wakaba 1.3 $result = {
6241 wakaba 1.14 utf32_offset => $token->{location}->{pos} - $__d,
6242     line_number => $token->{location}->{line},
6243     column_number => $token->{location}->{column} - $__d,
6244 wakaba 1.3 };
6245 wakaba 1.14 $result->{utf32_offset} = 0 if $result->{utf32_offset} < 0;
6246     $result->{column_number} = 0 if $result->{column_number} < 0;
6247     ## 0 or 1, which should be?
6248 wakaba 1.3 @For: ManakaiDOM|ManakaiDOM3
6249 wakaba 1.1
6250     ElementTypeBinding:
6251     @Name: RuleDef
6252     @ElementType:
6253     dis:ResourceDef
6254     @ShadowContent:
6255     @@ForCheck: ManakaiDOM|ForClass
6256     @@rdf:type: Muf2003|RuleDefClass
6257    
6258     ElementTypeBinding:
6259     @Name: RuleParam
6260     @ElementType:
6261     dis:ResourceDef
6262     @ShadowContent:
6263     @@rdf:type: Muf2003|RuleParameter
6264    
6265     ElementTypeBinding:
6266     @Name: enImplNote
6267     @ElementType:
6268     dis:ImplNote
6269     @ShadowContent:
6270     @@lang:en
6271    
6272     ElementTypeBinding:
6273     @Name: ErrDef
6274     @ElementType:
6275     dis:ResourceDef
6276     @ShadowContent:
6277     @@rdf:type: DOMCore|DOMErrorType
6278     @@For: ManakaiDOM|DOM3
6279     @@ecore:textFormatter: ManakaiXMLParserExceptionFormatter
6280    
6281 wakaba 1.3 ElementTypeBinding:
6282     @Name: WFErrDef
6283     @ElementType:
6284     dis:ResourceDef
6285     @ShadowContent:
6286     @@rdf:type: DOMCore|DOMErrorType
6287     @@For: ManakaiDOM|DOM3
6288     @@ecore:textFormatter: ManakaiXMLParserExceptionFormatter
6289    
6290     WFErrDef:
6291     @QName: xp|wf-syntax-error
6292     @enDesc:
6293     The entity does not match to the production rule; it is not
6294     well-formed.
6295     @DOMCore:severity: DOMCore|SEVERITY_FATAL_ERROR
6296     @enMufDef:
6297     |%xp-error-token-type;|%xp-error-token-value
6298     (prefix => { (|}, suffix => {|)}); is not
6299     allowed%xp-error-lines (prefix => { (|}, suffix => {|)});
6300     @ecore:hasParameter:
6301     @@@: xp|error-token
6302     @@enDesc:
6303     The token that is not allowed.
6304    
6305     WFErrDef:
6306     @QName: xp|wf-pi-target-is-xml
6307     @enDesc:
6308     A processing instruction has its <CODE::PITarget> of
6309     <XML::xml> (in any case) which is not allowed.
6310     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6311     @enMufDef:
6312     Processing instruction target name cannot be |%p
6313     (name => {<Q::xp|name>});|
6314     @ecore:hasParameter:
6315     @@@: xp|error-token
6316     @@enDesc:
6317     The token that contains the name.
6318     @ecore:hasParameter:
6319     @@@: xp|name
6320     @@enDesc:
6321     A string that is specified as target name of the
6322     processing instruction.
6323     @ecore:hasParameter: xp|parent
6324    
6325     WFErrDef:
6326     @QName: xp|wf-no-end-tag
6327     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6328     @enDesc:
6329     An end-tag is not found.
6330     @enMufDef:
6331     End-tag |</%p (name => {<Q::xp|expected-element-type>});>| is required
6332     @ecore:hasParameter: xp|error-token
6333     @ecore:hasParameter:
6334     @@@: xp|node
6335     @@enDesc:
6336     The element node that is not closed.
6337     @ecore:hasParameter:
6338     @@@: xp|expected-element-type
6339     @@enDesc:
6340     The element type name of the element that is not closed.
6341    
6342     WFErrDef:
6343     @QName: xp|wf-unsupported-xml-version
6344     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6345     @enDesc:
6346     The XML version specified in the version declaration is not supported.
6347     @enMufDef:
6348     XML version |%p (name => {<Q::infoset|version>});| is not supported
6349     @ecore:hasParameter: xp|bad-token
6350     @ecore:hasParameter:
6351     @@@: xp|parent
6352     @@enDesc:
6353     The document node.
6354     @ecore:hasParameter:
6355     @@@: infoset|version
6356     @@enDesc:
6357     The specified XML version.
6358    
6359     WFErrDef:
6360     @QName: xp|wf-malformed-enc-name
6361     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6362     @enDesc:
6363     An <XA::encoding> pseudo-attribute value does not match
6364     to the procduction rule <CODE::EncName>.
6365     @enMufDef:
6366     Encoding name |%p (name => {<Q::xp|name>});| is not allowed
6367     @ecore:hasParameter: xp|error-token
6368     @ecore:hasParameter:
6369     @@@: xp|parent
6370     @@enDesc: The document node.
6371     @ecore:hasParameter:
6372     @@@: xp|name
6373     @@enDesc:
6374     The <XA::encoding> value.
6375    
6376     WFErrDef:
6377     @QName: xp|wf-malformed-xml-standalone
6378     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6379     @enDesc:
6380     An <XA::standalone> pseudo-attribute value is neither <XML::yes>
6381     or <XML::no>.
6382     @enMufDef:
6383     |standalone| pseudo-attribute value |%p (name => {<Q::xp|name>});|
6384     is not allowed
6385     @ecore:hasParameter: xp|error-token
6386     @ecore:hasParameter:
6387     @@@: xp|parent
6388     @@enDesc: The document node.
6389     @ecore:hasParameter:
6390     @@@: xp|name
6391     @@enDesc:
6392     The <XA::standalone> value.
6393    
6394     WFErrDef:
6395     @QName: xp|wf-legal-literal-character
6396     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6397     @enDesc:
6398     Each character in XML entity must match to the production
6399     rule <CODE::Char - RestrictedChar>.
6400     @enMufDef:
6401     Character %character-code-point
6402     (v => {<Q::xp|character-number>}); is not allowed
6403     @ecore:hasParameter:
6404     @@@: xp|character-number
6405     @@enDesc:
6406     The code position of the character being referred.
6407    
6408     WFErrDef:
6409     @QName: xp|wf-element-type-match
6410     @DOMCore:severity: DOMCore|SEVERITY_FATAL_ERROR
6411 wakaba 1.1 @enDesc:
6412 wakaba 1.3 The <CODE::Name> in an element's end-tag must match the element type
6413     in the start-tag.
6414     @enMufDef:
6415     End-tag |</%p (name => {<Q::xp|actual-element-type>});>| does
6416     not match to start-tag |<%p (name => {<Q::xp|expected-element-type>});>|
6417     @ecore:hasParameter: xp|error-token
6418     @ecore:hasParameter:
6419     @@@: xp|node
6420     @@enDesc:
6421     The current opening element node.
6422     @ecore:hasParameter:
6423     @@@: xp|expected-element-type
6424     @@enDesc:
6425     The element type name of the current element.
6426     @ecore:hasParameter:
6427     @@@: xp|actual-element-type
6428     @@enDesc:
6429     The <CODE::Name> occurs in the end-tag.
6430    
6431     WFErrDef:
6432     @QName: xp|wf-unique-att-spec
6433 wakaba 1.1 @DOMCore:severity: DOMCore|SEVERITY_ERROR
6434 wakaba 1.3 @enDesc:
6435     An attribute name <kwd:MUST-NOT> appear more than once in
6436     the same start-tag or empty-element tag.
6437 wakaba 1.1 @enMufDef:
6438 wakaba 1.3 Attribute |%p (name => {<Q::xp|name>});| is specified more
6439     than once in the same tag
6440     @ecore:hasParameter: xp|error-token
6441     @ecore:hasParameter:
6442     @@@: xp|name
6443     @@enDesc:
6444     The name of the attribute.
6445    
6446     WFErrDef:
6447     @QName: xp|wf-legal-character
6448     @DOMCore:severity: DOMCore|SEVERITY_ERROR
6449     @enDesc:
6450     Characters referred to using character references <kwd:MUST>
6451     match the production for <CODE::Char>.
6452     @enMufDef:
6453     Reference to character %character-code-point
6454     (v => {<Q::xp|character-number>}); is not allowed
6455     @ecore:hasParameter: xp|error-token
6456     @ecore:hasParameter:
6457     @@@: xp|character-number
6458     @@enDesc:
6459     The code position of the character being referred.
6460     @ecore:hasParameter:
6461     @@@: xp|parent
6462     @@enDesc:
6463     The parent node in which the character reference has
6464     occurred, if available.
6465 wakaba 1.1
6466 wakaba 1.3 XWParam:
6467 wakaba 1.1 @QName: xp|error-token
6468     @enDesc:
6469     The token where the parser found an error.
6470    
6471 wakaba 1.3 XWParam:
6472     @QName: xp|name
6473     @enDesc:
6474     A name.
6475    
6476     XWParam:
6477     @QName: xp|parent
6478     @enDesc:
6479     The parent node in which the error occurs.
6480    
6481     XWParam:
6482     @QName: xp|node
6483     @enDesc:
6484     The current node.
6485    
6486     XWParam:
6487     @QName: xp|actual-element-type
6488     @enDesc:
6489     The actual element type name occured in the source.
6490    
6491     XWParam:
6492     @QName: xp|expected-element-type
6493 wakaba 1.1 @enDesc:
6494 wakaba 1.3 The element type name expected.
6495    
6496     XWParam:
6497     @QName: xp|character-number
6498     @enDesc:
6499     The character code position.
6500    
6501     ElementTypeBinding:
6502     @Name: XWParam
6503     @ElementType:
6504     dis:ResourceDef
6505     @ShadowContent:
6506     @@For: =ManakaiDOM|all
6507     @@rdf:type: ecore|Parameter
6508 wakaba 1.1
6509     ElementTypeBinding:
6510     @Name:enMufDef
6511     @ElementType:
6512     ecore:defaultMessage
6513     @ShadowContent:
6514     @@lang:en
6515     @@ContentType:
6516     lang:muf
6517    
6518     ResourceDef:
6519     @QName: DOMImpl
6520     @AliasFor: DOMCore|DOMImplementation
6521     @For: ManakaiDOM|DOM
6522    
6523     ElementTypeBinding:
6524     @Name: Attr
6525     @ElementType:
6526     dis:ResourceDef
6527     @ShadowContent:
6528     @@rdf:type: DISLang|Attribute
6529     @@ForCheck: !=ManakaiDOM|ManakaiDOM
6530    
6531     ElementTypeBinding:
6532     @Name: Get
6533     @ElementType:
6534     dis:ResourceDef
6535     @ShadowContent:
6536     @@rdf:type: DISLang|AttributeGet
6537    
6538     ElementTypeBinding:
6539     @Name: Set
6540     @ElementType:
6541     dis:ResourceDef
6542     @ShadowContent:
6543     @@rdf:type: DISLang|AttributeSet
6544    
6545     ElementTypeBinding:
6546     @Name: enDesc
6547     @ElementType:
6548     dis:Description
6549     @ShadowContent:
6550     @@lang:en
6551    
6552     ElementTypeBinding:
6553     @Name: Method
6554     @ElementType:
6555     dis:ResourceDef
6556     @ShadowContent:
6557     @@rdf:type: DISLang|Method
6558     @@For: !=ManakaiDOM|ManakaiDOM
6559    
6560     ElementTypeBinding:
6561     @Name: Return
6562     @ElementType:
6563     dis:ResourceDef
6564     @ShadowContent:
6565     @@rdf:type: DISLang|MethodReturn
6566    
6567     ElementTypeBinding:
6568     @Name: Param
6569     @ElementType:
6570     dis:ResourceDef
6571     @ShadowContent:
6572     @@rdf:type: DISLang|MethodParameter
6573    
6574     ElementTypeBinding:
6575     @Name: PerlDef
6576     @ElementType:
6577     dis:Def
6578     @ShadowContent:
6579     @@ContentType: lang|Perl
6580    
6581     ElementTypeBinding:
6582     @Name: PropDef
6583     @ElementType:
6584     dis:ResourceDef
6585     @ShadowContent:
6586     @@rdf:type: rdf|Property
6587    
6588     ClsDef:
6589     @ClsQName: ManakaiXMLParserExceptionFormatter
6590    
6591     @ClsISA: ecore|MUErrorFormatter||ManakaiDOM|Perl
6592    
6593     @RuleDef:
6594     @@Name: xp-error-token-type
6595     @@enDesc:
6596     The type of the token the parser is encountered.
6597    
6598     @@Method:
6599     @@@Name: after
6600     @@@Param:
6601     @@@@Name: name
6602     @@@@Type: DOMString
6603     @@@@enDesc: The name of the method.
6604     @@@Param:
6605     @@@@Name: p
6606     @@@@Type: DISPerl|HASH
6607     @@@@enDesc: The set of the parameters to the method.
6608     @@@Param:
6609     @@@@Name: o
6610     @@@@Type: DISPerl|HASH
6611     @@@@enDesc: The option value.
6612     @@@Return:
6613     @@@@PerlDef:
6614     $p->{-result} = $o->{<H::xp|error-token>}->{type}
6615     if defined $o->{<H::xp|error-token>}->{type};
6616    
6617     @RuleDef:
6618     @@Name: xp-error-token-value
6619     @@enDesc:
6620     The value of the token the parser is encountered, if any.
6621    
6622     @@Method:
6623     @@@Name: after
6624     @@@Param:
6625     @@@@Name: name
6626     @@@@Type: DOMString
6627     @@@@enDesc: The name of the method.
6628     @@@Param:
6629     @@@@Name: p
6630     @@@@Type: DISPerl|HASH
6631     @@@@enDesc: The set of the parameters to the method.
6632     @@@Param:
6633     @@@@Name: o
6634     @@@@Type: DISPerl|HASH
6635     @@@@enDesc: The option value.
6636     @@@Return:
6637     @@@@PerlDef:
6638     $p->{-result} = $o->{<H::xp|error-token>}->{value}
6639     if defined $o->{<H::xp|error-token>}->{value};
6640    
6641     @RuleDef:
6642     @@Name: xp-error-lines
6643     @@enDesc:
6644     A copy of fragment of the source text that contains the line
6645     where the error occurred, if available.
6646    
6647     @@Method:
6648     @@@Name: after
6649     @@@Param:
6650     @@@@Name: name
6651     @@@@Type: DOMString
6652     @@@@enDesc: The name of the method.
6653     @@@Param:
6654     @@@@Name: p
6655     @@@@Type: DISPerl|HASH
6656     @@@@enDesc: The set of the parameters to the method.
6657     @@@Param:
6658     @@@@Name: o
6659     @@@@Type: DISPerl|HASH
6660     @@@@enDesc: The option value.
6661     @@@Return:
6662     @@@@PerlDef:
6663     my $pos = $o-><AG::DOMCore|DOMError.location>
6664     -><AG::DOMCore|DOMLocator.utf32Offset>;
6665     if ($pos > -1) {
6666 wakaba 1.6 my $src = $o->{<H::ecore|object>}->{entity}->[-1]->{reptxt};
6667 wakaba 1.1 my $start = $pos;
6668     $start = rindex ($$src, "\x0A", $start - 1) for 0..2;
6669     $start++;
6670     my $end = $pos;
6671     $end = index ($$src, "\x0A", $end + 1) for 0..2;
6672     $end = length $$src if $end < 0;
6673     $p->{-result} = substr $$src, $start, $end - $start;
6674     }
6675 wakaba 1.3
6676     @RuleDef:
6677     @@Name: character-code-point
6678     @@enDesc:
6679     The character code position, in <CODE::U+<VAR::HHHH>> notation.
6680    
6681     @@Method:
6682     @@@Name: after
6683     @@@Param:
6684     @@@@Name: name
6685     @@@@Type: DOMString
6686     @@@@enDesc: The name of the method.
6687     @@@Param:
6688     @@@@Name: p
6689     @@@@Type: DISPerl|HASH
6690     @@@@enDesc: The set of the parameters to the method.
6691     @@@Param:
6692     @@@@Name: o
6693     @@@@Type: DISPerl|HASH
6694     @@@@enDesc: The option value.
6695     @@@RuleParam:
6696     @@@@Name: v
6697     @@@@Type: DISPerl|Number
6698     @@@@enDesc:
6699     The name of the error parameter that contains the character code.
6700     @@@Return:
6701     @@@@PerlDef:
6702     $p->{-result} = sprintf 'U+%04X', $o->{$p->{v}};
6703 wakaba 1.1 ##XMLParserExceptionFormatter

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24