/[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.17 - (hide annotations) (download)
Sat Feb 11 05:05:46 2006 UTC (18 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.16: +532 -50 lines
++ manakai/lib/Message/DOM/ChangeLog	11 Feb 2006 05:05:19 -0000
2006-02-11  Wakaba  <wakaba@suika.fam.cx>

	* XMLParser.dis ($self->{has_error}): Removed.
	(parseString): Don't throw |DOMLS:PARSE_ERR| if all fatal
	errors (including well-formedness constraint errors) are
	traped by the error handler.
	(PubidLiteral, SystemLiteral): Set |publicId| or |systemId|
	attribute of the node.  Reports an error if |publidLiteral|
	contains a non-|pubidChar|.

	* XDoctype.dis (d:DeclFeature30): New feature (|fe:XDoctypeDeclaration|
	version |3.0|).
	(ManakaiDOMDocumentTypeDefinition): The class no longer
	inherits |x:ManakaiDOMDocumentType| class.  Instead,
	it inherits |d:ManakaiDOMDocumentTypeDeclaration|
	and |t:ManakaiDOMNOde| classes.  It still implements |x:DocumentType|
	interface (except unimplemented |notations| and |internalSubset|
	attributes).
	(ManakaiDOMDocumentTypeDefinition.entities): New attribute
	for compatibility with |x:DocumentType| interface.
	(ManakaiDOMDocumentTypeDefinition.lookupPrefix): New method.
	(ManakaiDOMDocumentTypeDefinition.getFeature): New method.
	(ManakaiDOMDocumentTypeDefinition.nodeType,
	ManakaiDOMDocumentTypeDefinition.textContent): New attributes.
	(DocumentTypeDeclaration): New interface.

	* Tree.dis (Node/@f:implements): Typos fixed.
	(Node.MUErrorHandler): Missing |last A| statement is added.
	(createDocumentType): Throws an exception if |qualifiedName|
	is illegal.  Calls |DocumentTypeDefinition.newObject|
	instead of obsolete |DocumentType.newObject|.

	* DOMXML.dis (DocumentType.name, DocumentType.entities,
	DocumentType.publicId, DocumentType.systemId,
	DocumentType.lookupPrefix, DocumentType.getFeature): Now they are defined
	as clones of similar attributes or methods
	in |MDOM:XDoctype| module.
	(DocumentType.newObject): Removed (use |DocumentTypeDefinition.newObject|
	instead).
	(DocumentType.childNodes): Removed (|Node.childNodes| definition
	is 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.17 $Date: 2006/02/10 08:10:26 $
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.17
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 wakaba 1.17 CORE::delete $self->{dtdecl};
310 wakaba 1.11 $self->{cfg} = $r-><AG::Document.domConfig>;
311     local $r->{<H::mn:node>}
312     ->{<H::cfg|entity-reference-read-only>} = false;
313    
314     ## Document entity -> |Document| node
315     $self->_parse_DocumentEntity;
316    
317     ## Replacement tree for general |Entity| nodes
318     my @ent = values %{$self->{general_entities}};
319     if (@ent) {
320     for my $ent (@ent) {
321     if (exists $ent->{reptxt}) {
322     my $ent_name = $ent->{name};
323     $self->{entity} = [<Code::getCopyOfEntityState::
324     $entity_type = 'general_entity',
325     $entity_name = $ent_name>];
326 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
327 wakaba 1.11 $self->{token} = [];
328     $self->{char} = [];
329     ## TODO: External entity support
330     $self->_parse_InternalGeneralParsedEntity ($ent->{node});
331     $ent->{node}-><AS::x|Entity.hasReplacementTree> (true);
332     }
333     ## TODO: Read-only if configuration (for all entities)
334     }
335     }
336    
337     $r-><AS::Document.strictErrorChecking> (true);
338 wakaba 1.1 }__;
339    
340     @Method:
341     @@Name: shiftChar
342     @@ManakaiDOM:isForInternal:1
343     @@ForCheck: ManakaiDOM|ForClass
344     @@enDesc:
345     Returns the next character.
346     @@Return:
347     @@@Type: idl|long||ManakaiDOM|all
348     @@@enDesc:
349     The code position number of the next character, if any,
350 wakaba 1.6 or <CODE::-1>.
351 wakaba 1.1 @@@PerlDef:
352     if (@{$self->{char}}) {
353     $r = shift @{$self->{char}};
354     } else {
355 wakaba 1.7 no warnings 'substr';
356     ## substr outside length warnings at the end of the string
357 wakaba 1.6 GETCHAR: {
358     my $char = substr (${$self->{entity}->[-1]->{reptxt}},
359     $self->{entity}->[-1]->{pos}, 1);
360    
361 wakaba 1.7 if (defined $char and length $char) {
362 wakaba 1.13 $self->{entity}->[-1]->{pos}++;
363 wakaba 1.6 $r = ord $char;
364     if ($r == 0x000A) {
365     $self->{entity}->[-1]->{line}++;
366     $self->{entity}->[-1]->{column} = 1;
367     } elsif ($r == 0x000D) {
368     my $next_char = substr (${$self->{entity}->[-1]->{reptxt}},
369     $self->{entity}->[-1]->{pos}, 1);
370     if ($next_char eq "\x0A") {
371     $self->{entity}->[-1]->{pos}++;
372 wakaba 1.13 $self->{entity}->[-1]->{line}++;
373 wakaba 1.6 $self->{entity}->[-1]->{column} = 1;
374     } elsif ($next_char eq "\x85") {
375     if ($self->{xml_version} eq '1.1') {
376 wakaba 1.16 if ($self->{entity}->[-1]->{no_xml11_eol}) {
377     my $location = {
378     utf32_offset => $self->{entity}->[-1]->{pos} - 1,
379     line_number => $self->{entity}->[-1]->{line},
380     column_number => $self->{entity}->[-1]->{column},
381     };
382     my $continue = __DOMCore:ERROR{
383     xp|fatal-xml11-end-of-line-in-xml-declaration::
384     DOMCore|location => {$location},
385     xp|character-number => {$r},
386     }__;
387     unless ($continue) {
388     __EXCEPTION{DOMLS|PARSE_ERR}__;
389     }
390     } # no_xml11_eol
391 wakaba 1.6 $self->{entity}->[-1]->{pos}++;
392 wakaba 1.13 $self->{entity}->[-1]->{line}++;
393 wakaba 1.6 $self->{entity}->[-1]->{column} = 1;
394     } else {
395 wakaba 1.16 ## |no_xml11_eol| will be tested later.
396 wakaba 1.13 $self->{entity}->[-1]->{column}++;
397     ## Line number will be increased by next |shiftChar| call.
398 wakaba 1.6 }
399 wakaba 1.3 } else {
400 wakaba 1.13 $self->{entity}->[-1]->{line}++;
401 wakaba 1.6 $self->{entity}->[-1]->{column} = 1;
402     }
403     $r = 0x000A;
404     } elsif (
405     not ((0x0020 <= $r and $r <= 0x007E) or
406     (0x00A0 <= $r and $r <= 0xD7FF) or
407     (0xE000 <= $r and $r <= 0xFFFD) or
408     (0x10000 <= $r and $r <= 0x10FFFF)) and
409     $r != 0x0009 and $r != 0x0085 and
410     not ($self->{xml_version} eq '1.0' and
411     (0x007F <= $r and $r <= 0x009F))
412     ) {
413     my $location = {
414 wakaba 1.13 utf32_offset => $self->{entity}->[-1]->{pos} - 1,
415 wakaba 1.6 line_number => $self->{entity}->[-1]->{line},
416     column_number => $self->{entity}->[-1]->{column},
417     };
418     my $continue = __DOMCore:ERROR{xp|wf-legal-literal-character::
419     DOMCore|location => {$location},
420     xp|character-number => {$r},
421     }__;
422     unless ($continue) {
423     __EXCEPTION{DOMLS|PARSE_ERR}__;
424 wakaba 1.3 }
425 wakaba 1.6 $self->{entity}->[-1]->{column}++;
426     } elsif ($r == 0x0085 or $r == 0x2028) {
427 wakaba 1.16 if ($self->{entity}->[-1]->{no_xml11_eol}) {
428     my $location = {
429     utf32_offset => $self->{entity}->[-1]->{pos} - 1,
430     line_number => $self->{entity}->[-1]->{line},
431     column_number => $self->{entity}->[-1]->{column},
432     };
433     my $continue = __DOMCore:ERROR{
434     xp|fatal-xml11-end-of-line-in-xml-declaration::
435     DOMCore|location => {$location},
436     xp|character-number => {$r},
437     }__;
438     unless ($continue) {
439     __EXCEPTION{DOMLS|PARSE_ERR}__;
440     }
441     } # no_xml11_eol
442 wakaba 1.6 $r = 0x000A if $self->{xml_version} eq '1.1';
443 wakaba 1.13 ## Even in XML 1.0 it increases the line number.
444 wakaba 1.6 $self->{entity}->[-1]->{line}++;
445     $self->{entity}->[-1]->{column} = 1;
446 wakaba 1.3 } else {
447 wakaba 1.6 $self->{entity}->[-1]->{column}++;
448 wakaba 1.3 }
449     } else {
450 wakaba 1.6 $r = -1;
451 wakaba 1.3 }
452 wakaba 1.6 } # GETCHAR
453 wakaba 1.1 }
454    
455     @Method:
456     @@ManakaiDOM:isForInternal: 1
457     @@Operator: ManakaiDOM|MUErrorHandler
458     @@enDesc:
459     When a <IF::ecore|ErrorInterface||ManakaiDOM|Perl> is <Perl::report>ed,
460     then this method is invoked.
461    
462     The method calls the <cfg::DOMCore|error-handler> if the error is of
463     <IF::DOMCore|DOMError>. Otherwise, the error is re-thrown so that
464     corresponding <Perl::catch> clause, if any, can catch the error.
465     @@Param:
466     @@@Name: err
467     @@@Type: ecore|ErrorInterface||ManakaiDOM|Perl
468     @@@enDesc:
469     The reported error object.
470     @@Return:
471     @@@Type: DISPerl|Any
472     @@@enDesc:
473     If the <P::err> is a <IF::DOMCore|DOMError>, then the return value
474     of the error handler.
475    
476     {NOTE:: If the error is thrown, the method never returns.
477     }
478     @@@nullCase:
479     @@@@enDesc:
480     No error handler.
481     @@@PerlDef:
482     if ($err->isa (<IFName::DOMCore|DOMError||ManakaiDOM|ManakaiDOM>)) {
483     __DEEP{
484     A: {
485     my $cfg = $self-><AG::LSParser.domConfig>;
486     my $h = $cfg-><M::DOMCore|DOMConfiguration.getParameter>
487     ('error-handler');
488     $r = $h-><M::DOMCore|DOMErrorHandler.handleError> ($err);
489     } # A
490     }__;
491     } else {
492     $err-><M::ecore|ErrorInterface||ManakaiDOM|Perl.throw>;
493     }
494    
495     @DISPerl:dpgDef:
496    
497     /*
498     XML Document Entity
499    
500     document := prolog element *Misc
501     - *Char RestrictedChar *Char ;; [1]
502     */
503 wakaba 1.11 rule DocumentEntity : standalone {
504 wakaba 1.1 /*
505     prolog := XMLDecl? *Misc [doctypedecl *Misc] ;; [22]
506     */
507 wakaba 1.16 ?lexmode DocumentStart;
508 wakaba 1.11
509     my $doc;
510     lang:Perl {
511     $doc = $self->{doc};
512     }
513 wakaba 1.1
514 wakaba 1.3 ~? (XDO) {
515 wakaba 1.16 ?lexmode XMLDeclarationOrPI;
516     lang:Perl {
517     $self->{entity}->[-1]->{no_xml11_eol} = true;
518     }
519     ~ (S) { // XML declaration
520     &_XMLDeclaration_ ($doc => $doc);
521     ~ (PIC2) {
522     ?lexmode DocumentProlog;
523     } else {
524     ?lexmode DocumentProlog;
525     }
526     } (NameChar) { // Processing instruction whose target begins with |xml|
527     my $target_token;
528     lang:Perl ($v => $token.value) {
529     $target_token = $token;
530     $target_token->{value} = 'xml'.$target_token->{value};
531     $self->{entity}->[-1]->{no_xml11_eol} = false;
532     }
533     ?lexmode PINmtoken;
534     ~? (Nmtoken) {
535     lang:Perl ($v => $token.value) {
536     $target_token->{value} .= $v;
537     }
538     ?lexmode PIName;
539     }
540     lang:Perl {
541     $target_token->{type} = 'Name';
542     $target_token->{location_d} += 3; # 'xml'
543     unshift @{$self->{token}}, $token;
544     $token = $target_token;
545     }
546     &_ProcessingInstruction_ ($doc => $doc, $parent => $doc);
547     ~ (PIC) {
548     ?lexmode DocumentProlog;
549     } else {
550     ?lexmode DocumentProlog;
551     }
552 wakaba 1.3 } else {
553 wakaba 1.16 lang:Perl {
554     $self->{entity}->[-1]->{no_xml11_eol} = false;
555     }
556 wakaba 1.3 }
557     } else {
558     ?lexmode 'DocumentProlog';
559     }
560 wakaba 1.1
561     // *Misc
562 wakaba 1.2 ~* (CDO) {
563 wakaba 1.1 &_CommentDeclaration_ ($doc => $doc, $parent => $doc);
564    
565     ~ (MDC) {
566     ?lexmode DocumentProlog;
567     } else {
568     ?lexmode DocumentProlog;
569     }
570     } (PIO) {
571     &_ProcessingInstruction_ ($doc => $doc, $parent => $doc);
572    
573     ~ (PIC) {
574     ?lexmode 'DocumentProlog';
575     } else {
576     ?lexmode DocumentProlog;
577     }
578     } (S) {
579     //
580     }
581    
582     // doctypedecl
583     ~? (MDO) {
584     &_DocumentTypeDeclaration_ ($doc => $doc);
585    
586 wakaba 1.3 ~ (MDC) {
587     ?lexmode DocumentMisc;
588     } else {
589     ?lexmode DocumentMisc;
590     }
591     } else {
592     lang:Perl {
593     $self->{standalone} = true;
594     }
595     ?lexmode DocumentMisc;
596 wakaba 1.1 }
597    
598     // *Misc
599 wakaba 1.2 ~* (CDO) {
600 wakaba 1.1 &_CommentDeclaration_ ($doc => $doc, $parent => $doc);
601    
602     ~ (MDC) {
603     ?lexmode DocumentMisc;
604     } else {
605     ?lexmode DocumentMisc;
606     }
607     } (PIO) {
608     &_ProcessingInstruction_ ($doc => $doc, $parent => $doc);
609    
610     ~ (PIC) {
611     ?lexmode 'DocumentMisc';
612     } else {
613     ?lexmode DocumentMisc;
614     }
615     } (S) {
616     //
617     }
618    
619     // Document element
620     ~ (STAGO) {
621     &Element_ ($doc => $doc, $parent => $doc)
622     : unshift-current-token;
623     ~ (TAGC) {
624     ?lexmode DocumentEnd;
625     } else {
626     ?lexmode DocumentEnd;
627     }
628     } else {
629     ?lexmode 'DocumentEnd';
630     }
631    
632     // *Misc
633 wakaba 1.2 ~* (CDO) {
634 wakaba 1.1 &_CommentDeclaration_ ($doc => $doc, $parent => $doc);
635    
636     ~ (MDC) {
637     ?lexmode DocumentEnd;
638     } else {
639     ?lexmode DocumentEnd;
640     }
641     } (PIO) {
642     &_ProcessingInstruction_ ($doc => $doc, $parent => $doc);
643     ~ (PIC) {
644     ?lexmode 'DocumentEnd';
645     } else {
646     ?lexmode DocumentEnd;
647     }
648     } (S) {
649     //
650     }
651    
652     ~ (#EOF) { }
653     } // DocumentEntity
654 wakaba 1.11
655     /*
656     Internal General Parsed Entity
657    
658     An internal general parsed entity is well-formed if its
659     replacement text matches the production labeled |content|.
660     */
661     rule InternalGeneralParsedEntity ($ent) : standalone {
662     ?lexmode ElementContent;
663    
664     my $ns;
665     lang:Perl {
666     $ns = {
667     xml => <Q::xml:>,
668     xmlns => <Q::xmlns:>,
669     };
670     }
671    
672     &content ($parent => $ent, $ns => $ns);
673    
674     ~ (#EOF) { }
675     } // InternalGeneralParsedEntity
676    
677 wakaba 1.1 /*
678     XML Declaration
679    
680     XMLDecl := '<?xml' VersionInfo
681     [EncodingDecl]
682     [SDDecl]
683     [S] '?>' ;; [23]
684    
685     NOTE: XML declaration is optional in XML 1.0
686     while it is required in XML 1.1.
687     */
688 wakaba 1.16 rule _XMLDeclaration_ {
689     // ~ (XDO) { }
690 wakaba 1.3 ?lexmode XMLDeclaration;
691 wakaba 1.16 //lang:Perl {
692     // $self->{entity}->[-1]->{no_xml11_eol} = true;
693     //}
694     //~ (S) { }
695 wakaba 1.3
696     ~ (Name == 'version') {
697     ~? (S) { }
698     ~ (VI) { }
699     ~? (S) { }
700 wakaba 1.1
701 wakaba 1.3 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 eq '1.0' or $ver eq '1.1') {
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-unsupported-xml-version::
740     DOMCore|location => {$location},
741 wakaba 1.16 xp|parent => {$self->{doc}},
742 wakaba 1.3 infoset|version => {$ver},
743     xp|error-token => {$bad_token},
744     }__;
745     unless ($continue) {
746     __EXCEPTION{DOMLS|PARSE_ERR}__;
747     }
748     }
749 wakaba 1.16 $self->{doc}-><AS::Document.xmlVersion> ($ver);
750 wakaba 1.3 $self->{xml_version} = $ver;
751     }
752    
753     ~? (S) { }
754 wakaba 1.1 }
755    
756 wakaba 1.3 ~? (Name == 'encoding') {
757     ~? (S) { }
758     ~ (VI) { }
759     ~? (S) { }
760    
761     my $ver;
762     my $bad_token;
763    
764     ~ (LIT) {
765     ?lexmode AttributeValueLiteral;
766    
767     ~ (STRING) {
768     lang:Perl ($version => $token.value) {
769     $ver = $version;
770     $bad_token = $token;
771     }
772     }
773    
774     ~ (LIT) {
775     ?lexmode XMLDeclaration;
776     }
777     } (LITA) {
778     ?lexmode AttributeValueLiteralA;
779    
780     ~ (STRING) {
781     lang:Perl ($version => $token.value) {
782     $ver = $version;
783     $bad_token = $token;
784     }
785     }
786    
787     ~ (LITA) {
788     ?lexmode XMLDeclaration;
789     }
790     }
791    
792     lang:Perl : has-error {
793     unless ($ver =~ /\A[A-Za-z][A-Za-z0-9._-]*\z/) {
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-enc-name::
800     DOMCore|location => {$location},
801 wakaba 1.16 xp|parent => {$self->{doc}},
802 wakaba 1.3 xp|name => {$ver},
803     xp|error-token => {$bad_token},
804     }__;
805     unless ($continue) {
806     __EXCEPTION{DOMLS|PARSE_ERR}__;
807     }
808     }
809 wakaba 1.16 $self->{doc}-><AS::Document.xmlEncoding> ($ver);
810 wakaba 1.3 }
811    
812     ~? (S) { }
813 wakaba 1.1 }
814 wakaba 1.3
815     ~? (Name == 'standalone') {
816     ~? (S) { }
817     ~ (VI) { }
818     ~? (S) { }
819    
820     my $ver;
821     my $bad_token;
822    
823     ~ (LIT) {
824     ?lexmode AttributeValueLiteral;
825    
826     ~ (STRING) {
827     lang:Perl ($version => $token.value) {
828     $ver = $version;
829     $bad_token = $token;
830     }
831     }
832    
833     ~ (LIT) {
834     ?lexmode XMLDeclaration;
835     }
836     } (LITA) {
837     ?lexmode AttributeValueLiteralA;
838    
839     ~ (STRING) {
840     lang:Perl ($version => $token.value) {
841     $ver = $version;
842     $bad_token = $token;
843     }
844     }
845 wakaba 1.1
846 wakaba 1.3 ~ (LITA) {
847     ?lexmode XMLDeclaration;
848     }
849     }
850    
851     lang:Perl : has-error {
852     unless ($ver eq 'yes' or $ver eq 'no') {
853     my $location;
854     __CODE{xp|get-location-from-token::
855     $token => {$bad_token},
856     $result => {$location},
857     }__;
858     my $continue = __DOMCore:ERROR{xp|wf-malformed-xml-standalone::
859     DOMCore|location => {$location},
860 wakaba 1.16 xp|parent => {$self->{doc}},
861 wakaba 1.3 xp|name => {$ver},
862     xp|error-token => {$bad_token},
863     }__;
864     unless ($continue) {
865     __EXCEPTION{DOMLS|PARSE_ERR}__;
866     }
867     }
868 wakaba 1.13 if ($ver eq 'yes') {
869 wakaba 1.16 $self->{doc}-><AS::Document.xmlStandalone> (true);
870 wakaba 1.13 $self->{standalone} = true;
871     }
872 wakaba 1.3 }
873    
874     ~? (S) { }
875     }
876    
877 wakaba 1.16 ~ (PIC1) {
878     lang:Perl {
879     $self->{entity}->[-1]->{no_xml11_eol} = false;
880     }
881     } else {
882     lang:Perl {
883     $self->{entity}->[-1]->{no_xml11_eol} = false;
884     }
885     }
886    
887     // ~ (PIC2) { }
888 wakaba 1.3 } // _XMLDeclaration_
889 wakaba 1.1
890     /*
891     Comment Declaration
892    
893     Comment := '<!--' *(Char - '-' / '-' (Char - '-'))
894     '-->' ;; [15]
895 wakaba 1.4 */
896 wakaba 1.1 rule _CommentDeclaration_ ($doc, $parent) {
897     ?lexmode 'CommentDeclaration';
898    
899     ~? (STRING) {
900     lang:Perl ($data => $token.value) {
901     my $com = $doc-><M::Document.createComment> ($data);
902     $parent-><M::Node.appendChild> ($com);
903     }
904     } else {
905     lang:Perl {
906     my $com = $doc-><M::Document.createComment> ('');
907     $parent-><M::Node.appendChild> ($com);
908     }
909     }
910    
911     ~ (COM) {
912     ?lexmode MarkupDeclaration;
913     } else {
914     ?lexmode MarkupDeclaration;
915     }
916    
917     // ~ (MDC) { }
918 wakaba 1.4 } // _CommentDeclaration
919 wakaba 1.15
920     rule _CommentDeclarationDTD {
921     ?lexmode CommentDeclaration;
922 wakaba 1.4
923     ~? (STRING) {
924     //
925     }
926    
927     ~ (COM) {
928     ?lexmode MarkupDeclaration;
929     } else {
930     ?lexmode MarkupDeclaration;
931     }
932    
933     ~ (MDC) {
934     ?lexmode DTD;
935     } else {
936     ?lexmode DTD;
937     }
938     } // _CommentDeclarationDTD
939    
940 wakaba 1.1 /*
941     Processing Instruction
942    
943     PI := '<?' PITarget [S *Char - *Char '?>' *Char]
944     '?>' ;; [16]
945     */
946     rule _ProcessingInstruction_ ($doc, $parent) {
947     ?lexmode 'PIName';
948    
949     my $pi;
950    
951     ~ (Name) {
952 wakaba 1.3 lang:Perl ($name => $token.value) : has-error {
953 wakaba 1.1 if (lc $name eq 'xml') {
954 wakaba 1.3 my $location;
955     __CODE{xp|get-location-from-token::
956     $token => {$token},
957     $result => {$location},
958     }__;
959     my $continue = __DOMCore:ERROR{xp|wf-pi-target-is-xml::
960     xp|name => {$name},
961     DOMCore|location => {$location},
962     xp|parent => {$parent},
963     }__;
964     unless ($continue) {
965     __EXCEPTION{DOMLS|PARSE_ERR::
966     }__;
967     }
968 wakaba 1.1 }
969     ## TODO: Namespace well-formedness
970     $pi = $doc-><M::Document.createProcessingInstruction>
971     ($name);
972     }
973 wakaba 1.14 } else {
974     lang:Perl {
975     $pi = $doc-><M::Document.createProcessingInstruction> ('#INVALID');
976     }
977 wakaba 1.1 }
978    
979 wakaba 1.14 ~? (S) {
980 wakaba 1.1 ?lexmode 'PIData';
981    
982     my $tdata;
983    
984     ~? (DATA) {
985     lang:Perl ($data => $token.value) {
986     $tdata = $data;
987     }
988     } else {
989     lang:Perl {
990     $tdata = '';
991     }
992     }
993    
994     lang:Perl {
995     $pi-><AS::Node.nodeValue> ($tdata);
996     }
997     }
998    
999     lang:Perl {
1000     $parent-><M::Node.appendChild> ($pi);
1001     }
1002    
1003     // ~ (PIC) { }
1004     } // _ProcessingInstruction_
1005 wakaba 1.4
1006 wakaba 1.6 /*
1007     Processing instruction in DTD
1008     */
1009     rule _ProcessingInstructionDTD ($doc, $doctype) {
1010 wakaba 1.4 ?lexmode 'PIName';
1011 wakaba 1.6
1012     my $pi;
1013 wakaba 1.4
1014     ~ (Name) {
1015 wakaba 1.6 lang:Perl ($name => $token.value) : has-error {
1016     if (lc $name eq 'xml') {
1017     my $location;
1018     __CODE{xp|get-location-from-token::
1019     $token => {$token},
1020     $result => {$location},
1021     }__;
1022     my $continue = __DOMCore:ERROR{xp|wf-pi-target-is-xml::
1023     xp|name => {$name},
1024     DOMCore|location => {$location},
1025     xp|parent => {$doctype},
1026     }__;
1027     unless ($continue) {
1028     __EXCEPTION{DOMLS|PARSE_ERR::
1029     }__;
1030     }
1031     }
1032     ## TODO: Namespace well-formedness
1033     $pi = $doc-><M::Document.createProcessingInstruction>
1034     ($name);
1035     }
1036 wakaba 1.14 } else {
1037     lang:Perl {
1038     $pi = $doc-><M::Document.createProcessingInstruction> ('#INVALID');
1039     }
1040 wakaba 1.4 }
1041    
1042 wakaba 1.14 ~? (S) {
1043 wakaba 1.4 ?lexmode 'PIData';
1044    
1045 wakaba 1.6 my $tdata;
1046    
1047 wakaba 1.4 ~? (DATA) {
1048 wakaba 1.6 lang:Perl ($data => $token.value) {
1049     $tdata = $data;
1050     }
1051     } else {
1052     lang:Perl {
1053     $tdata = '';
1054     }
1055     }
1056    
1057     lang:Perl {
1058     $pi-><AS::Node.nodeValue> ($tdata);
1059 wakaba 1.4 }
1060     }
1061    
1062 wakaba 1.6 lang:Perl {
1063     $doctype-><M::Node.appendChild> ($pi);
1064     }
1065    
1066 wakaba 1.4 ~ (PIC) {
1067     ?lexmode DTD;
1068     } else {
1069     ?lexmode DTD;
1070     }
1071     } // _ProcessingInstructionDTD
1072 wakaba 1.1
1073     /*
1074     Element content parsing mode
1075    
1076     element := EmptyElemTag /
1077     STag content ETag ;; [39]
1078     content := (CharData / element / Reference / CDSect /
1079     PI / Comment) ;; [43]
1080     */
1081 wakaba 1.6 rule Element_ ($doc, $parent, $ns) : standalone {
1082 wakaba 1.1 ?lexmode 'ElementContent';
1083    
1084     my $node; // Current "parent" node
1085     my $nodes; // Node stack (w/o $current_node)
1086     my $type; // Current "parent" element type QName
1087     my $types; // Element type stack (w/o $current_type)
1088 wakaba 1.6 //my $ns; // Current in-scope namespace bindings
1089 wakaba 1.1 my $nses; // Namespace binding stack (w/o $current_ns)
1090    
1091     lang:Perl {
1092     $node = $parent;
1093     $nodes = [];
1094     $type = '';
1095     $types = [];
1096 wakaba 1.6 $ns ||= {
1097 wakaba 1.1 xml => <Q::xml:>,
1098     xmlns => <Q::xmlns:>,
1099     };
1100     $nses = [];
1101     }
1102    
1103     ~* : name => CONTENT
1104     (CharData) {
1105     // Character data
1106     lang:Perl ($data => $token.value) {
1107     $node-><M::Node.appendChild>
1108     ($doc-><M::Document.createTextNode> ($data));
1109     }
1110     } (STAGO) {
1111     // Start tag or empty element tag
1112    
1113     ?lexmode 'StartTag';
1114    
1115     ~ (Name) {
1116     my $attrs;
1117     lang:Perl ($name => $token.value) {
1118     push @{$types}, $type;
1119     $type = $name;
1120     $attrs = {};
1121     }
1122    
1123     ~? (S) {
1124     &AttributeSpecificationList
1125     ($doc => $doc, $attrs => $attrs);
1126     }
1127    
1128     my $el;
1129 wakaba 1.9
1130     /*
1131     Note that this implementation does not perform
1132     attribute value tokenization (but does white space
1133     normalization common to attribute types) and
1134     construct the tree as is. DOM Level 3 Core spec
1135     is unclear on this point. With tokenization,
1136     entity references cannot be preserved.
1137    
1138     The manakai Node.nodeValue and Attr.value attributes
1139     do tokenization according to attribute types.
1140     */
1141    
1142     /*
1143     ISSUE: Should |xml:id| attribute be typed?
1144     */
1145 wakaba 1.1
1146     lang:Perl {
1147     push @{$nses}, $ns;
1148     $ns = {%$ns};
1149    
1150     my %gattr;
1151     my %lattr;
1152     for my $atqname (keys %$attrs) {
1153     my ($pfx, $lname) = split /:/, $atqname;
1154 wakaba 1.9 $attrs->{$atqname}->{def} = $self->{attr}->{$type}->{$atqname};
1155 wakaba 1.1 if (defined $lname) { ## Global attribute
1156     ## TODO: Namespace well-formedness (lname is NCName)
1157     if ($pfx eq 'xmlns') {
1158     my $nsuri = $attrs->{$atqname}->{value};
1159     if ($lname eq 'xml' and
1160     $nsuri ne <Q::xml:>) {
1161     ## TODO: error
1162     } elsif ($lname eq 'xmlns') {
1163     ## TODO: error
1164     }
1165     if ($nsuri eq '') {
1166     ## TODO: error in XML 1.0
1167     } elsif ($nsuri eq <Q::xml:> and
1168     $lname ne 'xml') {
1169     ## TODO: error
1170     } elsif ($nsuri eq <Q::xmlns:>) {
1171     ## TODO: error
1172     }
1173     $ns->{$lname} = $attrs->{$atqname}->{value};
1174 wakaba 1.9 if ($attrs->{$atqname}->{def}) {
1175     my $dt = $attrs->{$atqname}->{def}-><AG::ATDef.declaredType>;
1176     if ({
1177     <C::ATDef.ID_ATTR> => true,
1178     <C::ATDef.IDREF_ATTR> => true,
1179     <C::ATDef.IDREFS_ATTR> => true,
1180     <C::ATDef.ENTITY_ATTR> => true,
1181     <C::ATDef.ENTITIES_ATTR> => true,
1182     <C::ATDef.NMTOKEN_ATTR> => true,
1183     <C::ATDef.NMTOKENS_ATTR> => true,
1184     <C::ATDef.NOTATION_ATTR> => true,
1185     <C::ATDef.ENUMERATION_ATTR> => true,
1186     }->{$dt}) {
1187     ## Tokenization (XML 1 3.3.3)
1188     for ($ns->{$lname}) {
1189     s/^\x20+//;
1190     s/\x20+\z//;
1191     s/\x20+/ /g;
1192     }
1193     }
1194     }
1195 wakaba 1.1 delete $ns->{$lname} unless length $ns->{$lname};
1196     } elsif ($pfx eq '') {
1197     ## TODO: pfx is not NCName error
1198     } else {
1199     if ($gattr{$pfx}->{$lname}) {
1200     ## TODO: Namespace well-formedness error
1201     }
1202     }
1203     $gattr{$pfx}->{$lname} = $attrs->{$atqname};
1204     } else { ## Local attribute
1205     if ($pfx eq 'xmlns') {
1206     $ns->{''} = $attrs->{xmlns}->{value};
1207 wakaba 1.9 if ($attrs->{$atqname}->{def}) {
1208     my $dt = $attrs->{$atqname}->{def}-><AG::ATDef.declaredType>;
1209     if ({
1210     <C::ATDef.ID_ATTR> => true,
1211     <C::ATDef.IDREF_ATTR> => true,
1212     <C::ATDef.IDREFS_ATTR> => true,
1213     <C::ATDef.ENTITY_ATTR> => true,
1214     <C::ATDef.ENTITIES_ATTR> => true,
1215     <C::ATDef.NMTOKEN_ATTR> => true,
1216     <C::ATDef.NMTOKENS_ATTR> => true,
1217     <C::ATDef.NOTATION_ATTR> => true,
1218     <C::ATDef.ENUMERATION_ATTR> => true,
1219     }->{$dt}) {
1220     ## Tokenization (XML 1 3.3.3)
1221     for ($ns->{''}) {
1222     s/^\x20+//;
1223     s/\x20+\z//;
1224     s/\x20+/ /g;
1225     }
1226     }
1227     }
1228 wakaba 1.1 delete $ns->{''} unless length $ns->{''};
1229     } else {
1230     $lattr{$pfx} = $attrs->{$atqname};
1231     }
1232     }
1233     }
1234    
1235     my ($pfx, $lname) = split /:/, $type;
1236     my $nsuri;
1237     ## TODO: lname is NCName?
1238     if (defined $lname) { ## Prefixed namespace
1239     if ($pfx eq '') {
1240     ## TODO: pfx is not NCName error
1241     }
1242     if (defined $ns->{$pfx}) {
1243     $nsuri = $ns->{$pfx};
1244     } else {
1245     ## TODO: namespace ill-formed
1246     }
1247     } else { ## Default namespace
1248     $nsuri = $ns->{''};
1249     }
1250    
1251     $el = $doc-><M::Document.createElementNS>
1252     ($nsuri, $type);
1253    
1254     if ($attrs->{xmlns}) {
1255     my $attr = $doc-><M::Document.createAttributeNS>
1256     (<Q::xmlns:>, 'xmlns');
1257     for (@{$attrs->{xmlns}->{nodes}}) {
1258     $attr-><M::Node.appendChild> ($_);
1259     }
1260 wakaba 1.9 if ($attrs->{xmlns}->{def}) {
1261     __CODE{t|setAttrType::
1262     $attr => $attr,
1263     $type => {$attrs->{xmlns}->{def}-><AG::ATDef.declaredType>},
1264     }__;
1265     }
1266 wakaba 1.1 $el-><M::Element.setAttributeNodeNS> ($attr);
1267     }
1268    
1269     for my $lname (keys %lattr) {
1270     my $attr = $doc-><M::Document.createAttributeNS>
1271     (null, $lname);
1272     for (@{$lattr{$lname}->{nodes}}) {
1273     $attr-><M::Node.appendChild> ($_);
1274     }
1275 wakaba 1.9 if ($attrs->{$lname}->{def}) {
1276     __CODE{t|setAttrType::
1277     $attr => $attr,
1278     $type => {$attrs->{$lname}->{def}-><AG::ATDef.declaredType>},
1279     }__;
1280     }
1281 wakaba 1.1 $el-><M::Element.setAttributeNodeNS> ($attr);
1282     }
1283    
1284     for my $pfx (keys %gattr) {
1285     for my $lname (keys %{$gattr{$pfx}}) {
1286     my $attr = $doc-><M::Document.createAttributeNS>
1287     ($ns->{$pfx}, $pfx.':'.$lname);
1288     for (@{$gattr{$pfx}->{$lname}->{nodes}}) {
1289     $attr-><M::Node.appendChild> ($_);
1290     }
1291 wakaba 1.9 if ($attrs->{$pfx}->{$lname}->{def}) {
1292     __CODE{t|setAttrType::
1293     $attr => $attr,
1294     $type => {$attrs->{$pfx}->{$lname}
1295     ->{def}-><AG::ATDef.declaredType>},
1296     }__;
1297     }
1298 wakaba 1.1 $el-><M::Element.setAttributeNodeNS> ($attr);
1299     }
1300     }
1301    
1302     $node-><M::Node.appendChild> ($el);
1303     }
1304    
1305     ~ (TAGC) {
1306     lang:Perl {
1307     push @{$nodes}, $node;
1308     $node = $el;
1309     }
1310     ?lexmode ElementContent;
1311 wakaba 1.6 } (NESTC) {
1312     my $is_docel;
1313 wakaba 1.1 lang:Perl {
1314     $ns = pop @{$nses};
1315     $type = pop @{$types};
1316 wakaba 1.6 $is_docel = (@{$types} == 0);
1317     }
1318    
1319     if-true ($is_docel) {
1320     return;
1321     }
1322    
1323     ~ (TAGC) {
1324     ?lexmode ElementContent;
1325     } else {
1326     ?lexmode ElementContent;
1327 wakaba 1.1 }
1328     } else {
1329     ?lexmode ElementContent;
1330     }
1331     } else {
1332     ?lexmode ElementContent;
1333     }
1334    
1335     } (ETAGO) {
1336     // End tag
1337    
1338     ?lexmode 'EndTag';
1339    
1340     my $is_docel;
1341    
1342     ~ (Name) {
1343 wakaba 1.3 lang:Perl ($name => $token.value) : has-error {
1344 wakaba 1.1 if ($name eq $type) {
1345     $type = pop @{$types};
1346     if ($type eq '') {
1347     $is_docel = true;
1348     }
1349     $node = pop @{$nodes};
1350     $ns = pop @{$nses};
1351     } else {
1352 wakaba 1.3 my $location;
1353     __CODE{xp|get-location-from-token::
1354     $token => $token,
1355     $result => $location,
1356     }__;
1357     my $continue = __DOMCore:ERROR{xp|wf-element-type-match::
1358     DOMCore:location => {$location},
1359     xp|token => {$token},
1360     xp|expected-element-type => {$type},
1361     xp|actual-element-type => {$name},
1362     xp|node => {$node},
1363     }__;
1364     unless ($continue) {
1365     __EXCEPTION{DOMLS|PARSE_ERR}__;
1366     }
1367 wakaba 1.1 }
1368     }
1369     }
1370    
1371     ~? (S) { }
1372    
1373     if-true ($is_docel) {
1374 wakaba 1.3 lang:Perl : has-error {
1375 wakaba 1.1 if (@{$types}) {
1376 wakaba 1.3 my $location;
1377     __CODE{xp|get-location-from-token::
1378     $token => $token,
1379     $result => $location,
1380     }__;
1381     for my $type (reverse @{$types}) {
1382     my $continue = __DOMCore:ERROR{xp|wf-no-end-tag::
1383     DOMCore:location => {$location},
1384     xp|token => {$token},
1385     xp|expected-element-type => {$type},
1386     xp|node => {$node},
1387     }__;
1388     unless ($continue) {
1389     __EXCEPTION{DOMLS|PARSE_ERR}__;
1390     }
1391     $node = shift @{$nodes};
1392     }
1393 wakaba 1.1 }
1394     }
1395     return;
1396     }
1397    
1398     ~ (TAGC) {
1399     ?lexmode ElementContent;
1400     } else {
1401     ?lexmode 'ElementContent';
1402     }
1403    
1404     } (HCRO) {
1405     &_HexadecimalCharacterReference_
1406     ($doc => $doc, $parent => $node);
1407    
1408     ~ (REFC) {
1409     ?lexmode 'ElementContent';
1410     } else {
1411     ?lexmode ElementContent;
1412     }
1413     } (CRO) {
1414     &_NumericCharacterReference_
1415     ($doc => $doc, $parent => $node);
1416    
1417     ~ (REFC) {
1418     ?lexmode 'ElementContent';
1419     } else {
1420     ?lexmode ElementContent;
1421     }
1422     } (ERO) {
1423 wakaba 1.6 &_GeneralEntityReferenceEC
1424     ($doc => $doc, $parent => $node, $ns => $ns);
1425 wakaba 1.1 } (CDO) {
1426     &_CommentDeclaration_ ($doc => $doc, $parent => $node);
1427    
1428     ~ (MDC) {
1429     ?lexmode ElementContent;
1430     } else {
1431     ?lexmode ElementContent;
1432     }
1433     } (CDSO) {
1434     &_CDATASection_ ($doc => $doc, $parent => $node);
1435    
1436     ~ (MSE) {
1437     ?lexmode 'ElementContent';
1438     } else {
1439     ?lexmode ElementContent;
1440     }
1441     } (PIO) {
1442     &_ProcessingInstruction_ ($doc => $doc, $parent => $node);
1443    
1444     ~ (PIC) {
1445     ?lexmode 'ElementContent';
1446     } else {
1447     ?lexmode ElementContent;
1448     }
1449     }
1450 wakaba 1.3
1451     ~ (#NONE) { }
1452 wakaba 1.1 } // Element_
1453 wakaba 1.11
1454     /*
1455     content := [CharData]
1456     *((element / Reference / CDSect / PI / Comment) [CharData])
1457     */
1458     rule content ($parent, $ns) {
1459     // ?lexmode ElementContent;
1460    
1461     my $doc;
1462     lang:Perl {
1463     $doc = $self->{doc};
1464     }
1465    
1466     ~* (CharData) {
1467     lang:Perl ($data => $token.value) {
1468     $parent-><M::Node.appendChild>
1469     ($self->{doc}-><M::Document.createTextNode> ($data));
1470     }
1471     } (STAGO) {
1472     &Element_ ($doc => $doc, $parent => $parent, $ns => $ns)
1473     : unshift-current-token;
1474     ~ (TAGC) {
1475     ?lexmode ElementContent;
1476     } else {
1477     ?lexmode ElementContent;
1478     }
1479     } (HCRO) {
1480     &_HexadecimalCharacterReference_
1481     ($doc => $doc, $parent => $parent);
1482    
1483     ~ (REFC) {
1484     ?lexmode 'ElementContent';
1485     } else {
1486     ?lexmode ElementContent;
1487     }
1488     } (CRO) {
1489     &_NumericCharacterReference_
1490     ($doc => $doc, $parent => $parent);
1491    
1492     ~ (REFC) {
1493     ?lexmode 'ElementContent';
1494     } else {
1495     ?lexmode ElementContent;
1496     }
1497     } (ERO) {
1498     &_GeneralEntityReferenceEC
1499     ($doc => $doc, $parent => $parent, $ns => $ns);
1500     } (CDO) {
1501     &_CommentDeclaration_ ($doc => $doc, $parent => $parent);
1502    
1503     ~ (MDC) {
1504     ?lexmode ElementContent;
1505     } else {
1506     ?lexmode ElementContent;
1507     }
1508     } (CDSO) {
1509     &_CDATASection_ ($doc => $doc, $parent => $parent);
1510    
1511     ~ (MSE) {
1512     ?lexmode 'ElementContent';
1513     } else {
1514     ?lexmode ElementContent;
1515     }
1516     } (PIO) {
1517     &_ProcessingInstruction_ ($doc => $doc, $parent => $parent);
1518    
1519     ~ (PIC) {
1520     ?lexmode 'ElementContent';
1521     } else {
1522     ?lexmode ElementContent;
1523     }
1524     }
1525     } // content
1526 wakaba 1.1
1527     rule AttributeSpecificationList ($doc, $attrs)
1528     : standalone
1529     {
1530     ?lexmode 'StartTag';
1531    
1532     my $i;
1533     lang:Perl {
1534     $i = 0;
1535     }
1536    
1537     ~* (Name) {
1538     my $atqname;
1539     lang:Perl ($name => $token.value) {
1540     $atqname = $name;
1541     }
1542    
1543     my $vals;
1544     lang:Perl {
1545     if ($attrs->{$atqname}) {
1546 wakaba 1.3 my $location;
1547     __CODE{xp|get-location-from-token::
1548     $token => $token,
1549     $result => $location,
1550     }__;
1551     my $continue = __DOMCore:ERROR{xp|wf-unique-att-spec::
1552     DOMCore:location => {$location},
1553     xp|token => {$token},
1554     xp|name => {$atqname},
1555     }__;
1556     unless ($continue) {
1557     __EXCEPTION{DOMLS|PARSE_ERR}__;
1558     }
1559 wakaba 1.1 }
1560    
1561     $vals = $attrs->{$atqname} = {
1562     nodes => [],
1563     value => '',
1564     index => $i++,
1565     };
1566     }
1567 wakaba 1.3
1568     ~? (S) { }
1569     ~ (VI) { }
1570     ~? (S) { }
1571 wakaba 1.1
1572     ~ (LIT) {
1573     &_AttributeValueSpecification_
1574     ($doc => $doc, $vals => $vals);
1575    
1576     ~ (LIT) {
1577     ?lexmode StartTag;
1578     } else {
1579     ?lexmode StartTag;
1580     }
1581     } (LITA) {
1582     &_AttributeValueSpecificationA_
1583     ($doc => $doc, $vals => $vals);
1584    
1585     ~ (LITA) {
1586     ?lexmode StartTag;
1587     } else {
1588     ?lexmode StartTag;
1589     }
1590     }
1591     } (S) : separator : terminator? { }
1592     } // AttributeSpecificationList
1593    
1594     rule _AttributeValueSpecification_ ($doc, $vals) {
1595     // ~ (LIT) { }
1596     ?lexmode 'AttributeValueLiteral';
1597    
1598     ~* (STRING) {
1599     lang:Perl ($value => $token.value) {
1600     $value =~ s/[\x09\x0A\x0D]/ /g;
1601     my $text = $doc-><M::Document.createTextNode> ($value);
1602     push @{$vals->{nodes}}, $text;
1603     $vals->{value} .= $value;
1604     }
1605     } (HCRO) {
1606     &_HexadecimalCharacterReferenceV_
1607     ($doc => $doc, $vals => $vals);
1608    
1609     ~ (REFC) {
1610     ?lexmode AttributeValueLiteral;
1611     } else {
1612     ?lexmode AttributeValueLiteral;
1613     }
1614     } (CRO) {
1615     &_NumericCharacterReferenceV_
1616     ($doc => $doc, $vals => $vals);
1617    
1618     ~ (REFC) {
1619     ?lexmode AttributeValueLiteral;
1620     } else {
1621     ?lexmode AttributeValueLiteral;
1622     }
1623     } (ERO) {
1624     // TODO: Attribute value normalization
1625     &_GeneralEntityReferenceV_
1626     ($doc => $doc, $vals => $vals);
1627    
1628     ~ (REFC) {
1629     ?lexmode AttributeValueLiteral;
1630     } else {
1631     ?lexmode AttributeValueLiteral;
1632     }
1633     }
1634    
1635     // ~ (LIT) { } (LITA) { }
1636     } // _AttributeValueSpecification_
1637    
1638     rule _AttributeValueSpecificationA_ ($doc, $vals) {
1639     // ~ (LITA) { }
1640     ?lexmode 'AttributeValueLiteralA';
1641    
1642     ~* (STRING) {
1643     lang:Perl ($value => $token.value) {
1644     $value =~ s/[\x09\x0A\x0D]/ /g;
1645     my $text = $doc-><M::Document.createTextNode> ($value);
1646     push @{$vals->{nodes}}, $text;
1647     $vals->{value} .= $value;
1648     }
1649     } (HCRO) {
1650     &_HexadecimalCharacterReferenceV_
1651     ($doc => $doc, $vals => $vals);
1652    
1653     ~ (REFC) {
1654     ?lexmode AttributeValueLiteralA;
1655     } else {
1656     ?lexmode AttributeValueLiteralA;
1657     }
1658     } (CRO) {
1659     &_NumericCharacterReferenceV_
1660     ($doc => $doc, $vals => $vals);
1661    
1662     ~ (REFC) {
1663     ?lexmode AttributeValueLiteralA;
1664     } else {
1665     ?lexmode AttributeValueLiteralA;
1666     }
1667     } (ERO) {
1668     // TODO: Attribute value normalization
1669     &_GeneralEntityReferenceV_
1670     ($doc => $doc, $vals => $vals);
1671    
1672     ~ (REFC) {
1673     ?lexmode AttributeValueLiteralA;
1674     } else {
1675     ?lexmode AttributeValueLiteralA;
1676     }
1677     }
1678    
1679     // ~ (LITA) { }
1680     } // _AttributeValueSpecificationA_
1681    
1682     /*
1683 wakaba 1.11 Parsing replacement text of an entity referenced in
1684     an attribute value specification.
1685     */
1686     rule AttributeValueLiteralE_ ($parent, $vals)
1687     : recursive
1688     {
1689     // ?lexmode AttributeValueLiteralE;
1690    
1691     ~* (STRING) {
1692     lang:Perl ($value => $token.value) {
1693     $value =~ s/[\x09\x0A\x0D]/ /g;
1694     my $text = $self->{doc}-><M::Document.createTextNode> ($value);
1695     $parent-><M::Node.appendChild> ($text);
1696     $vals->{value} .= $value;
1697     }
1698     } (HCRO) {
1699     &_HexadecimalCharacterReferenceAE_
1700     ($parent => $parent, $vals => $vals);
1701    
1702     ~ (REFC) {
1703     ?lexmode AttributeValueLiteralE;
1704     } else {
1705     ?lexmode AttributeValueLiteralE;
1706     }
1707     } (CRO) {
1708     &_NumericCharacterReferenceAE_
1709     ($parent => $parent, $vals => $vals);
1710    
1711     ~ (REFC) {
1712     ?lexmode AttributeValueLiteralE;
1713     } else {
1714     ?lexmode AttributeValueLiteralE;
1715     }
1716     } (ERO) {
1717     &_GeneralEntityReferenceAE_ ($parent => $parent, $vals => $vals);
1718    
1719     ~ (REFC) {
1720     ?lexmode AttributeValueLiteralE;
1721     } else {
1722     ?lexmode AttributeValueLiteralE;
1723     }
1724     }
1725    
1726     // ~ (#EOF) { }
1727     } // AttributeValueLiteralE_
1728    
1729     /*
1730 wakaba 1.1 CDATA Section Content Parsing Mode
1731     */
1732     rule _CDATASection_ ($doc, $parent) {
1733     ?lexmode 'CDATASectionContent';
1734    
1735     my $cdata;
1736    
1737 wakaba 1.2 ~? (CData) {
1738 wakaba 1.1 lang:Perl ($data => $token.value) {
1739     $cdata = $data;
1740     }
1741     } else {
1742     lang:Perl {
1743     $cdata = '';
1744     }
1745     }
1746    
1747     lang:Perl {
1748     my $cdsect = $doc-><M::Document.createCDATASection>
1749     ($cdata);
1750     $parent-><M::Node.appendChild> ($cdsect);
1751     }
1752    
1753     // ~ (MSE) { }
1754     } // _CDATASection_
1755    
1756     rule _NumericCharacterReference_ ($doc, $parent) {
1757     ?lexmode 'NumericCharacterReference';
1758    
1759     ~ (NUMBER) {
1760 wakaba 1.3 lang:Perl ($num => $token.value) : has-error {
1761     $num += 0;
1762     unless (
1763     ($self->{xml_version} eq '1.0' and
1764     ((0x0020 <= $num and $num <= 0xD7FF) or
1765     (0xE000 <= $num and $num <= 0xFFFD) or
1766     (0x10000 <= $num and $num <= 0x10FFFF) or
1767     $num == 0x9 or $num == 0xA or $num == 0xD)) or
1768     ($self->{xml_version} eq '1.1' and
1769     ((0x0001 <= $num and $num <= 0xD7FF) or
1770     (0xE000 <= $num and $num <= 0xFFFD) or
1771     (0x10000 <= $num and $num <= 0x10FFFF)))
1772     ) {
1773     my $location;
1774     __CODE{xp|get-location-from-token::
1775     $token => $token,
1776     $result => $location,
1777     }__;
1778     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
1779     DOMCore:location => {$location},
1780     xp|token => {$token},
1781     xp|character-number => {$num},
1782     xp|parent => {$parent},
1783     }__;
1784     unless ($continue) {
1785     __EXCEPTION{DOMLS|PARSE_ERR}__;
1786     }
1787     }
1788     my $ncr = $doc-><M::Document.createTextNode> (chr $num);
1789 wakaba 1.1 $parent-><M::Node.appendChild> ($ncr);
1790     }
1791     }
1792    
1793     // ~ (REFC) { }
1794     } // _NumericCharacterReference_
1795    
1796     rule _NumericCharacterReferenceV_ ($doc, $vals) {
1797     ?lexmode 'NumericCharacterReference';
1798    
1799     ~ (NUMBER) {
1800 wakaba 1.3 lang:Perl ($num => $token.value) : has-error {
1801     $num += 0;
1802     unless (
1803     ($self->{xml_version} eq '1.0' and
1804     ((0x0020 <= $num and $num <= 0xD7FF) or
1805     (0xE000 <= $num and $num <= 0xFFFD) or
1806     (0x10000 <= $num and $num <= 0x10FFFF) or
1807     $num == 0x9 or $num == 0xA or $num == 0xD)) or
1808     ($self->{xml_version} eq '1.1' and
1809     ((0x0001 <= $num and $num <= 0xD7FF) or
1810     (0xE000 <= $num and $num <= 0xFFFD) or
1811     (0x10000 <= $num and $num <= 0x10FFFF)))
1812     ) {
1813     my $location;
1814     __CODE{xp|get-location-from-token::
1815     $token => $token,
1816     $result => $location,
1817     }__;
1818     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
1819     DOMCore:location => {$location},
1820     xp|token => {$token},
1821     xp|character-number => {$num},
1822     }__;
1823     unless ($continue) {
1824     __EXCEPTION{DOMLS|PARSE_ERR}__;
1825     }
1826     }
1827 wakaba 1.1 my $ncr = $doc-><M::Document.createTextNode>
1828 wakaba 1.9 (my $char = chr $num);
1829 wakaba 1.1 push @{$vals->{nodes}}, $ncr;
1830     $vals->{value} .= $char;
1831     }
1832     }
1833    
1834     // ~ (REFC) { }
1835     } // _NumericCharacterReferenceV_
1836    
1837 wakaba 1.11 /*
1838     Numeric character reference in the replacement text
1839     of the entity referenced in an attribute value specification
1840     */
1841     rule _NumericCharacterReferenceAE_ ($parent, $vals)
1842     {
1843     ?lexmode NumericCharacterReference;
1844    
1845     ~ (NUMBER) {
1846     lang:Perl ($num => $token.value) : has-error {
1847     $num += 0;
1848     unless (
1849     ($self->{xml_version} eq '1.0' and
1850     ((0x0020 <= $num and $num <= 0xD7FF) or
1851     (0xE000 <= $num and $num <= 0xFFFD) or
1852     (0x10000 <= $num and $num <= 0x10FFFF) or
1853     $num == 0x9 or $num == 0xA or $num == 0xD)) or
1854     ($self->{xml_version} eq '1.1' and
1855     ((0x0001 <= $num and $num <= 0xD7FF) or
1856     (0xE000 <= $num and $num <= 0xFFFD) or
1857     (0x10000 <= $num and $num <= 0x10FFFF)))
1858     ) {
1859     my $location;
1860     __CODE{xp|get-location-from-token::
1861     $token => $token,
1862     $result => $location,
1863     }__;
1864     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
1865     DOMCore:location => {$location},
1866     xp|token => {$token},
1867     xp|character-number => {$num},
1868     }__;
1869     unless ($continue) {
1870     __EXCEPTION{DOMLS|PARSE_ERR}__;
1871     }
1872     }
1873     my $ncr = $self->{doc}-><M::Document.createTextNode>
1874     (my $char = chr $num);
1875     $parent-><M::Node.appendChild> ($ncr);
1876     $vals->{value} .= $char;
1877     }
1878     }
1879    
1880     // ~ (REFC) { }
1881     } // _NumericCharacterReferenceAE_
1882    
1883     rule _NumericCharacterReferenceEV_ ($vals)
1884     {
1885     ?lexmode 'NumericCharacterReference';
1886    
1887     ~ (NUMBER) {
1888     lang:Perl ($num => $token.value) : has-error {
1889     $num += 0;
1890     unless (
1891     ($self->{xml_version} eq '1.0' and
1892     ((0x0020 <= $num and $num <= 0xD7FF) or
1893     (0xE000 <= $num and $num <= 0xFFFD) or
1894     (0x10000 <= $num and $num <= 0x10FFFF) or
1895     $num == 0x9 or $num == 0xA or $num == 0xD)) or
1896     ($self->{xml_version} eq '1.1' and
1897     ((0x0001 <= $num and $num <= 0xD7FF) or
1898     (0xE000 <= $num and $num <= 0xFFFD) or
1899     (0x10000 <= $num and $num <= 0x10FFFF)))
1900     ) {
1901     my $location;
1902     __CODE{xp|get-location-from-token::
1903     $token => $token,
1904     $result => $location,
1905     }__;
1906     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
1907     DOMCore:location => {$location},
1908     xp|token => {$token},
1909     xp|character-number => {$num},
1910     }__;
1911     unless ($continue) {
1912     __EXCEPTION{DOMLS|PARSE_ERR}__;
1913     }
1914     }
1915     push @{$vals}, chr $num;
1916     }
1917     }
1918    
1919     // ~ (REFC) { }
1920     } // _NumericCharacterReferenceEV_
1921    
1922 wakaba 1.1 rule _HexadecimalCharacterReference_ ($doc, $parent) {
1923     ?lexmode 'HexadecimalCharacterReference';
1924    
1925     ~ (Hex) {
1926 wakaba 1.9 lang:Perl ($v => $token.value) : has-error {
1927     my $num = hex $v;
1928 wakaba 1.3 unless (
1929     ($self->{xml_version} eq '1.0' and
1930     ((0x0020 <= $num and $num <= 0xD7FF) or
1931     (0xE000 <= $num and $num <= 0xFFFD) or
1932     (0x10000 <= $num and $num <= 0x10FFFF) or
1933     $num == 0x9 or $num == 0xA or $num == 0xD)) or
1934     ($self->{xml_version} eq '1.1' and
1935     ((0x0001 <= $num and $num <= 0xD7FF) or
1936     (0xE000 <= $num and $num <= 0xFFFD) or
1937     (0x10000 <= $num and $num <= 0x10FFFF)))
1938     ) {
1939     my $location;
1940     __CODE{xp|get-location-from-token::
1941     $token => $token,
1942     $result => $location,
1943     }__;
1944     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
1945     DOMCore:location => {$location},
1946     xp|token => {$token},
1947     xp|character-number => {$num},
1948     xp|parent => {$parent},
1949     }__;
1950     unless ($continue) {
1951     __EXCEPTION{DOMLS|PARSE_ERR}__;
1952     }
1953     }
1954 wakaba 1.1 my $ncr = $doc-><M::Document.createTextNode>
1955 wakaba 1.9 (chr $num);
1956 wakaba 1.1 $parent-><M::Node.appendChild> ($ncr);
1957     }
1958     }
1959    
1960     // ~ (REFC) { }
1961     } // _HexadecimalCharacterReference_
1962    
1963 wakaba 1.3 rule _HexadecimalCharacterReferenceV_ ($doc, $vals) {
1964 wakaba 1.1 ?lexmode 'HexadecimalCharacterReference';
1965    
1966     ~ (Hex) {
1967 wakaba 1.9 lang:Perl ($v => $token.value) : has-error {
1968     my $num = hex $v;
1969 wakaba 1.3 unless (
1970     ($self->{xml_version} eq '1.0' and
1971     ((0x0020 <= $num and $num <= 0xD7FF) or
1972     (0xE000 <= $num and $num <= 0xFFFD) or
1973     (0x10000 <= $num and $num <= 0x10FFFF) or
1974     $num == 0x9 or $num == 0xA or $num == 0xD)) or
1975     ($self->{xml_version} eq '1.1' and
1976     ((0x0001 <= $num and $num <= 0xD7FF) or
1977     (0xE000 <= $num and $num <= 0xFFFD) or
1978     (0x10000 <= $num and $num <= 0x10FFFF)))
1979     ) {
1980     my $location;
1981     __CODE{xp|get-location-from-token::
1982     $token => $token,
1983     $result => $location,
1984     }__;
1985     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
1986     DOMCore:location => {$location},
1987     xp|token => {$token},
1988     xp|character-number => {$num},
1989     }__;
1990     unless ($continue) {
1991     __EXCEPTION{DOMLS|PARSE_ERR}__;
1992     }
1993     }
1994 wakaba 1.1 my $ncr = $doc-><M::Document.createTextNode>
1995 wakaba 1.9 (my $char = chr $num);
1996 wakaba 1.1 push @{$vals->{nodes}}, $ncr;
1997     $vals->{value} .= $char;
1998     }
1999     }
2000    
2001     // ~ (REFC) { }
2002 wakaba 1.11 } // _HexadecimalCharacterReferenceV_
2003    
2004     /*
2005     Hexadecimal character reference in the replacement text
2006     of the entity referenced in an attribute value literal
2007     */
2008     rule _HexadecimalCharacterReferenceAE_ ($parent, $vals)
2009     {
2010     ?lexmode HexadecimalCharacterReference;
2011    
2012     ~ (Hex) {
2013     lang:Perl ($v => $token.value) : has-error {
2014     my $num = hex $v;
2015     unless (
2016     ($self->{xml_version} eq '1.0' and
2017     ((0x0020 <= $num and $num <= 0xD7FF) or
2018     (0xE000 <= $num and $num <= 0xFFFD) or
2019     (0x10000 <= $num and $num <= 0x10FFFF) or
2020     $num == 0x9 or $num == 0xA or $num == 0xD)) or
2021     ($self->{xml_version} eq '1.1' and
2022     ((0x0001 <= $num and $num <= 0xD7FF) or
2023     (0xE000 <= $num and $num <= 0xFFFD) or
2024     (0x10000 <= $num and $num <= 0x10FFFF)))
2025     ) {
2026     my $location;
2027     __CODE{xp|get-location-from-token::
2028     $token => $token,
2029     $result => $location,
2030     }__;
2031     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
2032     DOMCore:location => {$location},
2033     xp|token => {$token},
2034     xp|character-number => {$num},
2035     }__;
2036     unless ($continue) {
2037     __EXCEPTION{DOMLS|PARSE_ERR}__;
2038     }
2039     }
2040     my $ncr = $self->{doc}-><M::Document.createTextNode>
2041     (my $char = chr $num);
2042     $parent-><M::Node.appendChild> ($ncr);
2043     $vals->{value} .= $char;
2044     }
2045     }
2046    
2047     // ~ (REFC) { }
2048     } // _HexadecimalCharacterReferenceAE_
2049    
2050     rule _HexadecimalCharacterReferenceEV_ ($vals) {
2051     ?lexmode HexadecimalCharacterReference;
2052    
2053     ~ (Hex) {
2054     lang:Perl ($v => $token.value) : has-error {
2055     my $num = hex $v;
2056     unless (
2057     ($self->{xml_version} eq '1.0' and
2058     ((0x0020 <= $num and $num <= 0xD7FF) or
2059     (0xE000 <= $num and $num <= 0xFFFD) or
2060     (0x10000 <= $num and $num <= 0x10FFFF) or
2061     $num == 0x9 or $num == 0xA or $num == 0xD)) or
2062     ($self->{xml_version} eq '1.1' and
2063     ((0x0001 <= $num and $num <= 0xD7FF) or
2064     (0xE000 <= $num and $num <= 0xFFFD) or
2065     (0x10000 <= $num and $num <= 0x10FFFF)))
2066     ) {
2067     my $location;
2068     __CODE{xp|get-location-from-token::
2069     $token => $token,
2070     $result => $location,
2071     }__;
2072     my $continue = __DOMCore:ERROR{xp|wf-legal-character::
2073     DOMCore:location => {$location},
2074     xp|token => {$token},
2075     xp|character-number => {$num},
2076     }__;
2077     unless ($continue) {
2078     __EXCEPTION{DOMLS|PARSE_ERR}__;
2079     }
2080     }
2081     push @{$vals}, chr $num;
2082     }
2083     }
2084    
2085     // ~ (REFC) { }
2086     } // _HexadecimalCharacterReferenceEV_
2087    
2088     /*
2089     General entity reference in element's content
2090     */
2091     rule _GeneralEntityReferenceEC ($doc, $parent, $ns)
2092     : recursive
2093     {
2094     ?lexmode 'EntityReference';
2095    
2096     ~ (Name == 'lt') {
2097     lang:Perl {
2098     $parent-><M::Node.appendChild>
2099     ($self->{doc}-><M::Document.createTextNode> ('<'));
2100     }
2101     } (Name == 'gt') {
2102     lang:Perl {
2103     $parent-><M::Node.appendChild>
2104     ($self->{doc}-><M::Document.createTextNode> ('>'));
2105     }
2106     } (Name == 'amp') {
2107     lang:Perl {
2108     $parent-><M::Node.appendChild>
2109     ($self->{doc}-><M::Document.createTextNode> ('&'));
2110     }
2111     } (Name == 'quot') {
2112     lang:Perl {
2113     $parent-><M::Node.appendChild>
2114     ($self->{doc}-><M::Document.createTextNode> ('"'));
2115     }
2116     } (Name == 'apos') {
2117     lang:Perl {
2118     $parent-><M::Node.appendChild>
2119     ($self->{doc}-><M::Document.createTextNode> ("'"));
2120     }
2121     } (Name) {
2122     my $er;
2123     lang:Perl ($name => $token.value) {
2124     ## TODO: Namespace well-formedness
2125     ## TODO: Entity declared constraints
2126     $er = $doc-><M::Document.createEntityReference>
2127     ($name);
2128     $parent-><M::Node.appendChild> ($er);
2129     push @{$self->{entity}}, <Code::getCopyOfEntityState::
2130     $entity_type = 'general_entity',
2131     $entity_name = $name>;
2132 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2133 wakaba 1.11 push @{$self->{entity_token}}, $self->{token};
2134     $self->{token} = [];
2135     push @{$self->{entity_char}}, $self->{char};
2136     $self->{char} = [];
2137     }
2138    
2139     ?lexmode ElementContent;
2140     &content ($doc => $doc, $parent => $er, $ns => $ns);
2141     ~ (#EOF) { }
2142     lang:Perl {
2143     $self->{token} = pop @{$self->{entity_token}};
2144     $self->{char} = pop @{$self->{entity_char}};
2145     pop @{$self->{entity}};
2146 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2147 wakaba 1.11 }
2148    
2149     // TODO: Set read-only flag
2150    
2151     ?lexmode EntityReference;
2152     ?requires-next-token;
2153     }
2154    
2155     ~ (REFC) {
2156     ?lexmode ElementContent;
2157     } else {
2158     ?lexmode ElementContent;
2159     }
2160     } // _GeneralEntityReferenceEC
2161    
2162     /*
2163     General entity reference in an attribute value literal
2164     */
2165     rule _GeneralEntityReferenceV_ ($vals) {
2166     ?lexmode EntityReference;
2167    
2168     ~ (Name == 'lt') {
2169     lang:Perl {
2170     push @{$vals->{nodes}}, $self->{doc}-><M::Document.createTextNode>
2171     ('<');
2172     $vals->{value} .= '<';
2173     }
2174     } (Name == 'gt') {
2175     lang:Perl {
2176     push @{$vals->{nodes}}, $self->{doc}-><M::Document.createTextNode>
2177     ('>');
2178     $vals->{value} .= '>';
2179     }
2180     } (Name == 'amp') {
2181     lang:Perl {
2182     push @{$vals->{nodes}}, $self->{doc}-><M::Document.createTextNode>
2183     ('&');
2184     $vals->{value} .= '&';
2185     }
2186     } (Name == 'quot') {
2187     lang:Perl {
2188     push @{$vals->{nodes}}, $self->{doc}-><M::Document.createTextNode>
2189     ('"');
2190     $vals->{value} .= '"';
2191     }
2192     } (Name == 'apos') {
2193     lang:Perl {
2194     push @{$vals->{nodes}}, $self->{doc}-><M::Document.createTextNode>
2195     ("'");
2196     $vals->{value} .= "'";
2197     }
2198     } (Name) {
2199     my $er;
2200     lang:Perl ($name => $token.value) {
2201     ## TODO: Namespace well-formedness
2202     ## TODO: Entity declared constraints
2203     ## TODO: No external entity constraint
2204     $er = $self->{doc}-><M::Document.createEntityReference> ($name);
2205     push @{$vals->{nodes}}, $er;
2206     push @{$self->{entity}}, <Code::getCopyOfEntityState::
2207     $entity_type = 'general_entity',
2208     $entity_name = $name>;
2209 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2210 wakaba 1.11 push @{$self->{entity_token}}, $self->{token};
2211     $self->{token} = [];
2212     push @{$self->{entity_char}}, $self->{char};
2213     $self->{char} = [];
2214     }
2215    
2216     ?lexmode AttributeValueLiteralE;
2217     &AttributeValueLiteralE_ ($parent => $er, $vals => $vals);
2218     ~ (#EOF) { }
2219     lang:Perl {
2220     $self->{token} = pop @{$self->{entity_token}};
2221     $self->{char} = pop @{$self->{entity_char}};
2222     pop @{$self->{entity}};
2223 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2224 wakaba 1.11 }
2225    
2226     // TODO: Set read-only flag
2227    
2228     ?lexmode EntityReference;
2229     ?requires-next-token;
2230     }
2231    
2232     // ~ (REFC) { }
2233     } // _GeneralEntityReferenceV_
2234 wakaba 1.1
2235 wakaba 1.6 /*
2236 wakaba 1.11 General entity reference in the replacement text
2237     of the entity referenced in an attribute value literal
2238 wakaba 1.6 */
2239 wakaba 1.11 rule _GeneralEntityReferenceAE_ ($parent, $vals)
2240 wakaba 1.6 {
2241 wakaba 1.11 ?lexmode EntityReference;
2242 wakaba 1.1
2243 wakaba 1.11 ~ (Name == 'lt') {
2244     lang:Perl {
2245     $parent-><M::Node.appendChild>
2246     ($self->{doc}-><M::Document.createTextNode> ('<'));
2247     $vals->{value} .= '<';
2248     }
2249     } (Name == 'gt') {
2250     lang:Perl {
2251     $parent-><M::Node.appendChild>
2252     ($self->{doc}-><M::Document.createTextNode> ('>'));
2253     $vals->{value} .= '>';
2254     }
2255     } (Name == 'amp') {
2256     lang:Perl {
2257     $parent-><M::Node.appendChild>
2258     ($self->{doc}-><M::Document.createTextNode> ('&'));
2259     $vals->{value} .= '&';
2260     }
2261     } (Name == 'quot') {
2262     lang:Perl {
2263     $parent-><M::Node.appendChild>
2264     ($self->{doc}-><M::Document.createTextNode> ('"'));
2265     $vals->{value} .= '"';
2266     }
2267     } (Name == 'apos') {
2268     lang:Perl {
2269     $parent-><M::Node.appendChild>
2270     ($self->{doc}-><M::Document.createTextNode> ("'"));
2271     $vals->{value} .= "'";
2272     }
2273     } (Name) {
2274 wakaba 1.6 my $er;
2275 wakaba 1.1 lang:Perl ($name => $token.value) {
2276     ## TODO: Namespace well-formedness
2277     ## TODO: Entity declared constraints
2278 wakaba 1.11 ## TODO: No external entity constraint
2279     $er = $self->{doc}-><M::Document.createEntityReference> ($name);
2280 wakaba 1.1 $parent-><M::Node.appendChild> ($er);
2281 wakaba 1.6 push @{$self->{entity}}, <Code::getCopyOfEntityState::
2282     $entity_type = 'general_entity',
2283     $entity_name = $name>;
2284 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2285 wakaba 1.6 push @{$self->{entity_token}}, $self->{token};
2286     $self->{token} = [];
2287     push @{$self->{entity_char}}, $self->{char};
2288     $self->{char} = [];
2289     }
2290    
2291 wakaba 1.11 ?lexmode AttributeValueLiteralE;
2292     &AttributeValueLiteralE_ ($parent => $er, $vals => $vals);
2293 wakaba 1.6 ~ (#EOF) { }
2294     lang:Perl {
2295     $self->{token} = pop @{$self->{entity_token}};
2296     $self->{char} = pop @{$self->{entity_char}};
2297     pop @{$self->{entity}};
2298 wakaba 1.14 $self->{location} = $self->{entity}->[-1];
2299 wakaba 1.6 }
2300    
2301 wakaba 1.11 // TODO: Set read-only flag
2302    
2303 wakaba 1.6 ?lexmode EntityReference;
2304     ?requires-next-token;
2305 wakaba 1.1 }
2306    
2307     // ~ (REFC) { }
2308 wakaba 1.11 } // _GeneralEntityReferenceAE_
2309 wakaba 1.6
2310     /*
2311     General entity reference in literal entity value
2312     */
2313 wakaba 1.11 rule _GeneralEntityReferenceEV_ ($vals) {
2314 wakaba 1.6 ?lexmode 'EntityReference';
2315    
2316     ~ (Name) {
2317     lang:Perl ($name => $token.value) {
2318     ## TODO: Namespace well-formedness
2319     ## TODO: Entity declared constraints
2320     push @$vals, $name;
2321     }
2322     }
2323 wakaba 1.11
2324     // No expansion
2325 wakaba 1.6
2326     // ~ (REFC) { }
2327     } // _GeneralEntityReferenceEV_
2328 wakaba 1.1
2329     /*
2330 wakaba 1.4 Document Type Declaration
2331 wakaba 1.1 */
2332 wakaba 1.4 rule _DocumentTypeDeclaration_ ($doc) {
2333     ?lexmode MarkupDeclaration;
2334    
2335     ~ (Name == 'DOCTYPE') { }
2336    
2337     ~ (S) { }
2338    
2339     // Document type name
2340 wakaba 1.6 my $name;
2341 wakaba 1.4 ~ (Name) {
2342 wakaba 1.6 lang:Perl ($v => $token.value) {
2343     $name = $v;
2344     }
2345     }
2346 wakaba 1.17
2347     my $node;
2348     my $decl;
2349 wakaba 1.6 lang:Perl {
2350 wakaba 1.11 $self->{docx} = $self->{doc}
2351     -><M::Node.getFeature> (<Q::fe:XDoctype>, '3.0');
2352     $node = $self->{docx}-><M::DocumentXDoctype.createDocumentTypeDefinition>
2353     ($name);
2354 wakaba 1.17 $decl = $self->{dtdecl} = $node-><M::Node.getFeature>
2355     (<Q::fe:XDoctypeDeclaration>, '3.0');
2356 wakaba 1.4 }
2357    
2358     ~? (S) {
2359     ~? (Name == 'PUBLIC') {
2360     ~ (S) { }
2361    
2362 wakaba 1.17 &PubidLiteral ($decl => $decl);
2363 wakaba 1.4
2364     ~ (S) { }
2365    
2366 wakaba 1.17 &SystemLiteral ($decl => $decl);
2367 wakaba 1.4
2368     ~? (S) { }
2369     } (Name == 'SYSTEM') {
2370     ~ (S) { }
2371    
2372 wakaba 1.17 &SystemLiteral ($decl => $decl);
2373 wakaba 1.4
2374     ~? (S) { }
2375     }
2376     }
2377 wakaba 1.17
2378 wakaba 1.11 lang:Perl {
2379     $self->{dtdef} = $node;
2380     $doc-><M::Node.appendChild> ($node);
2381     $doc-><AG::Document.domConfig>
2382     -><M::c|DOMConfiguration.setParameter>
2383     ('schema-type' => <Q::xml-dtd:>);
2384     }
2385    
2386 wakaba 1.4 ~? (DSO) {
2387 wakaba 1.6 &InternalSubset ($doc => $doc, $doctype => $node);
2388 wakaba 1.4
2389     ~ (DSC) {
2390     ?lexmode MarkupDeclaration;
2391     } else {
2392     ?lexmode MarkupDeclaration;
2393     }
2394    
2395     ~? (S) { }
2396     }
2397    
2398     // TODO: set $self->{standalone} true if only internal subset
2399     // with no param ref
2400    
2401     // ~ (MDC) { }
2402     } // _DocumentTypeDeclaration_
2403    
2404 wakaba 1.17 /*
2405     Public Identifier Literal
2406     */
2407     rule PubidLiteral ($decl) {
2408     my $pubid;
2409     my $pubid_token;
2410 wakaba 1.4 ~ (LIT) {
2411     ?lexmode SystemLiteral;
2412    
2413     ~? (STRING) {
2414 wakaba 1.17 lang:Perl ($v => $token.value) {
2415     $pubid = $v;
2416     $pubid_token = $token;
2417     }
2418 wakaba 1.4 }
2419    
2420     ~ (LIT) {
2421     ?lexmode MarkupDeclaration;
2422     } else {
2423     ?lexmode MarkupDeclaration;
2424     }
2425     } (LITA) {
2426     ?lexmode SystemLiteralA;
2427    
2428     ~? (STRING) {
2429 wakaba 1.17 lang:Perl ($v => $token.value) {
2430     $pubid = $v;
2431     $pubid_token = $token;
2432     }
2433 wakaba 1.4 }
2434    
2435     ~ (LITA) {
2436     ?lexmode MarkupDeclaration;
2437     } else {
2438     ?lexmode MarkupDeclaration;
2439     }
2440     }
2441 wakaba 1.17
2442     if-true ($pubid_token) {
2443     lang:Perl : has-error {
2444     if ($pubid =~ m{[^\x20\x0D\x0Aa-zA-Z0-9'()+,./:=?;!*#\@\$_%-]}s) {
2445     my $location;
2446     __CODE{xp|get-location-from-token::
2447     $token => {$pubid_token},
2448     $result => {$location},
2449     }__;
2450     ## Should this be other (new) error type?
2451     my $continue = __DOMCore:ERROR{xp|wf-syntax-error::
2452     xp|error-token => {$token},
2453     c|location => {$location},
2454     }__;
2455     unless ($continue) {
2456     __EXCEPTION{DOMLS|PARSE_ERR::
2457     }__;
2458     }
2459     }
2460    
2461     ## NOTE: U+0009 is syntactically illegal.
2462     $pubid =~ s/[\x09\x0A\x0D\x20]+//gs;
2463     $pubid =~ s/\A\x20//s;
2464     $pubid =~ s/\x20\z//s;
2465     ## NOTE: Bare attribute name is written.
2466     $decl->public_id ($pubid);
2467     }
2468     }
2469 wakaba 1.4 } // PubidLiteral
2470    
2471 wakaba 1.17 /*
2472     System Identifier Literal
2473     */
2474     rule SystemLiteral ($decl) {
2475 wakaba 1.4 ~ (LIT) {
2476     ?lexmode SystemLiteral;
2477 wakaba 1.17 &_SystemLiteral ($decl => $decl);
2478 wakaba 1.4 } (LITA) {
2479     ?lexmode SystemLiteralA;
2480 wakaba 1.17 &_SystemLiteral ($decl => $decl);
2481 wakaba 1.4 }
2482     } // SystemLiteral
2483    
2484 wakaba 1.17 /*
2485     System Identifier Literal Content
2486     */
2487     rule _SystemLiteral ($decl) {
2488     // LIT or LITA
2489    
2490 wakaba 1.4 ~? (STRING) {
2491 wakaba 1.17 lang:Perl ($v => $token.value) {
2492     ## NOTE: Bare attribute name is written.
2493     $decl->system_id ($v);
2494     }
2495 wakaba 1.4 }
2496    
2497     ~ (LIT) {
2498     ?lexmode MarkupDeclaration;
2499     } (LITA) {
2500     ?lexmode MarkupDeclaration;
2501     } else {
2502     ?lexmode MarkupDeclaration;
2503     }
2504     } // _SystemLiteral
2505    
2506     /*
2507     DTD Internal Subset
2508    
2509     intSubset := *(markupdecl / DeclSep) ;; [28b]
2510     */
2511 wakaba 1.6 rule InternalSubset ($doc, $doctype) {
2512 wakaba 1.4 ?lexmode DTD;
2513    
2514     ~* (MDO) {
2515     ?lexmode MarkupDeclaration;
2516    
2517     ~ (Name == 'ELEMENT') {
2518     &_ElementDeclaration ($doc => $doc);
2519     } (Name == 'ATTLIST') {
2520 wakaba 1.8 &_AttlistDeclaration ($doc => $doc, $doctype => $doctype);
2521 wakaba 1.4 } (Name == 'ENTITY') {
2522     &_EntityDeclaration ($doc => $doc);
2523     } (Name == 'NOTATION') {
2524     &_NotationDeclaration ($doc => $doc);
2525     }
2526     } (S) {
2527     //
2528     } (CDO) {
2529     &_CommentDeclarationDTD ($doc => $doc);
2530     } (PIO) {
2531 wakaba 1.6 &_ProcessingInstructionDTD ($doc => $doc, $doctype => $doctype);
2532 wakaba 1.4 } (PERO) {
2533     ?lexmode EntityReference;
2534    
2535     ~ (Name) {
2536    
2537     }
2538    
2539     ~ (REFC) {
2540     ?lexmode DTD;
2541     } else {
2542     ?lexmode DTD;
2543     }
2544     }
2545     } // InternalSubset
2546    
2547     rule _ElementDeclaration ($doc) {
2548     // ~ (MDO) { }
2549     // ?lexmode MarkupDeclaration
2550     // ~ (Name == 'Element') { }
2551    
2552     ~ (S) { }
2553    
2554     ~ (Name) {
2555    
2556     }
2557    
2558     ?lexmode ElementDeclaration;
2559    
2560     ~ (S) { }
2561    
2562     // contentspec
2563     ~ (MGO) {
2564     &_ContentModel ($doc => $doc);
2565     } (Name == 'EMPTY') {
2566    
2567     } (Name == 'ANY') {
2568    
2569     }
2570    
2571     ~? (S) { }
2572    
2573     ~ (MDC) {
2574     ?lexmode DTD;
2575     } else {
2576     ?lexmode DTD;
2577     }
2578     } // _ElementDeclaration
2579    
2580     rule _ContentModel ($doc) {
2581     // ~ (MGO) { }
2582    
2583     ~? (S) { }
2584    
2585     ~ (Name) {
2586     // Element content model
2587     &_ModelGroup ($doc => $doc)
2588     : unshift-current-token;
2589    
2590     ~? (OPT) {
2591    
2592     } (REP) {
2593    
2594     } (PLUS) {
2595    
2596     }
2597    
2598     } (MDO) {
2599     &_ModelGroup ($doc => $doc)
2600     : unshift-current-token;
2601    
2602     ~? (OPT) {
2603    
2604     } (REP) {
2605    
2606     } (PLUS) {
2607    
2608     }
2609    
2610     } (PCDATA) {
2611     // Mixed content declaration
2612     ~? (S) { }
2613    
2614     ~* (OR) {
2615     ~? (S) { }
2616    
2617     ~ (Name) {
2618    
2619     }
2620    
2621     ~? (S) { }
2622     }
2623    
2624     ~ (MGC) { }
2625    
2626     ~? (REP) {
2627    
2628     } else {
2629     // TODO: error if |Name|
2630     }
2631    
2632    
2633     }
2634     } // _ContentModel
2635    
2636     rule _ModelGroup ($doc)
2637     : standalone
2638     : recursive
2639     {
2640     // ~ (MGO) { }
2641     // ~? (S) { }
2642    
2643     &ContentParticle ($doc => $doc);
2644    
2645     ~? (S) { }
2646    
2647     ~? (OR) {
2648     ~? (S) { }
2649    
2650     &ContentParticle ($doc => $doc);
2651    
2652     ~? (S) { }
2653    
2654     ~* (OR) {
2655     ~? (S) { }
2656    
2657     &ContentParticle ($doc => $doc);
2658    
2659     ~? (S) { }
2660     }
2661    
2662     } (SEQ) {
2663     ~? (S) { }
2664    
2665     &ContentParticle ($doc => $doc);
2666    
2667     ~? (S) { }
2668    
2669     ~* (SEQ) {
2670     ~? (S) { }
2671    
2672     &ContentParticle ($doc => $doc);
2673    
2674     ~? (S) { }
2675     }
2676    
2677     }
2678    
2679     ~ (MGC) { }
2680     } // _ModelGroup
2681    
2682     rule ContentParticle ($doc) {
2683     ~ (Name) {
2684    
2685     } (MGO) {
2686     ~? (S) { }
2687    
2688     &_ModelGroup ($doc => $doc);
2689     }
2690    
2691     ~? (OPT) {
2692    
2693     } (REP) {
2694    
2695     } (PLUS) {
2696    
2697     }
2698     } // ContentParticle
2699    
2700 wakaba 1.8 /*
2701     Attribute list declaration
2702     */
2703     rule _AttlistDeclaration ($doc, $doctype) {
2704 wakaba 1.4 // ~ (MDO) { }
2705     // ~ (Name == 'ATTLIST') { }
2706    
2707     ?lexmode AttlistDeclaration;
2708    
2709     ~ (S) { }
2710    
2711 wakaba 1.8 my $name;
2712 wakaba 1.4 ~ (Name) {
2713 wakaba 1.8 lang:Perl ($v => $token.value) {
2714     $name = $v;
2715     }
2716     } else {
2717     lang:Perl { $name = '#ILLEGAL' }
2718     }
2719 wakaba 1.4
2720 wakaba 1.8 my $docxd;
2721     my $et;
2722     lang:Perl {
2723     $et = $doctype-><M::DTDef.getElementTypeDefinitionNode> ($name);
2724     unless ($et) {
2725 wakaba 1.11 $docxd = $doc-><M::Node.getFeature> (<Q::fe:XDoctype>, '3.0');
2726 wakaba 1.8 $et = $docxd-><M::DocumentXDoctype.createElementTypeDefinition>
2727     ($name);
2728     $doctype-><M::DTDef.setElementTypeDefinitionNode> ($et)
2729     unless $name eq '#ILLEGAL';
2730     }
2731 wakaba 1.4 }
2732    
2733     ~? (S) { }
2734    
2735     ~* (Name) {
2736 wakaba 1.8 my $at;
2737     lang:Perl ($v => $token.value) {
2738     $docxd ||= $doc-><M::Node.getFeature>
2739 wakaba 1.11 (<Q::fe:XDoctype>, '3.0');
2740 wakaba 1.8 $at = $docxd-><M::DocumentXDoctype.createAttributeDefinition> ($v);
2741 wakaba 1.9 unless (exists $et-><AG::ETDef.attributeDefinitions>->{$v}) {
2742     $et-><M::ETDef.setAttributeDefinitionNode> ($at);
2743     $self->{attr}->{$name}->{$v} = $at;
2744     }
2745 wakaba 1.8 }
2746 wakaba 1.4
2747     ~ (S) { }
2748    
2749     // AttType
2750     ~ (Name == 'NOTATION') {
2751     ~ (S) { }
2752    
2753 wakaba 1.8 my $kwd;
2754     lang:Perl {
2755     $at-><AS::ATDef.declaredType> (<C::ATDef.NOTATION_ATTR>);
2756     $kwd = $at-><AG::ATDef.allowedTokens>;
2757     }
2758    
2759 wakaba 1.4 ~ (EGO) {
2760     ~? (S) { }
2761    
2762 wakaba 1.8 ~+ (Name) {
2763     lang:Perl ($v => $token.value) {
2764     push @$kwd, $v;
2765     }
2766 wakaba 1.4
2767     ~? (S) { }
2768     } (OR) : separator {
2769     ~? (S) { }
2770     }
2771    
2772     ~ (EGC) { }
2773     }
2774 wakaba 1.8
2775 wakaba 1.4 } (Name) {
2776 wakaba 1.8 my $type;
2777     lang:Perl ($v => $token.value) : has-error {
2778     my $map = {
2779     CDATA => <C::ATDef.CDATA_ATTR>,
2780     ID => <C::ATDef.ID_ATTR>,
2781     IDREF => <C::ATDef.IDREF_ATTR>,
2782     IDREFS => <C::ATDef.IDREFS_ATTR>,
2783     ENTITY => <C::ATDef.ENTITY_ATTR>,
2784     ENTITIES => <C::ATDef.ENTITIES_ATTR>,
2785     NMTOKEN => <C::ATDef.NMTOKEN_ATTR>,
2786     NMTOKENS => <C::ATDef.NMTOKENS_ATTR>,
2787     };
2788     if ($map->{$v}) {
2789     $at-><AS::ATDef.declaredType> ($map->{$v});
2790     } else {
2791     ## TODO: Exception
2792     }
2793     }
2794 wakaba 1.4
2795     } (EGO) {
2796     ?lexmode Enumeration;
2797    
2798     ~? (S) { }
2799    
2800 wakaba 1.8 my $kwd;
2801     lang:Perl {
2802     $at-><AS::ATDef.declaredType> (<C::ATDef.ENUMERATION_ATTR>);
2803     $kwd = $at-><AG::ATDef.allowedTokens>;
2804     }
2805    
2806     ~+ (Nmtoken) {
2807     lang:Perl ($v => $token.value) {
2808     push @$kwd, $v;
2809     }
2810 wakaba 1.4
2811     ~? (S) { }
2812     } (OR) : separator {
2813     ~? (S) { }
2814     }
2815    
2816     ~ (EGC) {
2817     ?lexmode AttlistDeclaration;
2818     } else {
2819     ?lexmode AttlistDeclaration;
2820     }
2821    
2822     }
2823    
2824     ~ (S) { }
2825    
2826     // DefaultDecl
2827     ~ (RNI) {
2828     ~ (Name == 'REQUIRED') {
2829 wakaba 1.8 lang:Perl {
2830     $at-><AS::ATDef.defaultType> (<C::ATDef.REQUIRED_DEFAULT>);
2831     }
2832 wakaba 1.4 } (Name == 'IMPLIED') {
2833 wakaba 1.8 lang:Perl {
2834     $at-><AS::ATDef.defaultType> (<C::ATDef.IMPLIED_DEFAULT>);
2835     }
2836 wakaba 1.4 } (Name == 'FIXED') {
2837     ~ (S) { }
2838 wakaba 1.8
2839     lang:Perl {
2840     $at-><AS::ATDef.defaultType> (<C::ATDef.FIXED_DEFAULT>);
2841     }
2842 wakaba 1.4
2843     ~ (LIT) {
2844     my $vals;
2845     lang:Perl {
2846 wakaba 1.8 $vals = {nodes => [], value => ''};
2847 wakaba 1.4 }
2848    
2849     &_AttributeValueSpecification_ ($doc => $doc, $vals => $vals);
2850    
2851 wakaba 1.8 lang:Perl {
2852     for (@{$vals->{nodes}}) {
2853     $at-><M::Node.appendChild> ($_);
2854     }
2855     }
2856    
2857 wakaba 1.4 ~ (LIT) {
2858     ?lexmode AttlistDeclaration;
2859     } else {
2860     ?lexmode AttlistDeclaration;
2861     }
2862     } (LITA) {
2863     my $vals;
2864     lang:Perl {
2865 wakaba 1.8 $vals = {nodes => [], value => ''};
2866 wakaba 1.4 }
2867    
2868     &_AttributeValueSpecificationA_ ($doc => $doc, $vals => $vals);
2869    
2870 wakaba 1.8 lang:Perl {
2871     for (@{$vals->{nodes}}) {
2872     $at-><M::Node.appendChild> ($_);
2873     }
2874     }
2875    
2876     ~ (LITA) {
2877 wakaba 1.4 ?lexmode AttlistDeclaration;
2878     } else {
2879     ?lexmode AttlistDeclaration;
2880     }
2881     }
2882     }
2883    
2884     } (LIT) {
2885     my $vals;
2886     lang:Perl {
2887 wakaba 1.8 $at-><AS::ATDef.defaultType> (<C::ATDef.EXPLICIT_DEFAULT>);
2888     $vals = {nodes => [], value => ''};
2889 wakaba 1.4 }
2890    
2891     &_AttributeValueSpecification_ ($doc => $doc, $vals => $vals);
2892    
2893 wakaba 1.8 lang:Perl {
2894     for (@{$vals->{nodes}}) {
2895     $at-><M::Node.appendChild> ($_);
2896     }
2897     }
2898    
2899 wakaba 1.4 ~ (LIT) {
2900     ?lexmode AttlistDeclaration;
2901     } else {
2902     ?lexmode AttlistDeclaration;
2903     }
2904     } (LITA) {
2905     my $vals;
2906     lang:Perl {
2907 wakaba 1.8 $at-><AS::ATDef.defaultType> (<C::ATDef.EXPLICIT_DEFAULT>);
2908     $vals = {nodes => [], value => ''};
2909 wakaba 1.4 }
2910    
2911     &_AttributeValueSpecificationA_ ($doc => $doc, $vals => $vals);
2912    
2913 wakaba 1.8 lang:Perl {
2914     for (@{$vals->{nodes}}) {
2915     $at-><M::Node.appendChild> ($_);
2916     }
2917     }
2918    
2919 wakaba 1.4 ~ (LITA) {
2920     ?lexmode AttlistDeclaration;
2921     } else {
2922     ?lexmode AttlistDeclaration;
2923     }
2924     }
2925    
2926     } (S) : separator : terminator? {
2927     //
2928     }
2929    
2930     ~ (MDC) {
2931     ?lexmode DTD;
2932     } else {
2933     ?lexmode DTD;
2934     }
2935     } // _AttlistDeclaration
2936    
2937 wakaba 1.11 /*
2938     Entity declaration
2939     */
2940 wakaba 1.4 rule _EntityDeclaration ($doc) {
2941     // ~ (MDO) { }
2942     // ~ (Name == ENTITY) { }
2943    
2944     ~ (S) { }
2945    
2946 wakaba 1.6 my $decl;
2947 wakaba 1.11 lang:Perl { $decl = { name => '#ILLEGAL' }; }
2948 wakaba 1.6
2949 wakaba 1.4 ~? (PERO) {
2950     ~ (S) { }
2951 wakaba 1.6 lang:Perl {
2952     $decl->{is_param_entity} = true;
2953     }
2954 wakaba 1.4 }
2955    
2956     ~ (Name) {
2957 wakaba 1.6 lang:Perl ($v => $token.value) {
2958     $decl->{name} = $v;
2959     }
2960 wakaba 1.4 }
2961    
2962 wakaba 1.11 lang:Perl {
2963     $decl->{node} = $self->{docx}-><M::DocumentXDoctype.createGeneralEntity>
2964     ($decl->{name});
2965     ## TODO: Parameter entity...
2966     }
2967    
2968 wakaba 1.4 ~ (S) { }
2969    
2970     ~ (LIT) {
2971 wakaba 1.6 &_EntityValue ($doc => $doc, $decl => $decl);
2972 wakaba 1.4 } (LITA) {
2973 wakaba 1.6 &_EntityValueA ($doc => $doc, $decl => $decl);
2974 wakaba 1.4 } (Name == 'PUBLIC') {
2975     ~ (S) { }
2976    
2977 wakaba 1.17 &PubidLiteral ($decl => $decl);
2978 wakaba 1.4
2979     ~ (S) { }
2980    
2981 wakaba 1.17 &SystemLiteral ($decl => $decl);
2982 wakaba 1.4 } (Name == 'SYSTEM') {
2983     ~ (S) { }
2984    
2985 wakaba 1.17 &SystemLiteral ($decl => $decl);
2986 wakaba 1.4 }
2987    
2988     ~? (S) {
2989     ~? (Name == 'NDATA') {
2990     // TODO: error if parameter entity
2991    
2992     ~ (S) { }
2993    
2994     ~ (Name) {
2995 wakaba 1.6 lang:Perl ($v => $token.value) {
2996     $decl->{notation} = $v;
2997 wakaba 1.11 $decl->{node}-><AG::x|Entity.notationName> ($v);
2998 wakaba 1.6 }
2999 wakaba 1.4 }
3000    
3001     ~? (S) { }
3002     }
3003     }
3004    
3005 wakaba 1.6 lang:Perl {
3006     if ($self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'}
3007     ->{$decl->{name}}) {
3008 wakaba 1.11 ## TODO: warning
3009     ## TODO: predefined entity error check
3010 wakaba 1.6 } else {
3011     $self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'}
3012     ->{$decl->{name}} = $decl;
3013 wakaba 1.11 $self->{dtdef}-><M::DTDef.setGeneralEntityNode> ($decl->{node})
3014     unless $decl->{is_param_entity};
3015 wakaba 1.6 }
3016     }
3017    
3018 wakaba 1.4 ~ (MDC) {
3019     ?lexmode DTD;
3020     } else {
3021     ?lexmode DTD;
3022     }
3023     } // _EntityDeclaration
3024    
3025     rule _NotationDeclaration ($doc) {
3026     // ~ (MDO) { }
3027     // ~ (Name == NOTATION) { }
3028    
3029     ~ (S) { }
3030    
3031     ~ (Name) {
3032    
3033     }
3034    
3035     ~ (S) { }
3036    
3037 wakaba 1.17 my $decl;
3038     lang:Perl {
3039     $decl = $self->{docx}-><M::DocumentXDoctype.createGeneralEntity>
3040     ($decl->{name});
3041     ## Temporary: to avoid error.
3042     }
3043    
3044 wakaba 1.4 ~ (Name == 'PUBLIC') {
3045     ~ (S) { }
3046    
3047 wakaba 1.17 &PubidLiteral ($decl => $decl);
3048 wakaba 1.4
3049     ~? (S) {
3050     ~? (LIT) {
3051     ?lexmode SystemLiteral;
3052 wakaba 1.17 &_SystemLiteral ($decl => $decl);
3053 wakaba 1.4
3054     ~? (S) { }
3055     } (LITA) {
3056     ?lexmode SystemLiteralA;
3057 wakaba 1.17 &_SystemLiteral ($decl => $decl);
3058 wakaba 1.4
3059     ~? (S) { }
3060     }
3061     }
3062     } (Name == 'SYSTEM') {
3063     ~ (S) { }
3064    
3065 wakaba 1.17 &SystemLiteral ($decl => $decl);
3066 wakaba 1.4
3067     ~? (S) { }
3068     }
3069    
3070     ~ (MDC) {
3071     ?lexmode DTD;
3072     } else {
3073     ?lexmode DTD;
3074     }
3075     } // _NotationDeclaration
3076    
3077 wakaba 1.11 rule _EntityValue ($decl) {
3078 wakaba 1.4 ?lexmode EntityValue;
3079    
3080     my $vals;
3081 wakaba 1.6 my $reptxt;
3082 wakaba 1.4 lang:Perl {
3083     $vals = [];
3084 wakaba 1.6 $reptxt = '';
3085 wakaba 1.4 }
3086    
3087     ~* (STRING) {
3088 wakaba 1.6 lang:Perl ($v => $token.value) {
3089     $reptxt .= $v;
3090     }
3091 wakaba 1.4 } (PERO) {
3092     ?lexmode EntityDeclaration;
3093 wakaba 1.6
3094     // TODO: Expand or wferror if internal subset
3095 wakaba 1.4
3096     ~ (Name) {
3097    
3098     }
3099    
3100     ~ (REFC) {
3101     ?lexmode EntityValue;
3102     } else {
3103     ?lexmode EntityValue;
3104     }
3105     } (HCRO) {
3106 wakaba 1.11 &_HexadecimalCharacterReferenceEV_ ($vals => $vals);
3107 wakaba 1.4
3108 wakaba 1.6 lang:Perl {
3109 wakaba 1.11 $reptxt .= $vals->[-1];
3110 wakaba 1.6 }
3111    
3112 wakaba 1.4 ~ (REFC) {
3113     ?lexmode EntityValue;
3114     } else {
3115     ?lexmode EntityValue;
3116     }
3117     } (CRO) {
3118 wakaba 1.11 &_NumericCharacterReferenceEV_ ($vals => $vals);
3119 wakaba 1.6
3120     lang:Perl {
3121 wakaba 1.11 $reptxt .= $vals->[-1];
3122 wakaba 1.6 }
3123 wakaba 1.4
3124     ~ (REFC) {
3125     ?lexmode EntityValue;
3126     } else {
3127     ?lexmode EntityValue;
3128     }
3129     } (ERO) {
3130 wakaba 1.11 &_GeneralEntityReferenceEV_ ($vals => $vals);
3131 wakaba 1.4
3132 wakaba 1.6 lang:Perl {
3133 wakaba 1.11 $reptxt .= '&' . $vals->[-1] . ';';
3134 wakaba 1.6 }
3135    
3136 wakaba 1.4 ~ (REFC) {
3137     ?lexmode EntityValue;
3138     } else {
3139     ?lexmode EntityValue;
3140     }
3141     }
3142    
3143     ~ (LIT) {
3144     ?lexmode MarkupDeclaration;
3145     } (LITA) {
3146     ?lexmode MarkupDeclaration;
3147     } else {
3148     ?lexmode MarkupDeclaration;
3149     }
3150 wakaba 1.6
3151     lang:Perl {
3152     $decl->{reptxt} = \$reptxt;
3153     }
3154 wakaba 1.4 } // _EntityValue
3155    
3156 wakaba 1.11 rule _EntityValueA ($decl) {
3157 wakaba 1.4 ?lexmode EntityValueA;
3158    
3159     my $vals;
3160 wakaba 1.6 my $reptxt;
3161 wakaba 1.4 lang:Perl {
3162     $vals = [];
3163 wakaba 1.6 $reptxt = '';
3164 wakaba 1.4 }
3165    
3166     ~* (STRING) {
3167 wakaba 1.6 lang:Perl ($v => $token.value) {
3168     $reptxt .= $v;
3169     }
3170 wakaba 1.4 } (PERO) {
3171     ?lexmode EntityDeclaration;
3172    
3173 wakaba 1.6 // TODO: implement this
3174 wakaba 1.4 ~ (Name) {
3175    
3176     }
3177    
3178     ~ (REFC) {
3179     ?lexmode EntityValueA;
3180     } else {
3181     ?lexmode EntityValueA;
3182     }
3183     } (HCRO) {
3184 wakaba 1.11 &_HexadecimalCharacterReferenceEV_ ($vals => $vals);
3185 wakaba 1.4
3186 wakaba 1.6 lang:Perl {
3187 wakaba 1.11 $reptxt .= $vals->[-1];
3188 wakaba 1.6 }
3189    
3190    
3191 wakaba 1.4 ~ (REFC) {
3192     ?lexmode EntityValueA;
3193     } else {
3194     ?lexmode EntityValueA;
3195     }
3196     } (CRO) {
3197 wakaba 1.11 &_NumericCharacterReferenceEV_ ($vals => $vals);
3198 wakaba 1.4
3199 wakaba 1.6 lang:Perl {
3200 wakaba 1.11 $reptxt .= $vals->[-1];
3201 wakaba 1.6 }
3202    
3203 wakaba 1.4 ~ (REFC) {
3204     ?lexmode EntityValueA;
3205     } else {
3206     ?lexmode EntityValueA;
3207     }
3208     } (ERO) {
3209 wakaba 1.11 &_GeneralEntityReferenceEV_ ($vals => $vals);
3210 wakaba 1.4
3211 wakaba 1.6 lang:Perl {
3212 wakaba 1.11 $reptxt .= '&' . $vals->[-1] . ';';
3213 wakaba 1.6 }
3214    
3215 wakaba 1.4 ~ (REFC) {
3216     ?lexmode EntityValueA;
3217     } else {
3218     ?lexmode EntityValueA;
3219     }
3220     }
3221    
3222     ~ (LITA) {
3223     ?lexmode MarkupDeclaration;
3224     } else {
3225     ?lexmode MarkupDeclaration;
3226     }
3227 wakaba 1.6
3228     lang:Perl {
3229     $decl->{reptxt} = \$reptxt;
3230     }
3231 wakaba 1.4 } // _EntityValueA
3232    
3233    
3234     /*
3235     XML Name
3236     */
3237     lexmode NameChar {
3238     $NameStartChar10 := [
3239     '_' ':'
3240     // Letter
3241     // BaseChar
3242     U+0041..U+005A U+0061..U+007A U+00C0..U+00D6
3243     U+00D8..U+00F6 U+00F8..U+00FF U+0100..U+0131
3244     U+0134..U+013E U+0141..U+0148 U+014A..U+017E
3245     U+0180..U+01C3 U+01CD..U+01F0 U+01F4..U+01F5
3246     U+01FA..U+0217 U+0250..U+02A8 U+02BB..U+02C1
3247     U+0386 U+0388..U+038A U+038C U+038E..U+03A1
3248     U+03A3..U+03CE U+03D0..U+03D6 U+03DA U+03DC
3249     U+03DE U+03E0 U+03E2..U+03F3 U+0401..U+040C
3250     U+040E..U+044F U+0451..U+045C U+045E..U+0481
3251     U+0490..U+04C4 U+04C7..U+04C8 U+04CB..U+04CC
3252     U+04D0..U+04EB U+04EE..U+04F5 U+04F8..U+04F9
3253     U+0531..U+0556 U+0559 U+0561..U+0586
3254     U+05D0..U+05EA U+05F0..U+05F2 U+0621..U+063A
3255     U+0641..U+064A U+0671..U+06B7 U+06BA..U+06BE
3256     U+06C0..U+06CE U+06D0..U+06D3 U+06D5
3257     U+06E5..U+06E6 U+0905..U+0939 U+093D
3258     U+0958..U+0961 U+0985..U+098C U+098F..U+0990
3259     U+0993..U+09A8 U+09AA..U+09B0 U+09B2
3260     U+09B6..U+09B9 U+09DC..U+09DD U+09DF..U+09E1
3261     U+09F0..U+09F1 U+0A05..U+0A0A U+0A0F..U+0A10
3262     U+0A13..U+0A28 U+0A2A..U+0A30 U+0A32..U+0A33
3263     U+0A35..U+0A36 U+0A38..U+0A39 U+0A59..U+0A5C
3264     U+0A5E U+0A72..U+0A74 U+0A85..U+0A8B U+0A8D
3265     U+0A8F..U+0A91 U+0A93..U+0AA8 U+0AAA..U+0AB0
3266     U+0AB2..U+0AB3 U+0AB5..U+0AB9 U+0ABD U+0AE0
3267     U+0B05..U+0B0C U+0B0F..U+0B10 U+0B13..U+0B28
3268     U+0B2A..U+0B30 U+0B32..U+0B33 U+0B36..U+0B39
3269     U+0B3D U+0B5C..U+0B5D U+0B5F..U+0B61
3270     U+0B85..U+0B8A U+0B8E..U+0B90 U+0B92..U+0B95
3271     U+0B99..U+0B9A U+0B9C U+0B9E..U+0B9F
3272     U+0BA3..U+0BA4 U+0BA8..U+0BAA U+0BAE..U+0BB5
3273     U+0BB7..U+0BB9 U+0C05..U+0C0C U+0C0E..U+0C10
3274     U+0C12..U+0C28 U+0C2A..U+0C33 U+0C35..U+0C39
3275     U+0C60..U+0C61 U+0C85..U+0C8C U+0C8E..U+0C90
3276     U+0C92..U+0CA8 U+0CAA..U+0CB3 U+0CB5..U+0CB9
3277     U+0CDE U+0CE0..U+0CE1 U+0D05..U+0D0C
3278     U+0D0E..U+0D10 U+0D12..U+0D28 U+0D2A..U+0D39
3279     U+0D60..U+0D61 U+0E01..U+0E2E U+0E30
3280     U+0E32..U+0E33 U+0E40..U+0E45 U+0E81..U+0E82
3281     U+0E84 U+0E87..U+0E88 U+0E8A U+0E8D
3282     U+0E94..U+0E97 U+0E99..U+0E9F U+0EA1..U+0EA3
3283     U+0EA5 U+0EA7 U+0EAA..U+0EAB U+0EAD..U+0EAE
3284     U+0EB0 U+0EB2..U+0EB3 U+0EBD U+0EC0..U+0EC4
3285     U+0F40..U+0F47 U+0F49..U+0F69 U+10A0..U+10C5
3286     U+10D0..U+10F6 U+1100 U+1102..U+1103
3287     U+1105..U+1107 U+1109 U+110B..U+110C
3288     U+110E..U+1112 U+113C U+113E U+1140 U+114C
3289     U+114E U+1150 U+1154..U+1155 U+1159
3290     U+115F..U+1161 U+1163 U+1165 U+1167 U+1169
3291     U+116D..U+116E U+1172..U+1173 U+1175 U+119E
3292     U+11A8 U+11AB U+11AE..U+11AF U+11B7..U+11B8
3293     U+11BA U+11BC..U+11C2 U+11EB U+11F0 U+11F9
3294     U+1E00..U+1E9B U+1EA0..U+1EF9 U+1F00..U+1F15
3295     U+1F18..U+1F1D U+1F20..U+1F45 U+1F48..U+1F4D
3296     U+1F50..U+1F57 U+1F59 U+1F5B U+1F5D
3297     U+1F5F..U+1F7D U+1F80..U+1FB4 U+1FB6..U+1FBC
3298     U+1FBE U+1FC2..U+1FC4 U+1FC6..U+1FCC
3299     U+1FD0..U+1FD3 U+1FD6..U+1FDB U+1FE0..U+1FEC
3300     U+1FF2..U+1FF4 U+1FF6..U+1FFC U+2126
3301     U+212A..U+212B U+212E U+2180..U+2182
3302     U+3041..U+3094 U+30A1..U+30FA U+3105..U+312C
3303     U+AC00..U+D7A3
3304     // Ideographic
3305     U+4E00..U+9FA5 U+3007 U+3021..U+3029
3306     ];
3307     $NameChar10 := [
3308     '.' '-' '_' ':'
3309     // Letter
3310     // BaseChar
3311     U+0041..U+005A U+0061..U+007A U+00C0..U+00D6
3312     U+00D8..U+00F6 U+00F8..U+00FF U+0100..U+0131
3313     U+0134..U+013E U+0141..U+0148 U+014A..U+017E
3314     U+0180..U+01C3 U+01CD..U+01F0 U+01F4..U+01F5
3315     U+01FA..U+0217 U+0250..U+02A8 U+02BB..U+02C1
3316     U+0386 U+0388..U+038A U+038C U+038E..U+03A1
3317     U+03A3..U+03CE U+03D0..U+03D6 U+03DA U+03DC
3318     U+03DE U+03E0 U+03E2..U+03F3 U+0401..U+040C
3319     U+040E..U+044F U+0451..U+045C U+045E..U+0481
3320     U+0490..U+04C4 U+04C7..U+04C8 U+04CB..U+04CC
3321     U+04D0..U+04EB U+04EE..U+04F5 U+04F8..U+04F9
3322     U+0531..U+0556 U+0559 U+0561..U+0586
3323     U+05D0..U+05EA U+05F0..U+05F2 U+0621..U+063A
3324     U+0641..U+064A U+0671..U+06B7 U+06BA..U+06BE
3325     U+06C0..U+06CE U+06D0..U+06D3 U+06D5
3326     U+06E5..U+06E6 U+0905..U+0939 U+093D
3327     U+0958..U+0961 U+0985..U+098C U+098F..U+0990
3328     U+0993..U+09A8 U+09AA..U+09B0 U+09B2
3329     U+09B6..U+09B9 U+09DC..U+09DD U+09DF..U+09E1
3330     U+09F0..U+09F1 U+0A05..U+0A0A U+0A0F..U+0A10
3331     U+0A13..U+0A28 U+0A2A..U+0A30 U+0A32..U+0A33
3332     U+0A35..U+0A36 U+0A38..U+0A39 U+0A59..U+0A5C
3333     U+0A5E U+0A72..U+0A74 U+0A85..U+0A8B U+0A8D
3334     U+0A8F..U+0A91 U+0A93..U+0AA8 U+0AAA..U+0AB0
3335     U+0AB2..U+0AB3 U+0AB5..U+0AB9 U+0ABD U+0AE0
3336     U+0B05..U+0B0C U+0B0F..U+0B10 U+0B13..U+0B28
3337     U+0B2A..U+0B30 U+0B32..U+0B33 U+0B36..U+0B39
3338     U+0B3D U+0B5C..U+0B5D U+0B5F..U+0B61
3339     U+0B85..U+0B8A U+0B8E..U+0B90 U+0B92..U+0B95
3340     U+0B99..U+0B9A U+0B9C U+0B9E..U+0B9F
3341     U+0BA3..U+0BA4 U+0BA8..U+0BAA U+0BAE..U+0BB5
3342     U+0BB7..U+0BB9 U+0C05..U+0C0C U+0C0E..U+0C10
3343     U+0C12..U+0C28 U+0C2A..U+0C33 U+0C35..U+0C39
3344     U+0C60..U+0C61 U+0C85..U+0C8C U+0C8E..U+0C90
3345     U+0C92..U+0CA8 U+0CAA..U+0CB3 U+0CB5..U+0CB9
3346     U+0CDE U+0CE0..U+0CE1 U+0D05..U+0D0C
3347     U+0D0E..U+0D10 U+0D12..U+0D28 U+0D2A..U+0D39
3348     U+0D60..U+0D61 U+0E01..U+0E2E U+0E30
3349     U+0E32..U+0E33 U+0E40..U+0E45 U+0E81..U+0E82
3350     U+0E84 U+0E87..U+0E88 U+0E8A U+0E8D
3351     U+0E94..U+0E97 U+0E99..U+0E9F U+0EA1..U+0EA3
3352     U+0EA5 U+0EA7 U+0EAA..U+0EAB U+0EAD..U+0EAE
3353     U+0EB0 U+0EB2..U+0EB3 U+0EBD U+0EC0..U+0EC4
3354     U+0F40..U+0F47 U+0F49..U+0F69 U+10A0..U+10C5
3355     U+10D0..U+10F6 U+1100 U+1102..U+1103
3356     U+1105..U+1107 U+1109 U+110B..U+110C
3357     U+110E..U+1112 U+113C U+113E U+1140 U+114C
3358     U+114E U+1150 U+1154..U+1155 U+1159
3359     U+115F..U+1161 U+1163 U+1165 U+1167 U+1169
3360     U+116D..U+116E U+1172..U+1173 U+1175 U+119E
3361     U+11A8 U+11AB U+11AE..U+11AF U+11B7..U+11B8
3362     U+11BA U+11BC..U+11C2 U+11EB U+11F0 U+11F9
3363     U+1E00..U+1E9B U+1EA0..U+1EF9 U+1F00..U+1F15
3364     U+1F18..U+1F1D U+1F20..U+1F45 U+1F48..U+1F4D
3365     U+1F50..U+1F57 U+1F59 U+1F5B U+1F5D
3366     U+1F5F..U+1F7D U+1F80..U+1FB4 U+1FB6..U+1FBC
3367     U+1FBE U+1FC2..U+1FC4 U+1FC6..U+1FCC
3368     U+1FD0..U+1FD3 U+1FD6..U+1FDB U+1FE0..U+1FEC
3369     U+1FF2..U+1FF4 U+1FF6..U+1FFC U+2126
3370     U+212A..U+212B U+212E U+2180..U+2182
3371     U+3041..U+3094 U+30A1..U+30FA U+3105..U+312C
3372     U+AC00..U+D7A3
3373     // Ideographic
3374     U+4E00..U+9FA5 U+3007 U+3021..U+3029
3375     // Digit
3376     U+0030..U+0039 U+0660..U+0669 U+06F0..U+06F9
3377     U+0966..U+096F U+09E6..U+09EF U+0A66..U+0A6F
3378     U+0AE6..U+0AEF U+0B66..U+0B6F U+0BE7..U+0BEF
3379     U+0C66..U+0C6F U+0CE6..U+0CEF U+0D66..U+0D6F
3380     U+0E50..U+0E59 U+0ED0..U+0ED9 U+0F20..U+0F29
3381     // CombiningChar
3382     U+0300..U+0345 U+0360..U+0361 U+0483..U+0486
3383     U+0591..U+05A1 U+05A3..U+05B9 U+05BB..U+05BD
3384     U+05BF U+05C1..U+05C2 U+05C4 U+064B..U+0652
3385     U+0670 U+06D6..U+06DC U+06DD..U+06DF
3386     U+06E0..U+06E4 U+06E7..U+06E8 U+06EA..U+06ED
3387     U+0901..U+0903 U+093C U+093E..U+094C U+094D
3388     U+0951..U+0954 U+0962..U+0963 U+0981..U+0983
3389     U+09BC U+09BE U+09BF U+09C0..U+09C4
3390     U+09C7..U+09C8 U+09CB..U+09CD U+09D7
3391     U+09E2..U+09E3 U+0A02 U+0A3C U+0A3E U+0A3F
3392     U+0A40..U+0A42 U+0A47..U+0A48 U+0A4B..U+0A4D
3393     U+0A70..U+0A71 U+0A81..U+0A83 U+0ABC
3394     U+0ABE..U+0AC5 U+0AC7..U+0AC9 U+0ACB..U+0ACD
3395     U+0B01..U+0B03 U+0B3C U+0B3E..U+0B43
3396     U+0B47..U+0B48 U+0B4B..U+0B4D U+0B56..U+0B57
3397     U+0B82..U+0B83 U+0BBE..U+0BC2 U+0BC6..U+0BC8
3398     U+0BCA..U+0BCD U+0BD7 U+0C01..U+0C03
3399     U+0C3E..U+0C44 U+0C46..U+0C48 U+0C4A..U+0C4D
3400     U+0C55..U+0C56 U+0C82..U+0C83 U+0CBE..U+0CC4
3401     U+0CC6..U+0CC8 U+0CCA..U+0CCD U+0CD5..U+0CD6
3402     U+0D02..U+0D03 U+0D3E..U+0D43 U+0D46..U+0D48
3403     U+0D4A..U+0D4D U+0D57 U+0E31 U+0E34..U+0E3A
3404     U+0E47..U+0E4E U+0EB1 U+0EB4..U+0EB9
3405     U+0EBB..U+0EBC U+0EC8..U+0ECD U+0F18..U+0F19
3406     U+0F35 U+0F37 U+0F39 U+0F3E U+0F3F
3407     U+0F71..U+0F84 U+0F86..U+0F8B U+0F90..U+0F95
3408     U+0F97 U+0F99..U+0FAD U+0FB1..U+0FB7 U+0FB9
3409     U+20D0..U+20DC U+20E1 U+302A..U+302F U+3099
3410     U+309A
3411     // Extender
3412     U+00B7 U+02D0 U+02D1 U+0387 U+0640 U+0E46
3413     U+0EC6 U+3005 U+3031..U+3035 U+309D..U+309E
3414     U+30FC..U+30FE
3415     ];
3416 wakaba 1.1
3417     $NameStartChar11 := [
3418     ':' '_'
3419     'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M'
3420     'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'
3421     'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm'
3422     'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'
3423     U+00C0..U+00D6 U+00D8..U+00F6 U+00F8..U+02FF
3424     U+0370..U+037D U+037F..U+1FFF U+200C..U+200D
3425     U+2070..U+218F U+2C00..U+2FEF U+3001..U+D7FF
3426     U+F900..U+FDCF U+FDF0..U+FFFD U+10000..U+EFFFF
3427     ];
3428     $NameChar11 := [
3429     '-' '.' '0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
3430     U+00B7 U+0300..U+036F U+203F..U+2040
3431     // NameStartChar
3432     ':' '_'
3433     'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M'
3434     'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'
3435     'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm'
3436     'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'
3437     U+00C0..U+00D6 U+00D8..U+00F6 U+00F8..U+02FF
3438     U+0370..U+037D U+037F..U+1FFF U+200C..U+200D
3439     U+2070..U+218F U+2C00..U+2FEF U+3001..U+D7FF
3440     U+F900..U+FDCF U+FDF0..U+FFFD U+10000..U+EFFFF
3441     ];
3442 wakaba 1.4 } // NameChar
3443    
3444     lexmode Name
3445     : extends => 'NameChar'
3446     {
3447 wakaba 1.1 Name : value := $NameStartChar11 $NameChar11*;
3448     } // Name
3449 wakaba 1.4
3450     lexmode Nmtoken
3451     : extends => 'NameChar'
3452     {
3453     Nmtoken : value := $NameChar11*;
3454     } // Nmtoken
3455 wakaba 1.1
3456     /*
3457 wakaba 1.14 S
3458 wakaba 1.1 */
3459     lexmode S {
3460 wakaba 1.14 $s := [U+0009 U+000A U+000D U+0020];
3461     S := $s+;
3462 wakaba 1.1 } // S
3463    
3464     /*
3465     Document end scanning mode
3466     */
3467     lexmode DocumentEnd
3468     : standalone
3469     : extends => 'S'
3470     {
3471     /*
3472     Processing instruction
3473     */
3474     PIO := ['<'] ['?'];
3475    
3476     /*
3477     Comment declaration
3478     */
3479     CDO := ['<'] ['!'] ['-'] ['-'];
3480     } // DocumentEnd
3481    
3482     /*
3483     Document misc scanning mode
3484    
3485     This mode scans |Misc| constructions as well
3486     as document element's start tag.
3487     */
3488     lexmode DocumentMisc
3489     : standalone
3490     : extends => 'DocumentEnd'
3491     {
3492     /*
3493     Document element start tag
3494     */
3495     STAGO := ['<'];
3496     } // DocumentMisc
3497    
3498     /*
3499     Document prolog scanning mode
3500     */
3501     lexmode DocumentProlog
3502     : standalone
3503     : extends => 'DocumentMisc'
3504     {
3505     /*
3506     |DOCTYPE| declaration
3507     */
3508     MDO := ['<'] ['!'];
3509     } // DocumentProlog
3510 wakaba 1.16
3511 wakaba 1.1 /*
3512 wakaba 1.16 Document Start Scanning Mode
3513 wakaba 1.1 */
3514     lexmode DocumentStart
3515     : standalone
3516     : extends => 'DocumentProlog'
3517     {
3518     /*
3519     XML declaration
3520     */
3521 wakaba 1.16 XDO := ['<'] ['?'] ['x'] ['m'] ['l'];
3522 wakaba 1.1 } // DocumentStart
3523    
3524     /*
3525     Comment declaration scanning mode
3526     */
3527     lexmode CommentDeclaration
3528     : standalone
3529     {
3530     /*
3531     Comment close
3532     */
3533     COM := ['-'] ['-'];
3534    
3535     /*
3536     Comment data
3537     */
3538 wakaba 1.15 ?default-token STRING : value;
3539 wakaba 1.1 } // CommentDeclaration
3540    
3541     /*
3542     Processing instruction name and |S| scanning mode
3543     */
3544     lexmode PIName
3545     : standalone
3546     : extends => 'Name'
3547     : extends => 'S'
3548     {
3549     /*
3550     Processing instruction close
3551     */
3552     PIC := ['?'] ['>'];
3553     } // PIName
3554    
3555     /*
3556 wakaba 1.16 Processing instruction name and |S| scanning mode
3557     */
3558     lexmode PINmtoken
3559     : standalone
3560     : extends => 'Nmtoken'
3561     : extends => 'S'
3562     {
3563     /*
3564     Processing instruction close
3565     */
3566     PIC := ['?'] ['>'];
3567     } // PINmtoken
3568    
3569     /*
3570 wakaba 1.1 Processing instruction data scanning mode
3571     */
3572     lexmode PIData
3573     : standalone
3574     {
3575     /*
3576     Processing instruction close
3577     */
3578     PIC := ['?'] ['>'];
3579    
3580     /*
3581     Processing instruction target data
3582     */
3583 wakaba 1.2 ?default-token DATA : value;
3584 wakaba 1.1 } // PIData
3585    
3586     /*
3587     Content of element scanning mode
3588     */
3589     lexmode ElementContent
3590     : standalone
3591     {
3592     /*
3593     Start tag open
3594     */
3595     STAGO := ['<'];
3596    
3597     /*
3598     End tag open
3599     */
3600     ETAGO := ['<'] ['/'];
3601    
3602     /*
3603     Hexadecimal character reference open
3604     */
3605     HCRO := ['&'] ['#'] ['x'];
3606    
3607     /*
3608     Numeric character reference open
3609     */
3610     CRO := ['&'] ['#'];
3611    
3612     /*
3613     General entity reference open
3614     */
3615     ERO := ['&'];
3616    
3617     /*
3618     Comment declaration open
3619     */
3620     CDO := ['<'] ['!'] ['-'] ['-'];
3621    
3622     /*
3623     CDATA section open
3624     */
3625     CDSO := ['<'] ['!'] ['[']
3626     ['C'] ['D'] ['A'] ['T'] ['A'] ['['];
3627    
3628     /*
3629     Processing instruction open
3630     */
3631     PIO := ['<'] ['?'];
3632 wakaba 1.2
3633     /*
3634     Markup section end
3635     */
3636     MSE := [']'] [']'] ['>'];
3637    
3638     /*
3639     Character data
3640     */
3641     /*
3642     Character data and/or |MSE|
3643     */
3644     ?default-token CharData : value;
3645 wakaba 1.1 } // ElementContent
3646    
3647     /*
3648     CDATA section content scanning mode
3649     */
3650     lexmode CDATASectionContent
3651     : standalone
3652     {
3653     /*
3654     Markup section end
3655     */
3656     MSE := [']'] [']'] ['>'];
3657    
3658     /*
3659     Character data
3660 wakaba 1.2 */
3661     ?default-token CData : value;
3662 wakaba 1.1 } // CDATASectionContent
3663    
3664     lexmode EntityReference
3665     : standalone
3666     : extends => 'Name'
3667     {
3668     /*
3669     Reference close
3670     */
3671     REFC := [';'];
3672     } // EntityReference
3673    
3674     lexmode NumericCharacterReference
3675     : standalone
3676     {
3677     /*
3678     Decimal number
3679     */
3680     $digit := ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9'];
3681     NUMBER : value := $digit+;
3682    
3683     /*
3684     Reference close
3685     */
3686     REFC := [';'];
3687     } // NumericCharacterReference
3688    
3689     lexmode HexadecimalCharacterReference
3690     : standalone
3691     {
3692     /*
3693     Hexadecimal number
3694     */
3695     $hexdigit := ['0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
3696     'A' 'B' 'C' 'D' 'E' 'F'
3697     'a' 'b' 'c' 'd' 'e' 'f'];
3698     Hex : value := $hexdigit+;
3699    
3700     /*
3701     Reference close
3702     */
3703     REFC := [';'];
3704     } // HexadecimalCharacterReference
3705    
3706 wakaba 1.16 /*
3707     The XML Declaration and Text Declaration Scanning Mode
3708     */
3709 wakaba 1.3 lexmode XMLDeclaration
3710     : standalone
3711     : extends => 'Name'
3712     : extends => 'S'
3713     {
3714    
3715     /*
3716     Value indicator
3717     */
3718     VI := ['='];
3719    
3720     /*
3721     Literal open
3722     */
3723     LIT := ['"'];
3724     LITA := [U+0027];
3725    
3726     /*
3727     Processing instruction close
3728 wakaba 1.16
3729     The |PIC|, i.e. |?>|, is split into two tokens |PIC1| and |PIC2|
3730     in this scanning mode to set |no_xml11_eol| flag in the
3731     |_XMLDeclaration_| |rule|.
3732 wakaba 1.3 */
3733 wakaba 1.16 PIC1 := ['?'];
3734     PIC2 := ['>'];
3735 wakaba 1.3 } // XMLDeclaration
3736 wakaba 1.16
3737     /*
3738     The XML Declaration or Processing Instruction Scanning Mode
3739    
3740     '<?xml' S ...
3741     (DocumentStart) (XMLDeclarationOrPI) (XMLDeclaration)
3742     '<?xml' '1' S ...
3743     (DocumentStart) (XMLDeclarationOrPI) (PINmtoken)(PIName) (PITarget)
3744     '<?xml' '-' 'stylesheet' S ...
3745     (DocumentStart) (XMLDeclarationOrPI) (PINmtoken) (PIName) (PITarget)
3746     */
3747     lexmode XMLDeclarationOrPI
3748     : standalone
3749     : extends => 'NameChar'
3750     : extends => 'S'
3751     {
3752     NameChar : value := $NameChar11;
3753     } // XMLDeclarationOrPI
3754 wakaba 1.3
3755 wakaba 1.1 lexmode StartTag
3756     : standalone
3757     : extends => 'Name'
3758     : extends => 'S'
3759     {
3760    
3761     /*
3762     Value indicator
3763     */
3764     VI := ['='];
3765    
3766     /*
3767     Literal open
3768     */
3769     LIT := ['"'];
3770     LITA := [U+0027];
3771    
3772     /*
3773     Tag close
3774     */
3775     TAGC := ['>'];
3776    
3777     /*
3778 wakaba 1.6 Null end-tag enabled start-tag close
3779 wakaba 1.1 */
3780 wakaba 1.6 NESTC := ['/'];
3781 wakaba 1.1 } // StartTag
3782    
3783     lexmode EndTag
3784     : standalone
3785     : extends => 'Name'
3786     : extends => 'S'
3787     {
3788     /*
3789     Tag close
3790     */
3791     TAGC := ['>'];
3792     } // EndTag
3793    
3794     lexmode AttributeValueLiteral_ {
3795     ERO := ['&'];
3796     CRO := ['&'] ['#'];
3797     HCRO := ['&'] ['#'] ['x'];
3798     } // AttributeValueLiteral_
3799    
3800     lexmode AttributeValueLiteral
3801     : standalone
3802     : extends => 'AttributeValueLiteral_'
3803     {
3804     LIT := ['"'];
3805 wakaba 1.3 STRING : value := [^'"' '&' '<']+;
3806 wakaba 1.1 } // AttributeValueLiteral
3807    
3808     lexmode AttributeValueLiteralA
3809     : standalone
3810     : extends => 'AttributeValueLiteral_'
3811     {
3812 wakaba 1.4 LITA := [U+0027];
3813 wakaba 1.3 STRING : value := [^U+0027 '&' '<']+;
3814 wakaba 1.1 } // AttributeValueLiteralA
3815 wakaba 1.11
3816     lexmode AttributeValueLiteralE
3817     : standalone
3818     : extends => 'AttributeValueLiteral_'
3819     {
3820     STRING : value := [^'&' '<']+;
3821     } // AttributeValueLiteralE
3822 wakaba 1.4
3823     lexmode EntityValue_ {
3824     PERO := ['%'];
3825     ERO := ['&'];
3826     CRO := ['&'] ['#'];
3827     HCRO := ['&'] ['#'] ['x'];
3828     } // EntityValue_
3829    
3830     lexmode EntityValue
3831     : standalone
3832     : extends => 'EntityValue_'
3833     {
3834     LIT := ['"'];
3835     STRING : value := [^'"' '&' '%']+;
3836     } // EntityValue
3837    
3838     lexmode EntityValueA
3839     : standalone
3840     : extends => 'EntityValue_'
3841     {
3842     LITA := [U+0027];
3843     STRING : value := [^U+0027 '&' '%']+;
3844     } // EntityValueA
3845    
3846     lexmode SystemLiteral
3847     : standalone
3848     {
3849     LIT := ['"'];
3850     ?default-token STRING : value;
3851     } // SystemLiteral
3852    
3853     lexmode SystemLiteralA
3854     : standalone
3855     {
3856     LITA := [U+0027];
3857     ?default-token STRING : value;
3858     } // SystemLiteralA
3859    
3860     lexmode DTD
3861     : standalone
3862     : extends => 'S'
3863     {
3864     /*
3865     Markup declaration open
3866     */
3867     MDO := ['<'] ['!'];
3868    
3869     /*
3870     Comment declaration open
3871     */
3872     CDO := ['<'] ['!'] ['-'] ['-'];
3873    
3874     /*
3875     Processing instruction open
3876     */
3877     PIO := ['<'] ['?'];
3878    
3879     /*
3880     Parameter entity reference open
3881     */
3882     PERO := ['%'];
3883    
3884     /*
3885     Declaration subset close
3886     */
3887     DSC := [']'];
3888    
3889     /*
3890     Contition section open
3891     */
3892     CSO := ['<'] ['!'] ['['];
3893     } // DTD
3894    
3895     /*
3896     Markup declaration scanning mode
3897    
3898     This mode is used to recognize |MDC| that terminates
3899     a comment declaration as well as the base |lexmode|
3900     for e.g. document type declaration scanning mode.
3901     */
3902     lexmode MarkupDeclaration
3903     : standalone
3904     : extends => 'Name'
3905     : extends => 'S'
3906     {
3907     /*
3908     Markup declaration close
3909     */
3910     MDC := ['>'];
3911    
3912     /*
3913     Literal open
3914     */
3915     LIT := ['"'];
3916    
3917     /*
3918     Alternative literal open
3919     */
3920     LITA := [U+0027];
3921    
3922     /*
3923     Parameter entity reference open
3924     */
3925     PERO := ['%'];
3926    
3927     /*
3928     Declaration subset open
3929     */
3930     DSO := ['['];
3931     } // MarkupDeclaration
3932    
3933     lexmode ElementDeclaration
3934     : standalone
3935     : extends => 'MarkupDeclaration'
3936     {
3937     /*
3938     Model group open
3939     */
3940     MGO := ['('];
3941    
3942     /*
3943     Model group close
3944     */
3945     MGC := [')'];
3946    
3947     /*
3948     Reserved name indicator
3949     */
3950     RNI := ['#'];
3951    
3952     /*
3953     Occurence indicators
3954     */
3955     OPT := ['?'];
3956     REP := ['*'];
3957     PLUS := ['+'];
3958    
3959     /*
3960     Connectors
3961     */
3962     OR := ['|'];
3963     SEQ := [','];
3964     } // ElementDeclaration
3965    
3966     lexmode AttlistDeclaration
3967     : standalone
3968     : extends => 'MarkupDeclaration'
3969     {
3970     /*
3971     Enumeration group open
3972     */
3973     EGO := ['('];
3974    
3975     /*
3976     Enumeration group close
3977     */
3978     EGC := [')'];
3979    
3980     /*
3981     Enumeration choice delimiter
3982     */
3983     OR := ['|'];
3984    
3985     /*
3986     Reserved name indicator
3987     */
3988     RNI := ['#'];
3989     } // AttlistDeclaration
3990    
3991     lexmode Enumeration
3992     : standalone
3993     : extends => 'Nmtoken'
3994     : extends => 'S'
3995     {
3996     /*
3997     Enumeration group close
3998     */
3999     EGC := [')'];
4000    
4001     /*
4002     Enumeration choice delimiter
4003     */
4004     OR := ['|'];
4005     } // Enumeration
4006    
4007 wakaba 1.1
4008     token-error default : default {
4009     lang:Perl {
4010 wakaba 1.3 my $location;
4011     __CODE{xp|get-location-from-token::
4012     $token => {$token},
4013     $result => {$location},
4014     }__;
4015     my $continue = __DOMCore:ERROR{xp|wf-syntax-error::
4016 wakaba 1.1 xp|error-token => {$token},
4017     DOMCore|location => {$location},
4018     }__;
4019     unless ($continue) {
4020     __EXCEPTION{DOMLS|PARSE_ERR::
4021     }__;
4022     }
4023     }
4024     } // default
4025 wakaba 1.5
4026     @XMLTests:
4027     @@XMLTest:
4028 wakaba 1.15 @@@QName: xp.char.xml10.test
4029     @@@DEnt:
4030     @@@@test:value:
4031     <?xml version="1.0"?>
4032     <p>$u0009$u000A$u000D$u0020$uD7FF$uE000$uFFFD$U00010000$U0010FFFF</p>
4033     @@@test:domTree:
4034     document {
4035     xml-version: '1.0';
4036     element {
4037     text-content: U+0009 U+000A U+000A U+0020 U+D7FF
4038     U+E000 U+FFFD U+10000 U+10FFFF;
4039     }
4040     }
4041     @@XMLTest:
4042     @@@QName: xp.char.xml11.test
4043     @@@DEnt:
4044     @@@@test:value:
4045     <?xml version="1.1"?>
4046     <p>$u0009$u000A$u000D$u0020$uD7FF$uE000$uFFFD$U00010000$U0010FFFF</p>
4047     @@@test:domTree:
4048     document {
4049     xml-version: '1.1';
4050     element {
4051     text-content: U+0009 U+000A U+000A U+0020 U+D7FF
4052     U+E000 U+FFFD U+10000 U+10FFFF;
4053     }
4054     }
4055     @@XMLTest:
4056     @@@QName: xp.char.xml10.c0.test
4057     @@@DEnt:
4058     @@@@test:value:
4059     <?xml version="1.0"?>
4060     <p>$u0000$u0001$u0002$u0003$u0004$u0005$u0006$u0007$u0008$u000B$
4061     $u000C$u000E$u000F$u0010$u0011$u0012$u0013$u0014$u0015$u0016$
4062     $u0017$u0018$u0019$u001A$u001B$u001C$u001D$u001E$u001F</p>
4063     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 4); } /* U+0000 */
4064     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 5); } /* U+0001 */
4065     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 6); } /* U+0002 */
4066     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 7); } /* U+0003 */
4067     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 8); } /* U+0004 */
4068     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 9); } /* U+0005 */
4069     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 10); } /* U+0006 */
4070     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 11); } /* U+0007 */
4071     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 12); } /* U+0008 */
4072     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 13); } /* U+000B */
4073     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 14); } /* U+000C */
4074     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 15); } /* U+000E */
4075     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 16); } /* U+000F */
4076     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 17); } /* U+0010 */
4077     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 18); } /* U+0011 */
4078     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 19); } /* U+0012 */
4079     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 20); } /* U+0013 */
4080     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 21); } /* U+0014 */
4081     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 22); } /* U+0015 */
4082     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 23); } /* U+0016 */
4083     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 24); } /* U+0017 */
4084     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 25); } /* U+0018 */
4085     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 26); } /* U+0019 */
4086     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 27); } /* U+001A */
4087     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 28); } /* U+001B */
4088     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 29); } /* U+001C */
4089     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 30); } /* U+001D */
4090     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 31); } /* U+001E */
4091     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 32); } /* U+001F */
4092     @@XMLTest:
4093     @@@QName: xp.char.xml11.c0.test
4094     @@@DEnt:
4095     @@@@test:value:
4096     <?xml version="1.1"?>
4097     <p>$u0000$u0001$u0002$u0003$u0004$u0005$u0006$u0007$u0008$u000B$
4098     $u000C$u000E$u000F$u0010$u0011$u0012$u0013$u0014$u0015$u0016$
4099     $u0017$u0018$u0019$u001A$u001B$u001C$u001D$u001E$u001F</p>
4100     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 4); } /* U+0000 */
4101     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 5); } /* U+0001 */
4102     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 6); } /* U+0002 */
4103     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 7); } /* U+0003 */
4104     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 8); } /* U+0004 */
4105     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 9); } /* U+0005 */
4106     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 10); } /* U+0006 */
4107     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 11); } /* U+0007 */
4108     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 12); } /* U+0008 */
4109     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 13); } /* U+000B */
4110     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 14); } /* U+000C */
4111     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 15); } /* U+000E */
4112     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 16); } /* U+000F */
4113     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 17); } /* U+0010 */
4114     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 18); } /* U+0011 */
4115     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 19); } /* U+0012 */
4116     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 20); } /* U+0013 */
4117     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 21); } /* U+0014 */
4118     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 22); } /* U+0015 */
4119     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 23); } /* U+0016 */
4120     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 24); } /* U+0017 */
4121     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 25); } /* U+0018 */
4122     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 26); } /* U+0019 */
4123     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 27); } /* U+001A */
4124     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 28); } /* U+001B */
4125     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 29); } /* U+001C */
4126     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 30); } /* U+001D */
4127     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 31); } /* U+001E */
4128     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 32); } /* U+001F */
4129     @@XMLTest:
4130     @@@QName: xp.char.xml10.c1.test
4131     @@@DEnt:
4132     @@@@test:value:
4133     <?xml version="1.0"?>
4134     <p>$u007F$u0080$u0081$u0082$u0083$u0084$u0086$u0087$u0088$
4135     $u0089$u008A$u008B$u008C$
4136     $u008D$u008E$u008F$u0090$u0091$u0092$u0093$u0094$u0095$u0096$
4137     $u0097$u0098$u0099$u009A$u009B$u009C$u009D$u009E$u009F$u0085</p>
4138     @@@test:domTree:
4139     document {
4140     xml-version: '1.0';
4141     element {
4142     text-content: U+007F U+0080 U+0081 U+0082 U+0083 U+0084 U+0086
4143     U+0087 U+0088 U+0089 U+008A U+008B U+008C U+008D
4144     U+008E U+008F U+0090 U+0091 U+0092 U+0093 U+0094
4145     U+0095 U+0096 U+0097 U+0098 U+0099 U+009A U+009B
4146     U+009C U+009D U+009E U+009F U+0085;
4147     }
4148     }
4149     @@XMLTest:
4150     @@@QName: xp.char.xml11.c1.test
4151     @@@DEnt:
4152     @@@@test:value:
4153     <?xml version="1.1"?>
4154     <p>$u007F$u0080$u0081$u0082$u0083$u0084$u0086$u0087$u0088$
4155     $u0089$u008A$u008B$u008C$
4156     $u008D$u008E$u008F$u0090$u0091$u0092$u0093$u0094$u0095$u0096$
4157     $u0097$u0098$u0099$u009A$u009B$u009C$u009D$u009E$u009F$u0085</p>
4158     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 4); } /* U+007F */
4159     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 5); } /* U+0080 */
4160     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 6); } /* U+0081 */
4161     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 7); } /* U+0082 */
4162     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 8); } /* U+0083 */
4163     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 9); } /* U+0084 */
4164     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 10); } /* U+0086 */
4165     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 11); } /* U+0087 */
4166     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 12); } /* U+0088 */
4167     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 13); } /* U+0089 */
4168     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 14); } /* U+008A */
4169     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 15); } /* U+008B */
4170     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 16); } /* U+008C */
4171     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 17); } /* U+008D */
4172     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 18); } /* U+008E */
4173     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 19); } /* U+008F */
4174     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 20); } /* U+0090 */
4175     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 21); } /* U+0091 */
4176     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 22); } /* U+0092 */
4177     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 23); } /* U+0093 */
4178     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 24); } /* U+0094 */
4179     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 25); } /* U+0095 */
4180     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 26); } /* U+0096 */
4181     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 27); } /* U+0097 */
4182     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 28); } /* U+0098 */
4183     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 29); } /* U+0099 */
4184     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 30); } /* U+009A */
4185     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 31); } /* U+009B */
4186     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 32); } /* U+009C */
4187     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 33); } /* U+009D */
4188     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 34); } /* U+009E */
4189     @@@c:erred: <[[xp|wf-legal-literal-character]]> { (2, 35); } /* U+009F */
4190    
4191     @@XMLTest:
4192 wakaba 1.12 @@@QName: xp.syntax.empty.test
4193     @@@DEnt:
4194     @@@@test:value: \
4195     @@@c:erred:
4196     <[[xp:wf-syntax-error]]> { (1, 1); }
4197     @@XMLTest:
4198     @@@QName: xp.syntax.space.test
4199     @@@DEnt:
4200 wakaba 1.13 @@@@test:value: \
4201 wakaba 1.12 @@@c:erred:
4202     <[[xp:wf-syntax-error]]> { (1, 4); }
4203     @@XMLTest:
4204     @@@QName: xp.syntax.newlines.test
4205     @@@DEnt:
4206     @@@@test:value:
4207     \
4208     \
4209     \
4210     @@@c:erred:
4211     <[[xp:wf-syntax-error]]> { (3, 1); }
4212    
4213     @@XMLTest:
4214 wakaba 1.6 @@@QName: xp.only.docel.test
4215 wakaba 1.5 @@@DEnt:
4216     @@@@test:value:
4217     <p></p>
4218     @@@test:domTree:
4219     document {
4220     xml-version: '1.0';
4221 wakaba 1.6 xml-encoding: null;
4222     xml-standalone: false;
4223     element {
4224     namespace-uri: null;
4225     prefix: null;
4226     local-name: 'p';
4227     text-content: '';
4228     }
4229     }
4230     @@XMLTest:
4231     @@@QName: xp.only.docel.emptyelemtag.test
4232     @@@DEnt:
4233     @@@@test:value:
4234     <p/>
4235     @@@test:domTree:
4236     document {
4237     xml-version: '1.0';
4238     xml-encoding: null;
4239     xml-standalone: false;
4240 wakaba 1.5 element {
4241     namespace-uri: null;
4242     prefix: null;
4243     local-name: 'p';
4244     text-content: '';
4245     }
4246     }
4247 wakaba 1.15 @@XMLTest:
4248     @@@QName: xp.root.s.1.test
4249     @@@DEnt:
4250     @@@@test:value:
4251     <?xml version="1.0"?>$u0020$u000D$u000A$u0009
4252     <p></p>
4253     @@@test:domTree:
4254     document {
4255     element { }
4256     }
4257    
4258     @@XMLTest:
4259     @@@QName: xp.Name.1.test
4260     @@@DEnt:
4261     @@@@test:value: <name/>
4262     @@@test:domTree:
4263     document {
4264     element {
4265     node-name: 'name';
4266     }
4267     }
4268     @@XMLTest:
4269     @@@QName: xp.Name.2.test
4270     @@@DEnt:
4271     @@@@test:value: <name0/>
4272     @@@test:domTree:
4273     document {
4274     element {
4275     node-name: 'name0';
4276     }
4277     }
4278     @@enImplNote:
4279     @@@ddid: xml11name
4280     @@@@:
4281     {TODO:: XML 1.1 Name tests required
4282     }
4283    
4284     @@XMLTest:
4285     @@@QName: xp.content.mse.1.test
4286     @@@DEnt:
4287     @@@@test:value:
4288     <p>]]></p>
4289     @@@c:erred:
4290     <[[xp|wf-syntax-error]]> { (1, 4)..(1, 6); }
4291     @@XMLTest:
4292     @@@QName: xp.content.mse.2.test
4293     @@@DEnt:
4294     @@@@test:value:
4295     <p>aaa]]>bbb</p>
4296     @@@c:erred:
4297     <[[xp|wf-syntax-error]]> { (1, 7)..(1, 9); }
4298    
4299     @@XMLTest:
4300     @@@QName: xp.root.comment.1.test
4301     @@@DEnt:
4302     @@@@test:value:
4303     <!--comment data-->
4304     <p/>
4305     @@@test:domTree:
4306     document {
4307     comment {
4308     data: 'comment data';
4309     }
4310     element { }
4311     }
4312     @@XMLTest:
4313     @@@QName: xp.root.comment.2.test
4314     @@@DEnt:
4315     @@@@test:value:
4316     <!---->
4317     <p/>
4318     @@@test:domTree:
4319     document {
4320     comment {
4321     data: '';
4322     }
4323     element { }
4324     }
4325     @@XMLTest:
4326     @@@QName: xp.root.after.pi.comment.1.test
4327     @@@DEnt:
4328     @@@@test:value:
4329     <?pi?>
4330     <!--comment data-->
4331     <p/>
4332     @@@test:domTree:
4333     document {
4334     pi { }
4335     comment {
4336     data: 'comment data';
4337     }
4338     element { }
4339     }
4340     @@XMLTest:
4341     @@@QName: xp.root.after.pi.comment.2.test
4342     @@@DEnt:
4343     @@@@test:value:
4344     <?pi?>
4345     <!---->
4346     <p/>
4347     @@@test:domTree:
4348     document {
4349     pi { }
4350     comment {
4351     data: '';
4352     }
4353     element { }
4354     }
4355     @@XMLTest:
4356     @@@QName: xp.root.after.element.comment.1.test
4357     @@@DEnt:
4358     @@@@test:value:
4359     <p/>
4360     <!--comment data-->
4361     @@@test:domTree:
4362     document {
4363     element { }
4364     comment {
4365     data: 'comment data';
4366     }
4367     }
4368     @@XMLTest:
4369     @@@QName: xp.root.after.element.comment.2.test
4370     @@@DEnt:
4371     @@@@test:value:
4372     <p/>
4373     <!---->
4374     @@@test:domTree:
4375     document {
4376     element { }
4377     comment {
4378     data: '';
4379     }
4380     }
4381     @@XMLTest:
4382     @@@QName: xp.doctype.intsubset.comment.1.test
4383     @@@DEnt:
4384     @@@@test:value:
4385     <!DOCTYPE a [
4386     <!--comment data-->
4387     ]>
4388     <p/>
4389     @@@test:domTree:
4390     document {
4391     document-type { }
4392     element { }
4393     }
4394     @@XMLTest:
4395     @@@QName: xp.doctype.intsubset.comment.2.test
4396     @@@DEnt:
4397     @@@@test:value:
4398     <!DOCTYPE a [
4399     <!---->
4400     ]>
4401     <p/>
4402     @@@test:domTree:
4403     document {
4404     document-type { }
4405     element { }
4406     }
4407     @@XMLTest:
4408     @@@QName: xp.doctype.intsubset.comment.3.test
4409     @@@DEnt:
4410     @@@@test:value:
4411     <!DOCTYPE a [
4412     <?pi?>
4413     <!---->
4414     ]>
4415     <p/>
4416     @@@test:domTree:
4417     document {
4418     document-type {
4419     pi { }
4420     }
4421     element { }
4422     }
4423     @@XMLTest:
4424     @@@QName: xp.content.comment.1.test
4425     @@@DEnt:
4426     @@@@test:value:
4427     <p><!--comment data--></p>
4428     @@@test:domTree:
4429     document {
4430     element {
4431     comment {
4432     data: 'comment data';
4433     }
4434     }
4435     }
4436     @@XMLTest:
4437     @@@QName: xp.content.comment.2.test
4438     @@@DEnt:
4439     @@@@test:value:
4440     <p><!----></p>
4441     @@@test:domTree:
4442     document {
4443     element {
4444     comment {
4445     data: '';
4446     }
4447     }
4448     }
4449     @@XMLTest:
4450     @@@QName: xp.content.comment.3.test
4451     @@@DEnt:
4452     @@@@test:value:
4453     <p>aaaaa<!---->bbbbb</p>
4454     @@@test:domTree:
4455     document {
4456     element {
4457     text {
4458     data: 'aaaaa';
4459     }
4460     comment {
4461     data: '';
4462     }
4463     text {
4464     data: 'bbbbb';
4465     }
4466     }
4467     }
4468     @@XMLTest:
4469     @@@QName: xp.content.comment.--.1.test
4470     @@@DEnt:
4471     @@@@test:value:
4472     <p><!--data--data--></p>
4473     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 12)..(1, 17); }
4474     @@XMLTest:
4475     @@@QName: xp.content.comment.---gt.test
4476     @@@DEnt:
4477     @@@@test:value:
4478     <p><!--data---></p>
4479     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 12)..(1, 15); }
4480 wakaba 1.13
4481     @@XMLTest:
4482     @@@QName: xp.xmldecl.version.1.0.test
4483     @@@DEnt:
4484     @@@@test:value:
4485     <?xml version="1.0"?>
4486     <p></p>
4487     @@@test:domTree:
4488     document {
4489     xml-version: '1.0';
4490     xml-encoding: null;
4491     xml-standalone: false;
4492     element { }
4493     }
4494     @@XMLTest:
4495     @@@QName: xp.xmldecl.version.1.0.lita.test
4496     @@@DEnt:
4497     @@@@test:value:
4498     <?xml version='1.0'?>
4499     <p></p>
4500     @@@test:domTree:
4501     document {
4502     xml-version: '1.0';
4503     xml-encoding: null;
4504     xml-standalone: false;
4505     element { }
4506     }
4507     @@XMLTest:
4508     @@@QName: xp.xmldecl.version.1.0.s.test
4509     @@@DEnt:
4510     @@@@test:value:
4511     <?xml version = "1.0" ?>
4512     <p></p>
4513     @@@test:domTree:
4514     document {
4515     xml-version: '1.0';
4516     xml-encoding: null;
4517     xml-standalone: false;
4518     element { }
4519     }
4520     @@XMLTest:
4521     @@@QName: xp.xmldecl.version.1.1.test
4522     @@@DEnt:
4523     @@@@test:value:
4524     <?xml version="1.1"?>
4525     <p></p>
4526     @@@test:domTree:
4527     document {
4528     xml-version: '1.1';
4529     xml-encoding: null;
4530     xml-standalone: false;
4531     element { }
4532     }
4533    
4534     @@XMLTest:
4535     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.test
4536     @@@DEnt:
4537     @@@@test:value:
4538     <?xml version="1.0" encoding="US-ascii"?>
4539     <p></p>
4540     @@@test:domTree:
4541     document {
4542     xml-version: '1.0';
4543     xml-encoding: 'US-ascii';
4544     xml-standalone: false;
4545     element { }
4546     }
4547     @@XMLTest:
4548     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.lita.test
4549     @@@DEnt:
4550     @@@@test:value:
4551     <?xml version="1.0" encoding='US-ascii'?>
4552     <p></p>
4553     @@@test:domTree:
4554     document {
4555     xml-version: '1.0';
4556     xml-encoding: 'US-ascii';
4557     xml-standalone: false;
4558     element { }
4559     }
4560     @@XMLTest:
4561     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.s.test
4562     @@@DEnt:
4563     @@@@test:value:
4564     <?xml version="1.0" encoding = "US-ascii" ?>
4565     <p></p>
4566     @@@test:domTree:
4567     document {
4568     xml-version: '1.0';
4569     xml-encoding: 'US-ascii';
4570     xml-standalone: false;
4571     element { }
4572     }
4573    
4574     @@XMLTest:
4575     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.yes.test
4576     @@@DEnt:
4577     @@@@test:value:
4578     <?xml version="1.0" encoding="us-ascii" standalone="yes"?>
4579     <p></p>
4580     @@@test:domTree:
4581     document {
4582     xml-version: '1.0';
4583     xml-encoding: 'us-ascii';
4584     xml-standalone: true;
4585     element { }
4586     }
4587     @@XMLTest:
4588     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.no.test
4589     @@@DEnt:
4590     @@@@test:value:
4591     <?xml version="1.0" encoding="us-ascii" standalone="no"?>
4592     <p></p>
4593     @@@test:domTree:
4594     document {
4595     xml-version: '1.0';
4596     xml-encoding: 'us-ascii';
4597     xml-standalone: false;
4598     element { }
4599     }
4600     @@XMLTest:
4601     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.yes.lita.test
4602     @@@DEnt:
4603     @@@@test:value:
4604     <?xml version="1.0" encoding="us-ascii" standalone='yes'?>
4605     <p></p>
4606     @@@test:domTree:
4607     document {
4608     xml-version: '1.0';
4609     xml-encoding: 'us-ascii';
4610     xml-standalone: true;
4611     element { }
4612     }
4613     @@XMLTest:
4614     @@@QName: xp.xmldecl.version.1.0.encoding.usascii.standalone.yes.s.test
4615     @@@DEnt:
4616     @@@@test:value:
4617     <?xml version="1.0" encoding="us-ascii" standalone = "yes" ?>
4618     <p></p>
4619     @@@test:domTree:
4620     document {
4621     xml-version: '1.0';
4622     xml-encoding: 'us-ascii';
4623     xml-standalone: true;
4624     element { }
4625     }
4626 wakaba 1.14 @@XMLTest:
4627     @@@QName: xp.xmldecl.no.encoding.but.standalone.attr.test
4628     @@@DEnt:
4629     @@@@test:value:
4630     <?xml version="1.0" standalone="yes"?>
4631     <p></p>
4632     @@@test:domTree:
4633     document {
4634     xml-version: '1.0';
4635     xml-encoding: null;
4636     xml-standalone: true;
4637     element { }
4638     }
4639     @@XMLTest:
4640     @@@QName: xp.xmldecl.encoding.encname.test
4641     @@@DEnt:
4642     @@@@test:value:
4643     <?xml version="1.0" encoding="a-._01-"?>
4644     <p></p>
4645     @@@test:domTree:
4646     document {
4647     xml-version: '1.0';
4648     xml-encoding: 'a-._01-';
4649     xml-standalone: false;
4650     element { }
4651     }
4652    
4653     @@XMLTest:
4654     @@@QName: xp.xmldecl.no.s.no.attr.test
4655     @@@DEnt:
4656     @@@@test:value:
4657     <?xml?>
4658     <p></p>
4659     @@@c:erred:
4660 wakaba 1.16 <[[xp:wf-syntax-error]]> { (1, 1)..(1, 7); }
4661 wakaba 1.14 @@XMLTest:
4662     @@@QName: xp.xmldecl.s.no.attr.test
4663     @@@DEnt:
4664     @@@@test:value:
4665     <?xml ?>
4666     <p></p>
4667     @@@c:erred:
4668     <[[xp:wf-syntax-error]]> { (1, 8)..(1, 9); }
4669     @@XMLTest:
4670     @@@QName: xp.xmldecl.unknown.attr.test
4671     @@@DEnt:
4672     @@@@test:value:
4673     <?xml unknown="value"?>
4674     <p></p>
4675     @@@c:erred:
4676     <[[xp:wf-syntax-error]]> { (1, 8)..(1, 22); }
4677     @@XMLTest:
4678     @@@QName: xp.xmldecl.version.unknown.attr.test
4679     @@@DEnt:
4680     @@@@test:value:
4681     <?xml version="1.0" unknown="value"?>
4682     <p></p>
4683     @@@c:erred:
4684     <[[xp:wf-syntax-error]]> { (1, 21)..(1, 35); }
4685     @@XMLTest:
4686     @@@QName: xp.xmldecl.version.encoding.unknown.attr.test
4687     @@@DEnt:
4688     @@@@test:value:
4689     <?xml version="1.0" encoding="us-ascii" unknown="value"?>
4690     <p></p>
4691     @@@c:erred:
4692     <[[xp:wf-syntax-error]]> { (1, 41)..(1, 55); }
4693     @@XMLTest:
4694     @@@QName: xp.xmldecl.version.encoding.standalone.unknown.attr.test
4695     @@@DEnt:
4696     @@@@test:value:
4697     <?xml version="1.0" encoding="us-ascii" standalone="yes"
4698     unknown="value"?>
4699     <p></p>
4700     @@@c:erred:
4701     <[[xp:wf-syntax-error]]> { (2, 1)..(2, 15); }
4702     @@XMLTest:
4703     @@@QName: xp.xmldecl.no.version.but.encoding.attr.test
4704     @@@DEnt:
4705     @@@@test:value:
4706     <?xml encoding="us-ascii"?>
4707     <p></p>
4708     @@@c:erred:
4709     <[[xp:wf-syntax-error]]> { (1, 7)..(1, 25); }
4710     @@XMLTest:
4711     @@@QName: xp.xmldecl.no.version.but.standalone.attr.test
4712     @@@DEnt:
4713     @@@@test:value:
4714     <?xml standalone="yes"?>
4715     <p></p>
4716     @@@c:erred:
4717     <[[xp:wf-syntax-error]]> { (1, 7)..(1, 24); }
4718     @@XMLTest:
4719     @@@QName: xp.xmldecl.version.unsupported.test
4720     @@@DEnt:
4721     @@@@test:value:
4722     <?xml version="1.2"?>
4723     <p></p>
4724     @@@c:erred:
4725     <[[xp:wf-unsupported-xml-version]]> { (1, 7)..(1, 19); }
4726     @@XMLTest:
4727     @@@QName: xp.xmldecl.version.unsupported.2.test
4728     @@@DEnt:
4729     @@@@test:value:
4730     <?xml version=" 1.0 "?>
4731     <p></p>
4732     @@@c:erred:
4733     <[[xp:wf-unsupported-xml-version]]> { (1, 7)..(1, 21); }
4734     @@XMLTest:
4735     @@@QName: xp.xmldecl.version.unsupported.3.test
4736     @@@DEnt:
4737     @@@@test:value:
4738     <?xml version="01.00"?>
4739     <p></p>
4740     @@@c:erred:
4741     <[[xp:wf-unsupported-xml-version]]> { (1, 7)..(1, 21); }
4742     @@XMLTest:
4743     @@@QName: xp.xmldecl.encoding.malformed.1.test
4744     @@@DEnt:
4745     @@@@test:value:
4746     <?xml version="1.0" encoding="0088"?>
4747     <p></p>
4748     @@@c:erred:
4749     <[[xp:wf-malformed-enc-name]]> { (1, 21)..(1, 35); }
4750     @@XMLTest:
4751     @@@QName: xp.xmldecl.encoding.malformed.2.test
4752     @@@DEnt:
4753     @@@@test:value:
4754     <?xml version="1.0" encoding="D.V.D!"?>
4755     <p></p>
4756     @@@c:erred:
4757     <[[xp:wf-malformed-enc-name]]> { (1, 21)..(1, 38); }
4758     @@XMLTest:
4759     @@@QName: xp.xmldecl.standalone.malformed.1.test
4760     @@@DEnt:
4761     @@@@test:value:
4762     <?xml version="1.0" standalone="true"?>
4763     <p></p>
4764     @@@c:erred:
4765     <[[xp:wf-malformed-xml-standalone]]> { (1, 21)..(1, 38); }
4766     @@XMLTest:
4767     @@@QName: xp.xmldecl.standalone.malformed.2.test
4768     @@@DEnt:
4769     @@@@test:value:
4770     <?xml version="1.0" standalone="YES"?>
4771     <p></p>
4772     @@@c:erred:
4773     <[[xp:wf-malformed-xml-standalone]]> { (1, 21)..(1, 37); }
4774     @@XMLTest:
4775     @@@QName: xp.xmldecl.standalone.malformed.3.test
4776     @@@DEnt:
4777     @@@@test:value:
4778     <?xml version="1.0" standalone="no "?>
4779     <p></p>
4780     @@@c:erred:
4781     <[[xp:wf-malformed-xml-standalone]]> { (1, 21)..(1, 38); }
4782 wakaba 1.6
4783     @@XMLTest:
4784 wakaba 1.14 @@@QName: xp.no-xmldecl.xml...-pi.test
4785     @@@DEnt:
4786     @@@@test:value:
4787     <?xmldeclaration?>
4788     <a></a>
4789     @@@test:domTree:
4790     document {
4791     pi {
4792     node-name: 'xmldeclaration';
4793     node-value: '';
4794     }
4795     element { }
4796     }
4797     @@XMLTest:
4798     @@@QName: xp.no-xmldecl.xml...-pi.after.document.element.test
4799     @@@DEnt:
4800     @@@@test:value:
4801     <a></a>
4802     <?xmldeclaration?>
4803     @@@test:domTree:
4804     document {
4805     element { }
4806     pi {
4807     node-name: 'xmldeclaration';
4808     node-value: '';
4809     }
4810     }
4811     @@XMLTest:
4812     @@@QName: xp.no-xmldecl.xml...-pi.in.document.element.test
4813     @@@DEnt:
4814     @@@@test:value:
4815     <a>
4816     <?xmldeclaration?>
4817     </a>
4818     @@@test:domTree:
4819     document {
4820     element {
4821     text { }
4822     pi {
4823     node-name: 'xmldeclaration';
4824     node-value: '';
4825     }
4826     text { }
4827     }
4828     }
4829     @@XMLTest:
4830     @@@QName: xp.no-xmldecl.xml...-pi.in.doctype.test
4831     @@@DEnt:
4832     @@@@test:value:
4833     <!DOCTYPE a [
4834     <?xmldeclaration?>
4835     ]>
4836     <a></a>
4837     @@@test:domTree:
4838     document {
4839     document-type {
4840     pi {
4841     node-name: 'xmldeclaration';
4842     node-value: '';
4843     }
4844     }
4845     element { }
4846     }
4847    
4848     @@XMLTest:
4849     @@@QName: xp.XMLdecl.test
4850     @@@DEnt:
4851     @@@@test:value:
4852     <?XML version="1.0"?>
4853     <p></p>
4854     @@@c:erred:
4855     <[[xp:wf-pi-target-is-xml]]> { (1, 1)..(1, 5); }
4856     @@XMLTest:
4857     @@@QName: xp.Xmldecl.test
4858     @@@DEnt:
4859     @@@@test:value:
4860     <?Xml version="1.0"?>
4861     <p></p>
4862     @@@c:erred:
4863     <[[xp:wf-pi-target-is-xml]]> { (1, 1)..(1, 5); }
4864     @@XMLTest:
4865     @@@QName: xp.xmldecl.after.document.element.empty.test
4866     @@@DEnt:
4867     @@@@test:value:
4868     <p></p>
4869     <?xml?>
4870     @@@c:erred:
4871     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4872     @@XMLTest:
4873     @@@QName: xp.xmldecl.after.document.element.test
4874     @@@DEnt:
4875     @@@@test:value:
4876     <p></p>
4877     <?xml version="1.0"?>
4878     @@@c:erred:
4879     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4880     @@XMLTest:
4881     @@@QName: xp.xmldecl.in.element.empty.test
4882     @@@DEnt:
4883     @@@@test:value:
4884     <p>
4885     <?xml?>
4886     </p>
4887     @@@c:erred:
4888     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4889     @@XMLTest:
4890     @@@QName: xp.xmldecl.in.element.test
4891     @@@DEnt:
4892     @@@@test:value:
4893     <p>
4894     <?xml version="1.0"?>
4895     </p>
4896     @@@c:erred:
4897     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4898     @@XMLTest:
4899     @@@QName: xp.xmldecl.after.comment.test
4900     @@@DEnt:
4901     @@@@test:value:
4902     <!---->
4903     <?xml version="1.0"?>
4904     <p></p>
4905     @@@c:erred:
4906     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4907     @@XMLTest:
4908     @@@QName: xp.xmldecl.after.comment.empty.test
4909     @@@DEnt:
4910     @@@@test:value:
4911     <!---->
4912     <?xml?>
4913     <p></p>
4914     @@@c:erred:
4915     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4916     @@XMLTest:
4917     @@@QName: xp.xmldecl.after.pi.test
4918     @@@DEnt:
4919     @@@@test:value:
4920     <?xml-declaration?>
4921     <?xml version="1.0"?>
4922     <p></p>
4923     @@@c:erred:
4924     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4925     @@XMLTest:
4926     @@@QName: xp.xmldecl.after.pi.empty.test
4927     @@@DEnt:
4928     @@@@test:value:
4929     <?xml-declaration?>
4930     <?xml?>
4931     <p></p>
4932     @@@c:erred:
4933     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4934     @@XMLTest:
4935 wakaba 1.16 @@@QName: xp.xmldecl.after.pi.2.test
4936     @@@DEnt:
4937     @@@@test:value:
4938     <?declaration?>
4939     <?xml version="1.0"?>
4940     <p></p>
4941     @@@c:erred:
4942     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4943     @@XMLTest:
4944     @@@QName: xp.xmldecl.after.pi.empty.2.test
4945     @@@DEnt:
4946     @@@@test:value:
4947     <?declaration?>
4948     <?xml?>
4949     <p></p>
4950     @@@c:erred:
4951     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4952     @@XMLTest:
4953 wakaba 1.14 @@@QName: xp.xmldecl.after.doctype.test
4954     @@@DEnt:
4955     @@@@test:value:
4956     <!DOCTYPE a>
4957     <?xml version="1.0"?>
4958     <p></p>
4959     @@@c:erred:
4960     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4961     @@XMLTest:
4962     @@@QName: xp.xmldecl.after.doctype.empty.test
4963     @@@DEnt:
4964     @@@@test:value:
4965     <!DOCTYPE a>
4966     <?xml?>
4967     <p></p>
4968     @@@c:erred:
4969     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4970     @@XMLTest:
4971     @@@QName: xp.xmldecl.in.doctype.test
4972     @@@DEnt:
4973     @@@@test:value:
4974     <!DOCTYPE a [
4975     <?xml version="1.0"?>
4976     ]>
4977     <p></p>
4978     @@@c:erred:
4979     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4980     @@XMLTest:
4981     @@@QName: xp.xmldecl.in.doctype.empty.test
4982     @@@DEnt:
4983     @@@@test:value:
4984     <!DOCTYPE a [
4985     <?xml?>
4986     ]>
4987     <p></p>
4988     @@@c:erred:
4989     <[[xp:wf-pi-target-is-xml]]> { (2, 1)..(2, 5); }
4990    
4991     @@XMLTest:
4992     @@@QName: xp.pi.before.element.empty.test
4993     @@@DEnt:
4994     @@@@test:value:
4995     <?target?>
4996     <a></a>
4997     @@@test:domTree:
4998     document {
4999     pi {
5000     node-name: 'target';
5001     node-value: '';
5002     }
5003     element { }
5004     }
5005     @@XMLTest:
5006     @@@QName: xp.pi.before.element.s.test
5007     @@@DEnt:
5008     @@@@test:value:
5009     <?target ?>
5010     <a></a>
5011     @@@test:domTree:
5012     document {
5013     pi {
5014     node-name: 'target';
5015     node-value: '';
5016     }
5017     element { }
5018     }
5019     @@XMLTest:
5020     @@@QName: xp.pi.before.element.string.test
5021     @@@DEnt:
5022     @@@@test:value:
5023     <?target string?>
5024     <a></a>
5025     @@@test:domTree:
5026     document {
5027     pi {
5028     node-name: 'target';
5029     node-value: 'string';
5030     }
5031     element { }
5032     }
5033     @@XMLTest:
5034     @@@QName: xp.pi.before.element.string.s.test
5035     @@@DEnt:
5036     @@@@test:value:
5037     <?target string ?>
5038     <a></a>
5039     @@@test:domTree:
5040     document {
5041     pi {
5042     node-name: 'target';
5043     node-value: 'string ';
5044     }
5045     element { }
5046     }
5047     @@XMLTest:
5048     @@@QName: xp.pi.before.element.gt.test
5049     @@@DEnt:
5050     @@@@test:value:
5051     <?target string>string?>
5052     <a></a>
5053     @@@test:domTree:
5054     document {
5055     pi {
5056     node-name: 'target';
5057     node-value: 'string>string';
5058     }
5059     element { }
5060     }
5061     @@XMLTest:
5062     @@@QName: xp.pi.doctype.empty.test
5063     @@@DEnt:
5064     @@@@test:value:
5065     <!DOCTYPE a [
5066     <?target?>
5067     ]>
5068     <a></a>
5069     @@@test:domTree:
5070     document {
5071     document-type {
5072     pi {
5073     node-name: 'target';
5074     node-value: '';
5075     }
5076     }
5077     element { }
5078     }
5079    
5080     @@XMLTest:
5081     @@@QName: xp.pi.no.target.test
5082     @@@DEnt:
5083     @@@@test:value:
5084     <??>
5085     <p></p>
5086     @@@c:erred:
5087     <[[xp:wf-syntax-error]]> { (1, 3)..(1, 4); }
5088     @@XMLTest:
5089     @@@QName: xp.pi.no.target.2.test
5090     @@@DEnt:
5091     @@@@test:value:
5092     <? ?>
5093     <p></p>
5094     @@@c:erred:
5095     <[[xp:wf-syntax-error]]> { (1, 3)..(1, 4); }
5096     @@XMLTest:
5097     @@@QName: xp.pi.bad.target.1.test
5098     @@@DEnt:
5099     @@@@test:value:
5100     <?target! ?>
5101     <p></p>
5102     @@@c:erred:
5103     <[[xp:wf-syntax-error]]> { (1, 9)..(1, 9); }
5104     @@XMLTest:
5105     @@@QName: xp.pi.bad.target.2.test
5106     @@@DEnt:
5107     @@@@test:value:
5108     <?0target ?>
5109     <p></p>
5110     @@@c:erred:
5111     <[[xp:wf-syntax-error]]> { (1, 3)..(1, 3); }
5112    
5113     @@XMLTest:
5114 wakaba 1.15 @@@QName: xp.cdatasection.empty.1.test
5115     @@@DEnt:
5116     @@@@test:value:
5117     <p><![CDATA[]]></p>
5118     @@@test:domTree:
5119     document {
5120     element {
5121     cdata-section {
5122     data: '';
5123     }
5124     }
5125     }
5126     @@XMLTest:
5127     @@@QName: xp.cdatasection.empty.2.test
5128     @@@DEnt:
5129     @@@@test:value:
5130     <p>aa<![CDATA[]]>bb</p>
5131     @@@test:domTree:
5132     document {
5133     element {
5134     text { data: 'aa'; }
5135     cdata-section {
5136     data: '';
5137     }
5138     text { data: 'bb'; }
5139     }
5140     }
5141     @@XMLTest:
5142     @@@QName: xp.cdatasection.1.test
5143     @@@DEnt:
5144     @@@@test:value:
5145     <p><![CDATA[abcdefg]]></p>
5146     @@@test:domTree:
5147     document {
5148     element {
5149     cdata-section {
5150     data: 'abcdefg';
5151     }
5152     }
5153     }
5154     @@XMLTest:
5155     @@@QName: xp.cdatasection.2.test
5156     @@@DEnt:
5157     @@@@test:value:
5158     <p>aa<![CDATA[abcdefg]]>bb</p>
5159     @@@test:domTree:
5160     document {
5161     element {
5162     text { data: 'aa'; }
5163     cdata-section {
5164     data: 'abcdefg';
5165     }
5166     text { data: 'bb'; }
5167     }
5168     }
5169     @@XMLTest:
5170     @@@QName: xp.cdatasection.ref.1.test
5171     @@@DEnt:
5172     @@@@test:value:
5173     <p><![CDATA[a&amp;&#x32;&#32;%abc;&def;]]&gt;b]]></p>
5174     @@@test:domTree:
5175     document {
5176     element {
5177     cdata-section {
5178     data: 'a&amp;&#x32;&#32;%abc;&def;]]&gt;b';
5179     }
5180     }
5181     }
5182     @@XMLTest:
5183     @@@QName: xp.cdatasection.in.general.entity.test
5184     @@@DEnt:
5185     @@@@test:value:
5186     <!DOCTYPE p [
5187     <!ENTITY cdata "<![CDATA[text]]>">
5188     ]>
5189     <p>&cdata;</p>
5190     @@@test:domTree:
5191     document {
5192     document-type {
5193     general-entity {
5194     node-name: 'cdata';
5195     cdata-section {
5196     data: 'text';
5197     }
5198     }
5199     }
5200     element {
5201     general-entity-reference {
5202     cdata-section {
5203     data: 'text';
5204     }
5205     }
5206     }
5207     }
5208     @@XMLTest:
5209     @@@QName: xp.cdatasection.no.mse.test
5210     @@@DEnt:
5211     @@@@test:value:
5212     <p><![CDATA[text</p>
5213     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 21); }
5214     @@XMLTest:
5215     @@@QName: xp.cdatasection.nest.test
5216     @@@DEnt:
5217     @@@@test:value:
5218     <p><![CDATA[text01<![CDATA[txt2]]>text3]]></p>
5219     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 40)..(1, 42); }
5220    
5221     @@XMLTest:
5222 wakaba 1.6 @@@QName: xp.doctype.empty.test
5223     @@@DEnt:
5224     @@@@test:value:
5225     <!DOCTYPE a>
5226     <a></a>
5227     @@@test:domTree:
5228     document {
5229     xml-version: '1.0';
5230     xml-encoding: null;
5231     xml-standalone: false;
5232     document-type {
5233     node-name: 'a';
5234 wakaba 1.17 public-id: null;
5235     system-id: null;
5236 wakaba 1.6 }
5237     element {
5238     namespace-uri: null;
5239     prefix: null;
5240     local-name: 'a';
5241     text-content: '';
5242     }
5243     }
5244 wakaba 1.15 @@XMLTest:
5245     @@@QName: xp.doctype.empty.after.document.element.test
5246     @@@DEnt:
5247     @@@@test:value:
5248     <a></a>
5249     <!DOCTYPE a>
5250     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5251     @@XMLTest:
5252     @@@QName: xp.doctype.empty.in.element.test
5253     @@@DEnt:
5254     @@@@test:value:
5255     <a>
5256     <!DOCTYPE a>
5257     </a>
5258     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5259     @@XMLTest:
5260     @@@QName: xp.doctype.empty.dup.test
5261     @@@DEnt:
5262     @@@@test:value:
5263     <!DOCTYPE a>
5264     <!DOCTYPE a>
5265     <a></a>
5266     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5267     @@XMLTest:
5268     @@@QName: xp.doctype.empty.in.intsubset.test
5269     @@@DEnt:
5270     @@@@test:value:
5271     <!DOCTYPE a [
5272     <!DOCTYPE a>
5273     ]>
5274     <a></a>
5275     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1)..(2, 12); }
5276 wakaba 1.16 @@XMLTest:
5277     @@@QName: xp.doctype.no.s.no.name.test
5278     @@@DEnt:
5279     @@@@test:value:
5280     <!DOCTYPE>
5281     <a></a>
5282     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 10); }
5283     @@XMLTest:
5284     @@@QName: xp.doctype.no.name.test
5285     @@@DEnt:
5286     @@@@test:value:
5287     <!DOCTYPE >
5288     <a></a>
5289     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 11); }
5290     @@XMLTest:
5291     @@@QName: xp.doctype.name.s.test
5292     @@@DEnt:
5293     @@@@test:value:
5294     <!DOCTYPE aa >
5295     <aa></aa>
5296     @@@test:domTree:
5297     document {
5298     document-type {
5299     node-name: 'aa';
5300 wakaba 1.17 public-id: null;
5301     system-id: null;
5302 wakaba 1.16 }
5303     element { }
5304     }
5305     @@XMLTest:
5306     @@@QName: xp.doctype.no.mdc.test
5307     @@@DEnt:
5308     @@@@test:value:
5309     <!DOCTYPE aa
5310     <aa></aa>
5311     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1); }
5312 wakaba 1.6
5313     @@XMLTest:
5314 wakaba 1.16 @@@QName: xp.doctype.intsubset.empty.1.test
5315 wakaba 1.6 @@@DEnt:
5316     @@@@test:value:
5317 wakaba 1.16 <!DOCTYPE a []>
5318 wakaba 1.6 <a></a>
5319     @@@test:domTree:
5320     document {
5321     xml-version: '1.0';
5322     xml-encoding: null;
5323     xml-standalone: false;
5324     document-type {
5325     node-name: 'a';
5326 wakaba 1.17 public-id: null;
5327     system-id: null;
5328 wakaba 1.6 }
5329     element {
5330     namespace-uri: null;
5331     prefix: null;
5332     local-name: 'a';
5333     text-content: '';
5334     }
5335     }
5336     @@XMLTest:
5337 wakaba 1.16 @@@QName: xp.doctype.intsubset.empty.2.test
5338 wakaba 1.6 @@@DEnt:
5339     @@@@test:value:
5340     <!DOCTYPE a [
5341 wakaba 1.16
5342 wakaba 1.6 ]>
5343     <a></a>
5344     @@@test:domTree:
5345     document {
5346     xml-version: '1.0';
5347     xml-encoding: null;
5348     xml-standalone: false;
5349     document-type {
5350     node-name: 'a';
5351 wakaba 1.17 public-id: null;
5352     system-id: null;
5353 wakaba 1.6 }
5354     element {
5355     namespace-uri: null;
5356     prefix: null;
5357     local-name: 'a';
5358     text-content: '';
5359     }
5360     }
5361     @@XMLTest:
5362 wakaba 1.16 @@@QName: xp.doctype.intsubset.empty.3.test
5363 wakaba 1.6 @@@DEnt:
5364     @@@@test:value:
5365 wakaba 1.16 <!DOCTYPE a[]>
5366 wakaba 1.6 <a></a>
5367     @@@test:domTree:
5368     document {
5369     document-type {
5370     node-name: 'a';
5371 wakaba 1.17 public-id: null;
5372     system-id: null;
5373 wakaba 1.6 }
5374 wakaba 1.16 element { }
5375     }
5376     @@XMLTest:
5377     @@@QName: xp.doctype.intsubset.empty.4.test
5378     @@@DEnt:
5379     @@@@test:value:
5380     <!DOCTYPE a[] >
5381     <a></a>
5382     @@@test:domTree:
5383     document {
5384     document-type {
5385     node-name: 'a';
5386 wakaba 1.17 public-id: null;
5387     system-id: null;
5388 wakaba 1.6 }
5389 wakaba 1.16 element { }
5390 wakaba 1.6 }
5391     @@XMLTest:
5392 wakaba 1.16 @@@QName: xp.doctype.intsubset.no.dsc.1.test
5393     @@@DEnt:
5394     @@@@test:value:
5395     <!DOCTYPE a [>
5396     <a></a>
5397     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 14); }
5398     @@XMLTest:
5399     @@@QName: xp.doctype.intsubset.no.dsc.2.test
5400 wakaba 1.6 @@@DEnt:
5401     @@@@test:value:
5402     <!DOCTYPE a [
5403     <a></a>
5404 wakaba 1.16 @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1); }
5405     @@XMLTest:
5406     @@@QName: xp.doctype.intsubset.no.dsc.3.test
5407     @@@DEnt:
5408     @@@@test:value:
5409     <!DOCTYPE a [
5410     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 14); }
5411     @@XMLTest:
5412     @@@QName: xp.doctype.intsubset.no.mdc.1.test
5413     @@@DEnt:
5414     @@@@test:value:
5415     <!DOCTYPE a []
5416     <a/>
5417     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 1); }
5418     @@XMLTest:
5419     @@@QName: xp.doctype.intsubset.no.mdc.2.test
5420     @@@DEnt:
5421     @@@@test:value:
5422     <!DOCTYPE a []]>
5423     <a/>
5424     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 15); }
5425 wakaba 1.17 @@XMLTest:
5426     @@@QName: xp.doctype.pubid.sysid.1.test
5427     @@@DEnt:
5428     @@@@test:value:
5429     <!DOCTYPE a PUBLIC "pubid" "sysid">
5430     <a/>
5431     @@@test:domTree:
5432     document {
5433     document-type {
5434     node-name: 'a';
5435     public-id: 'pubid';
5436     system-id: 'sysid';
5437     }
5438     element { }
5439     }
5440     @@XMLTest:
5441     @@@QName: xp.doctype.pubid.sysid.2.test
5442     @@@DEnt:
5443     @@@@test:value:
5444     <!DOCTYPE a PUBLIC 'pubid' "sysid">
5445     <a/>
5446     @@@test:domTree:
5447     document {
5448     document-type {
5449     node-name: 'a';
5450     public-id: 'pubid';
5451     system-id: 'sysid';
5452     }
5453     element { }
5454     }
5455     @@XMLTest:
5456     @@@QName: xp.doctype.pubid.sysid.3.test
5457     @@@DEnt:
5458     @@@@test:value:
5459     <!DOCTYPE a PUBLIC "pubid" 'sysid'>
5460     <a/>
5461     @@@test:domTree:
5462     document {
5463     document-type {
5464     node-name: 'a';
5465     public-id: 'pubid';
5466     system-id: 'sysid';
5467     }
5468     element { }
5469     }
5470     @@XMLTest:
5471     @@@QName: xp.doctype.pubid.sysid.4.test
5472     @@@DEnt:
5473     @@@@test:value:
5474     <!DOCTYPE a PUBLIC 'pubid' 'sysid'>
5475     <a/>
5476     @@@test:domTree:
5477     document {
5478     document-type {
5479     node-name: 'a';
5480     public-id: 'pubid';
5481     system-id: 'sysid';
5482     }
5483     element { }
5484     }
5485     @@XMLTest:
5486     @@@QName: xp.doctype.pubid.sysid.5.test
5487     @@@DEnt:
5488     @@@@test:value:
5489     <!DOCTYPE a PUBLIC "pubid" "sysid" >
5490     <a/>
5491     @@@test:domTree:
5492     document {
5493     document-type {
5494     node-name: 'a';
5495     public-id: 'pubid';
5496     system-id: 'sysid';
5497     }
5498     element { }
5499     }
5500     @@XMLTest:
5501     @@@QName: xp.doctype.pubid.sysid.6.test
5502     @@@DEnt:
5503     @@@@test:value:
5504     <!DOCTYPE a PUBLIC 'pubid' 'sysid' >
5505     <a/>
5506     @@@test:domTree:
5507     document {
5508     document-type {
5509     node-name: 'a';
5510     public-id: 'pubid';
5511     system-id: 'sysid';
5512     }
5513     element { }
5514     }
5515     @@XMLTest:
5516     @@@QName: xp.doctype.pubid.sysid.intsubset.1.test
5517     @@@DEnt:
5518     @@@@test:value:
5519     <!DOCTYPE a PUBLIC "pubid" "sysid"[]>
5520     <a/>
5521     @@@test:domTree:
5522     document {
5523     document-type {
5524     node-name: 'a';
5525     public-id: 'pubid';
5526     system-id: 'sysid';
5527     }
5528     element { }
5529     }
5530     @@XMLTest:
5531     @@@QName: xp.doctype.pubid.sysid.intsubset.2.test
5532     @@@DEnt:
5533     @@@@test:value:
5534     <!DOCTYPE a PUBLIC "pubid" "sysid" []>
5535     <a/>
5536     @@@test:domTree:
5537     document {
5538     document-type {
5539     node-name: 'a';
5540     public-id: 'pubid';
5541     system-id: 'sysid';
5542     }
5543     element { }
5544     }
5545     @@XMLTest:
5546     @@@QName: xp.doctype.pubid.sysid.intsubset.3.test
5547     @@@DEnt:
5548     @@@@test:value:
5549     <!DOCTYPE a PUBLIC 'pubid' 'sysid'[]>
5550     <a/>
5551     @@@test:domTree:
5552     document {
5553     document-type {
5554     node-name: 'a';
5555     public-id: 'pubid';
5556     system-id: 'sysid';
5557     }
5558     element { }
5559     }
5560     @@XMLTest:
5561     @@@QName: xp.doctype.pubid.sysid.intsubset.4.test
5562     @@@DEnt:
5563     @@@@test:value:
5564     <!DOCTYPE a PUBLIC 'pubid' 'sysid' []>
5565     <a/>
5566     @@@test:domTree:
5567     document {
5568     document-type {
5569     node-name: 'a';
5570     public-id: 'pubid';
5571     system-id: 'sysid';
5572     }
5573     element { }
5574     }
5575     @@XMLTest:
5576     @@@QName: xp.doctype.sysid.1.test
5577     @@@DEnt:
5578     @@@@test:value:
5579     <!DOCTYPE a SYSTEM "sysid">
5580     <a/>
5581     @@@test:domTree:
5582     document {
5583     document-type {
5584     node-name: 'a';
5585     public-id: null;
5586     system-id: 'sysid';
5587     }
5588     element { }
5589     }
5590     @@XMLTest:
5591     @@@QName: xp.doctype.sysid.2.test
5592     @@@DEnt:
5593     @@@@test:value:
5594     <!DOCTYPE a SYSTEM 'sysid'>
5595     <a/>
5596     @@@test:domTree:
5597     document {
5598     document-type {
5599     node-name: 'a';
5600     public-id: null;
5601     system-id: 'sysid';
5602     }
5603     element { }
5604     }
5605     @@XMLTest:
5606     @@@QName: xp.doctype.sysid.3.test
5607     @@@DEnt:
5608     @@@@test:value:
5609     <!DOCTYPE a SYSTEM "sysid" >
5610     <a/>
5611     @@@test:domTree:
5612     document {
5613     document-type {
5614     node-name: 'a';
5615     public-id: null;
5616     system-id: 'sysid';
5617     }
5618     element { }
5619     }
5620     @@XMLTest:
5621     @@@QName: xp.doctype.sysid.4.test
5622     @@@DEnt:
5623     @@@@test:value:
5624     <!DOCTYPE a SYSTEM 'sysid' >
5625     <a/>
5626     @@@test:domTree:
5627     document {
5628     document-type {
5629     node-name: 'a';
5630     public-id: null;
5631     system-id: 'sysid';
5632     }
5633     element { }
5634     }
5635     @@XMLTest:
5636     @@@QName: xp.doctype.sysid.intsubset.1.test
5637     @@@DEnt:
5638     @@@@test:value:
5639     <!DOCTYPE a SYSTEM "sysid"[]>
5640     <a/>
5641     @@@test:domTree:
5642     document {
5643     document-type {
5644     node-name: 'a';
5645     public-id: null;
5646     system-id: 'sysid';
5647     }
5648     element { }
5649     }
5650     @@XMLTest:
5651     @@@QName: xp.doctype.sysid.intsubset.2.test
5652     @@@DEnt:
5653     @@@@test:value:
5654     <!DOCTYPE a SYSTEM "sysid" []>
5655     <a/>
5656     @@@test:domTree:
5657     document {
5658     document-type {
5659     node-name: 'a';
5660     public-id: null;
5661     system-id: 'sysid';
5662     }
5663     element { }
5664     }
5665     @@XMLTest:
5666     @@@QName: xp.doctype.sysid.intsubset.3.test
5667     @@@DEnt:
5668     @@@@test:value:
5669     <!DOCTYPE a SYSTEM 'sysid'[]>
5670     <a/>
5671     @@@test:domTree:
5672     document {
5673     document-type {
5674     node-name: 'a';
5675     public-id: null;
5676     system-id: 'sysid';
5677     }
5678     element { }
5679     }
5680     @@XMLTest:
5681     @@@QName: xp.doctype.sysid.intsubset.4.test
5682     @@@DEnt:
5683     @@@@test:value:
5684     <!DOCTYPE a SYSTEM 'sysid' []>
5685     <a/>
5686     @@@test:domTree:
5687     document {
5688     document-type {
5689     node-name: 'a';
5690     public-id: null;
5691     system-id: 'sysid';
5692     }
5693     element { }
5694     }
5695     @@XMLTest:
5696     @@@QName: xp.doctype.public.stago.test
5697     @@@DEnt:
5698     @@@@test:value:
5699     <!DOCTYPE a PUBLIC<a/>
5700     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 19); }
5701     @@XMLTest:
5702     @@@QName: xp.doctype.public.mdc.test
5703     @@@DEnt:
5704     @@@@test:value:
5705     <!DOCTYPE a PUBLIC>
5706     <a/>
5707     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 19); }
5708     @@XMLTest:
5709     @@@QName: xp.doctype.public.s.stago.test
5710     @@@DEnt:
5711     @@@@test:value:
5712     <!DOCTYPE a PUBLIC <a/>
5713     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 20); }
5714     @@XMLTest:
5715     @@@QName: xp.doctype.public.s.mdc.test
5716     @@@DEnt:
5717     @@@@test:value:
5718     <!DOCTYPE a PUBLIC >
5719     <a/>
5720     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 20); }
5721     @@XMLTest:
5722     @@@QName: xp.doctype.public.lit.test
5723     @@@DEnt:
5724     @@@@test:value:
5725     <!DOCTYPE a PUBLIC"p" "s">
5726     <a/>
5727     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 19); }
5728     @@XMLTest:
5729     @@@QName: xp.doctype.public.lita.test
5730     @@@DEnt:
5731     @@@@test:value:
5732     <!DOCTYPE a PUBLIC'p' "s">
5733     <a/>
5734     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 19); }
5735     @@XMLTest:
5736     @@@QName: xp.doctype.pubid.lit.lita.unmatched.1.test
5737     @@@DEnt:
5738     @@@@test:value:
5739     <!DOCTYPE a PUBLIC "p' "s">
5740     <a/>
5741     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 25); }
5742     @@XMLTest:
5743     @@@QName: xp.doctype.pubid.lit.lita.unmatched.2.test
5744     @@@DEnt:
5745     @@@@test:value:
5746     <!DOCTYPE a PUBLIC "p' 's'><a/>
5747     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 32); }
5748     @@XMLTest:
5749     @@@QName: xp.doctype.pubid.lita.lit.unmatched.1.test
5750     @@@DEnt:
5751     @@@@test:value:
5752     <!DOCTYPE a PUBLIC 'p" "s"><a/>
5753     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 32); }
5754     @@XMLTest:
5755     @@@QName: xp.doctype.pubid.lita.lit.unmatched.2.test
5756     @@@DEnt:
5757     @@@@test:value:
5758     <!DOCTYPE a PUBLIC 'p" 's'>
5759     <a/>
5760     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 21)..(1, 25); }
5761     @@XMLTest:
5762     @@@QName: xp.doctype.public.s.lit.mdc.test
5763     @@@DEnt:
5764     @@@@test:value:
5765     <!DOCTYPE a PUBLIC "><a/>
5766     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 26); }
5767     @@XMLTest:
5768     @@@QName: xp.doctype.public.s.lita.mdc.test
5769     @@@DEnt:
5770     @@@@test:value:
5771     <!DOCTYPE a PUBLIC '><a/>
5772     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 26); }
5773     @@XMLTest:
5774     @@@QName: xp.doctype.public.lit.pubid.lit.mdc.test
5775     @@@DEnt:
5776     @@@@test:value:
5777     <!DOCTYPE a PUBLIC "p">
5778     <a/>
5779     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 23); }
5780     @@XMLTest:
5781     @@@QName: xp.doctype.public.lita.pubid.lita.mdc.test
5782     @@@DEnt:
5783     @@@@test:value:
5784     <!DOCTYPE a PUBLIC 'p'>
5785     <a/>
5786     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 23); }
5787     @@XMLTest:
5788     @@@QName: xp.doctype.public.lit.pubid.lit.s.mdc.test
5789     @@@DEnt:
5790     @@@@test:value:
5791     <!DOCTYPE a PUBLIC "p" >
5792     <a/>
5793     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 24); }
5794     @@XMLTest:
5795     @@@QName: xp.doctype.public.lita.pubid.lita.s.mdc.test
5796     @@@DEnt:
5797     @@@@test:value:
5798     <!DOCTYPE a PUBLIC 'p' >
5799     <a/>
5800     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 24); }
5801     @@XMLTest:
5802     @@@QName: xp.doctype.public.lit.pubid.lit.s.lit.mdc.test
5803     @@@DEnt:
5804     @@@@test:value:
5805     <!DOCTYPE a PUBLIC "p" "><a/>
5806     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 30); }
5807     @@XMLTest:
5808     @@@QName: xp.doctype.public.lit.pubid.lit.s.lita.mdc.test
5809     @@@DEnt:
5810     @@@@test:value:
5811     <!DOCTYPE a PUBLIC "p" '><a/>
5812     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 30); }
5813     @@XMLTest:
5814     @@@QName: xp.doctype.public.lita.pubid.lita.s.lit.mdc.test
5815     @@@DEnt:
5816     @@@@test:value:
5817     <!DOCTYPE a PUBLIC 'p' "><a/>
5818     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 30); }
5819     @@XMLTest:
5820     @@@QName: xp.doctype.public.lita.pubid.lita.s.lita.mdc.test
5821     @@@DEnt:
5822     @@@@test:value:
5823     <!DOCTYPE a PUBLIC 'p' '><a/>
5824     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 30); }
5825     @@XMLTest:
5826     @@@QName: xp.doctype.public.lit.pubid.lit.lit.lita.unmatched.mdc.test
5827     @@@DEnt:
5828     @@@@test:value:
5829     <!DOCTYPE a PUBLIC "p" "s'><a/>
5830     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 32); }
5831     @@XMLTest:
5832     @@@QName: xp.doctype.public.lita.pubid.lita.lita.lit.unmatched.mdc.test
5833     @@@DEnt:
5834     @@@@test:value:
5835     <!DOCTYPE a PUBLIC 'p' 's"><a/>
5836     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 32); }
5837     @@XMLTest:
5838     @@@QName: xp.doctype.pubid.sysid.stago.1.test
5839     @@@DEnt:
5840     @@@@test:value:
5841     <!DOCTYPE a PUBLIC "p" "s"<a/>
5842     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 27); }
5843     @@XMLTest:
5844     @@@QName: xp.doctype.pubid.sysid.stago.2.test
5845     @@@DEnt:
5846     @@@@test:value:
5847     <!DOCTYPE a PUBLIC "p" 's'<a/>
5848     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 27); }
5849     @@XMLTest:
5850     @@@QName: xp.doctype.pubid.sysid.stago.s.1.test
5851     @@@DEnt:
5852     @@@@test:value:
5853     <!DOCTYPE a PUBLIC "p" "s" <a/>
5854     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 28); }
5855     @@XMLTest:
5856     @@@QName: xp.doctype.pubid.sysid.stago.s.2.test
5857     @@@DEnt:
5858     @@@@test:value:
5859     <!DOCTYPE a PUBLIC "p" 's' <a/>
5860     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 28); }
5861 wakaba 1.16
5862     @@XMLTest:
5863     @@@QName: xp.endofline.1.0.crlf.test
5864     @@@DEnt:
5865     @@@@test:value:
5866     <?xml version="1.0"?>
5867     <p>aaa$u000D$u000Abbb</p>
5868 wakaba 1.6 @@@test:domTree:
5869     document {
5870     xml-version: '1.0';
5871 wakaba 1.16 element {
5872     text-content: 'aaa' U+000A 'bbb';
5873 wakaba 1.6 }
5874 wakaba 1.16 }
5875     @@XMLTest:
5876     @@@QName: xp.endofline.1.1.crlf.test
5877     @@@DEnt:
5878     @@@@test:value:
5879     <?xml version="1.1"?>
5880     <p>aaa$u000D$u000Abbb</p>
5881     @@@test:domTree:
5882     document {
5883     xml-version: '1.1';
5884 wakaba 1.6 element {
5885 wakaba 1.16 text-content: 'aaa' U+000A 'bbb';
5886 wakaba 1.6 }
5887     }
5888     @@XMLTest:
5889 wakaba 1.16 @@@QName: xp.endofline.1.0.crnl.test
5890 wakaba 1.6 @@@DEnt:
5891     @@@@test:value:
5892 wakaba 1.16 <?xml version="1.0"?>
5893     <p>aaa$u000D$u0085bbb</p>
5894 wakaba 1.6 @@@test:domTree:
5895     document {
5896     xml-version: '1.0';
5897 wakaba 1.16 element {
5898     text-content: 'aaa' U+000A U+0085 'bbb';
5899 wakaba 1.6 }
5900 wakaba 1.16 }
5901     @@XMLTest:
5902     @@@QName: xp.endofline.1.1.crnl.test
5903     @@@DEnt:
5904     @@@@test:value:
5905     <?xml version="1.1"?>
5906     <p>aaa$u000D$u0085bbb</p>
5907     @@@test:domTree:
5908     document {
5909     xml-version: '1.1';
5910 wakaba 1.6 element {
5911 wakaba 1.16 text-content: 'aaa' U+000A 'bbb';
5912 wakaba 1.6 }
5913     }
5914     @@XMLTest:
5915 wakaba 1.16 @@@QName: xp.endofline.1.0.nl.test
5916 wakaba 1.6 @@@DEnt:
5917     @@@@test:value:
5918 wakaba 1.16 <?xml version="1.0"?>
5919     <p>aaa$u0085bbb</p>
5920 wakaba 1.6 @@@test:domTree:
5921     document {
5922     xml-version: '1.0';
5923     element {
5924 wakaba 1.16 text-content: 'aaa' U+0085 'bbb';
5925 wakaba 1.6 }
5926     }
5927     @@XMLTest:
5928 wakaba 1.16 @@@QName: xp.endofline.1.1.nl.test
5929 wakaba 1.6 @@@DEnt:
5930     @@@@test:value:
5931 wakaba 1.16 <?xml version="1.1"?>
5932     <p>aaa$u0085bbb</p>
5933     @@@test:domTree:
5934     document {
5935     xml-version: '1.1';
5936     element {
5937     text-content: 'aaa' U+000A 'bbb';
5938     }
5939     }
5940     @@XMLTest:
5941     @@@QName: xp.endofline.1.0.ls.test
5942     @@@DEnt:
5943     @@@@test:value:
5944     <?xml version="1.0"?>
5945     <p>aaa$u2028bbb</p>
5946     @@@test:domTree:
5947     document {
5948     xml-version: '1.0';
5949     element {
5950     text-content: 'aaa' U+2028 'bbb';
5951     }
5952     }
5953     @@XMLTest:
5954     @@@QName: xp.endofline.1.1.ls.test
5955     @@@DEnt:
5956     @@@@test:value:
5957     <?xml version="1.1"?>
5958     <p>aaa$u2028bbb</p>
5959     @@@test:domTree:
5960     document {
5961     xml-version: '1.1';
5962     element {
5963     text-content: 'aaa' U+000A 'bbb';
5964     }
5965     }
5966     @@XMLTest:
5967     @@@QName: xp.endofline.1.0.cr.test
5968     @@@DEnt:
5969     @@@@test:value:
5970     <?xml version="1.0"?>
5971     <p>aaa$u000Dbbb</p>
5972     @@@test:domTree:
5973     document {
5974     xml-version: '1.0';
5975     element {
5976     text-content: 'aaa' U+000A 'bbb';
5977     }
5978     }
5979     @@XMLTest:
5980     @@@QName: xp.endofline.1.1.cr.test
5981     @@@DEnt:
5982     @@@@test:value:
5983     <?xml version="1.1"?>
5984     <p>aaa$u000Dbbb</p>
5985     @@@test:domTree:
5986     document {
5987     xml-version: '1.1';
5988     element {
5989     text-content: 'aaa' U+000A 'bbb';
5990     }
5991     }
5992     @@XMLTest:
5993     @@@QName: xp.endofline.1.0.lf.test
5994     @@@DEnt:
5995     @@@@test:value:
5996     <?xml version="1.0"?>
5997     <p>aaa$u000Abbb</p>
5998     @@@test:domTree:
5999     document {
6000     xml-version: '1.0';
6001     element {
6002     text-content: 'aaa' U+000A 'bbb';
6003     }
6004     }
6005     @@XMLTest:
6006     @@@QName: xp.endofline.1.1.lf.test
6007     @@@DEnt:
6008     @@@@test:value:
6009     <?xml version="1.1"?>
6010     <p>aaa$u000Abbb</p>
6011     @@@test:domTree:
6012     document {
6013     xml-version: '1.1';
6014     element {
6015     text-content: 'aaa' U+000A 'bbb';
6016     }
6017     }
6018     @@XMLTest:
6019     @@@QName: xp.xml10.endofline.nl.in.xmldecl.1.test
6020     @@@DEnt:
6021     @@@@test:value:
6022     <?xml$u0085version="1.0"?>
6023     <p/>
6024     @@@c:erred:
6025     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 6)..(2, 0); }
6026     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6027     @@XMLTest:
6028     @@@QName: xp.xml11.endofline.nl.in.xmldecl.1.test
6029     @@@DEnt:
6030     @@@@test:value:
6031     <?xml$u0085version="1.1"?>
6032     (err)<p/>
6033     @@@c:erred:
6034     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 6)..(2, 0); }
6035     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6036     @@XMLTest:
6037     @@@QName: xp.xml10.endofline.crnl.in.xmldecl.1.test
6038     @@@DEnt:
6039     @@@@test:value:
6040     <?xml$u000D$u0085version="1.0"?>
6041     <p/>
6042     @@@c:erred:
6043     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 6)..(2, 0); }
6044     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6045     @@XMLTest:
6046     @@@QName: xp.xml11.endofline.crnl.in.xmldecl.1.test
6047     @@@DEnt:
6048     @@@@test:value:
6049     <?xml$u000D$u0085version="1.1"?>
6050     (err)<p/>
6051     @@@c:erred:
6052     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 6)..(2, 0); }
6053     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6054     @@XMLTest:
6055     @@@QName: xp.xml10.endofline.ls.in.xmldecl.1.test
6056     @@@DEnt:
6057     @@@@test:value:
6058     <?xml$u2028version="1.0"?>
6059     <p/>
6060     @@@c:erred:
6061     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 6)..(2, 0); }
6062     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6063     @@XMLTest:
6064     @@@QName: xp.xml11.endofline.ls.in.xmldecl.1.test
6065     @@@DEnt:
6066     @@@@test:value:
6067     <?xml$u2028version="1.1"?>
6068     (err)<p/>
6069     @@@c:erred:
6070     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 6)..(2, 0); }
6071     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6072     @@XMLTest:
6073     @@@QName: xp.xml10.endofline.nl.in.xmldecl.2.test
6074     @@@DEnt:
6075     @@@@test:value:
6076     <?xml version="1.0"$u0085?>
6077     <p/>
6078     @@@c:erred:
6079     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 20)..(2, 0); }
6080     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6081     @@XMLTest:
6082     @@@QName: xp.xml11.endofline.nl.in.xmldecl.2.test
6083     @@@DEnt:
6084     @@@@test:value:
6085     <?xml version="1.1"$u0085?>
6086     (err)<p/>
6087     @@@c:erred:
6088     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 20)..(2, 0); }
6089     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6090     @@XMLTest:
6091     @@@QName: xp.xml10.endofline.crnl.in.xmldecl.2.test
6092     @@@DEnt:
6093     @@@@test:value:
6094     <?xml version="1.0"$u000D$u0085?>
6095     <p/>
6096     @@@c:erred:
6097     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 20)..(2, 0); }
6098     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6099     @@XMLTest:
6100     @@@QName: xp.xml11.endofline.crnl.in.xmldecl.2.test
6101     @@@DEnt:
6102     @@@@test:value:
6103     <?xml version="1.1"$u000D$u0085?>
6104     (err)<p/>
6105     @@@c:erred:
6106     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 20)..(2, 0); }
6107     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6108     @@XMLTest:
6109     @@@QName: xp.xml10.endofline.ls.in.xmldecl.2.test
6110     @@@DEnt:
6111     @@@@test:value:
6112     <?xml version="1.0"$u2028?>
6113     <p/>
6114     @@@c:erred:
6115     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 20)..(2, 0); }
6116     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6117     @@XMLTest:
6118     @@@QName: xp.xml11.endofline.ls.in.xmldecl.2.test
6119     @@@DEnt:
6120     @@@@test:value:
6121     <?xml version="1.1"$u2028?>
6122     (err)<p/>
6123     @@@c:erred:
6124     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 20)..(2, 0); }
6125     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6126     @@XMLTest:
6127     @@@QName: xp.xml10.endofline.nl.in.xmldecl.3.test
6128     @@@DEnt:
6129     @@@@test:value:
6130     <?xml $u0085version="1.0"?>
6131     <p/>
6132     @@@c:erred:
6133     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 7)..(2, 0); }
6134     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6135     @@XMLTest:
6136     @@@QName: xp.xml11.endofline.nl.in.xmldecl.3.test
6137     @@@DEnt:
6138     @@@@test:value:
6139     <?xml $u0085version="1.1"?>
6140     (err)<p/>
6141     @@@c:erred:
6142     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 7)..(2, 0); }
6143     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6144     @@XMLTest:
6145     @@@QName: xp.xml10.endofline.crnl.in.xmldecl.3.test
6146     @@@DEnt:
6147     @@@@test:value:
6148     <?xml $u000D$u0085version="1.0"?>
6149     <p/>
6150     @@@c:erred:
6151     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 7)..(2, 0); }
6152     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6153     @@XMLTest:
6154     @@@QName: xp.xml11.endofline.crnl.in.xmldecl.3.test
6155     @@@DEnt:
6156     @@@@test:value:
6157     <?xml $u000D$u0085version="1.1"?>
6158     (err)<p/>
6159     @@@c:erred:
6160     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 7)..(2, 0); }
6161     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6162     @@XMLTest:
6163     @@@QName: xp.xml10.endofline.ls.in.xmldecl.3.test
6164     @@@DEnt:
6165     @@@@test:value:
6166     <?xml $u2028version="1.0"?>
6167     <p/>
6168     @@@c:erred:
6169     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 7)..(2, 0); }
6170     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6171     @@XMLTest:
6172     @@@QName: xp.xml11.endofline.ls.in.xmldecl.3.test
6173     @@@DEnt:
6174     @@@@test:value:
6175     <?xml $u2028version="1.1"?>
6176     (err)<p/>
6177     @@@c:erred:
6178     <[[xp|fatal-xml11-end-of-line-in-xml-declaration]]> { (1, 7)..(2, 0); }
6179     @@@c:erred: <[[xp|wf-syntax-error]]> { }
6180     @@XMLTest:
6181     @@@QName: xp.xml10implied.endofline.nl.in.pi.1.test
6182     @@@DEnt:
6183     @@@@test:value:
6184     <?xml-$u0085?>
6185     <p/>
6186     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 7)..(2, 0); }
6187     @@XMLTest:
6188     @@@QName: xp.xml10.endofline.nl.in.pi.1.test
6189     @@@DEnt:
6190     @@@@test:value:
6191     <?xml version="1.0"?>
6192     <?xml-$u0085?>
6193     <p/>
6194     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 7)..(3, 0); }
6195     @@XMLTest:
6196     @@@QName: xp.xml11.endofline.nl.in.pi.1.test
6197     @@@DEnt:
6198     @@@@test:value:
6199     <?xml version="1.1"?>
6200     <?xml-$u0085?>
6201     <p/>
6202     @@@test:domTree:
6203     document {
6204     xml-version: '1.1';
6205     pi {
6206     node-name: 'xml-';
6207     node-value: '';
6208     }
6209     element { }
6210     }
6211     @@XMLTest:
6212     @@@QName: xp.xml10implied.endofline.crnl.in.pi.1.test
6213     @@@DEnt:
6214     @@@@test:value:
6215     <?xml-$u000D$u0085?>
6216     <p/>
6217     @@@test:domTree:
6218     document {
6219     xml-version: '1.0';
6220     pi {
6221     node-name: 'xml-';
6222     node-value: U+0085;
6223     }
6224     element { }
6225     }
6226     @@XMLTest:
6227     @@@QName: xp.xml10.endofline.crnl.in.pi.1.test
6228     @@@DEnt:
6229     @@@@test:value:
6230     <?xml version="1.0"?>
6231     <?xml-$u000D$u0085?>
6232     <p/>
6233     @@@test:domTree:
6234     document {
6235     xml-version: '1.0';
6236     pi {
6237     node-name: 'xml-';
6238     node-value: U+0085;
6239     }
6240     element { }
6241     }
6242     @@XMLTest:
6243     @@@QName: xp.xml11.endofline.crnl.in.pi.1.test
6244     @@@DEnt:
6245     @@@@test:value:
6246     <?xml version="1.1"?>
6247     <?xml-$u000D$u0085?>
6248     <p/>
6249     @@@test:domTree:
6250     document {
6251     xml-version: '1.1';
6252     pi {
6253     node-name: 'xml-';
6254     node-value: '';
6255     }
6256     element { }
6257     }
6258     @@XMLTest:
6259     @@@QName: xp.xml10implied.endofline.ls.in.pi.1.test
6260     @@@DEnt:
6261     @@@@test:value:
6262     <?xml-$u2028?>
6263     <p/>
6264     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 7)..(2, 0); }
6265     @@XMLTest:
6266     @@@QName: xp.xml10.endofline.ls.in.pi.1.test
6267     @@@DEnt:
6268     @@@@test:value:
6269     <?xml version="1.0"?>
6270     <?xml-$u2028?>
6271     <p/>
6272     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 7)..(3, 0); }
6273     @@XMLTest:
6274     @@@QName: xp.xml11.endofline.ls.in.pi.1.test
6275     @@@DEnt:
6276     @@@@test:value:
6277     <?xml version="1.1"?>
6278     <?xml-$u2028?>
6279     <p/>
6280     @@@test:domTree:
6281     document {
6282     xml-version: '1.1';
6283     pi {
6284     node-name: 'xml-';
6285     node-value: '';
6286     }
6287     element { }
6288     }
6289     @@XMLTest:
6290     @@@QName: xp.noxmldecl.pi.pi.test
6291     @@@DEnt:
6292     @@@@test:value:
6293     <?noxml 1?><?noxml 2?><p/>
6294     @@@test:domTree:
6295     document {
6296     xml-version: '1.0';
6297     pi {
6298     node-name: 'noxml';
6299     node-value: '1';
6300     }
6301     pi {
6302     node-name: 'noxml';
6303     node-value: '2';
6304     }
6305     element { }
6306     }
6307     @@XMLTest:
6308     @@@QName: xp.noxmldecl.pi.pi.2.test
6309     @@@DEnt:
6310     @@@@test:value:
6311     <?xmlno 1?><?xmlno 2?><p/>
6312     @@@test:domTree:
6313     document {
6314     xml-version: '1.0';
6315     pi {
6316     node-name: 'xmlno';
6317     node-value: '1';
6318     }
6319     pi {
6320     node-name: 'xmlno';
6321     node-value: '2';
6322     }
6323     element { }
6324     }
6325     @@XMLTest:
6326     @@@QName: xp.noxmldecl.pi.pi.3.test
6327     @@@DEnt:
6328     @@@@test:value:
6329     <?xmln 1?><?xmln 2?><p/>
6330     @@@test:domTree:
6331     document {
6332     xml-version: '1.0';
6333     pi {
6334     node-name: 'xmln';
6335     node-value: '1';
6336     }
6337     pi {
6338     node-name: 'xmln';
6339     node-value: '2';
6340     }
6341     element { }
6342     }
6343     @@XMLTest:
6344     @@@QName: xp.noxml.s.nl.test
6345     @@@DEnt:
6346     @@@@test:value:
6347     $u0085<p/>
6348     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 1)..(2, 0); }
6349     @@XMLTest:
6350     @@@QName: xp.noxml.s.crnl.test
6351     @@@DEnt:
6352     @@@@test:value:
6353     $u000D$u0085<p/>
6354     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 1)..(2, 0); }
6355     @@XMLTest:
6356     @@@QName: xp.noxml.s.ls.test
6357     @@@DEnt:
6358     @@@@test:value:
6359     $u2028<p/>
6360     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 1)..(2, 0); }
6361     @@XMLTest:
6362     @@@QName: xp.xml10.decl.s.nl.test
6363     @@@DEnt:
6364     @@@@test:value:
6365     <?xml version="1.0"?>$u0085<p/>
6366     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 22)..(2, 0); }
6367     @@XMLTest:
6368     @@@QName: xp.xml10.decl.s.crnl.test
6369     @@@DEnt:
6370     @@@@test:value:
6371     <?xml version="1.0"?>$u000D$u0085<p/>
6372     @@@c:erred: <[[xp|wf-syntax-error]]> { (2, 0)..(3, 0); }
6373     @@XMLTest:
6374     @@@QName: xp.xml10.decl.s.ls.test
6375     @@@DEnt:
6376     @@@@test:value:
6377     <?xml version="1.0"?>$u2028<p/>
6378     @@@c:erred: <[[xp|wf-syntax-error]]> { (1, 22)..(2, 0); }
6379     @@XMLTest:
6380     @@@QName: xp.xml11.decl.s.nl.test
6381     @@@DEnt:
6382     @@@@test:value:
6383     <?xml version="1.1"?>$u0085<p/>
6384     @@@test:domTree:
6385     document {
6386     xml-version: '1.1';
6387     element { }
6388     }
6389     @@XMLTest:
6390     @@@QName: xp.xml11.decl.s.crnl.test
6391     @@@DEnt:
6392     @@@@test:value:
6393     <?xml version="1.1"?>$u000D$u0085<p/>
6394     @@@test:domTree:
6395     document {
6396     xml-version: '1.1';
6397     element { }
6398     }
6399     @@XMLTest:
6400     @@@QName: xp.xml11.decl.s.ls.test
6401     @@@DEnt:
6402     @@@@test:value:
6403     <?xml version="1.1"?>$u2028<p/>
6404     @@@test:domTree:
6405     document {
6406     xml-version: '1.1';
6407     element { }
6408     }
6409    
6410     @@XMLTest:
6411     @@@QName: xp.doctype.intsubset.pi.test
6412     @@@DEnt:
6413     @@@@test:value:
6414     <!DOCTYPE a [
6415     <?pi data ?>
6416     ]>
6417     <a></a>
6418     @@@test:domTree:
6419     document {
6420     xml-version: '1.0';
6421     xml-encoding: null;
6422     xml-standalone: false;
6423     document-type {
6424     node-name: 'a';
6425     pi {
6426     target: 'pi';
6427     data: 'data ';
6428     }
6429     }
6430     element {
6431     namespace-uri: null;
6432     prefix: null;
6433     local-name: 'a';
6434     text-content: '';
6435     }
6436     }
6437     @@@enImplNote:
6438     A DOM PI node in doctype node is a manakai extension.
6439    
6440    
6441     @@XMLTest:
6442     @@@QName: xp.doctype.intsubset.entity.general.internal.test
6443     @@@DEnt:
6444     @@@@test:value:
6445     <!DOCTYPE a [
6446     <!ENTITY entity "entity value">
6447     ]>
6448     <a></a>
6449     @@@test:domTree:
6450     document {
6451     xml-version: '1.0';
6452     xml-encoding: null;
6453     xml-standalone: false;
6454     document-type {
6455     node-name: 'a';
6456     general-entity {
6457     node-name: 'entity';
6458     text-content: 'entity value';
6459     has-replacement-tree: true;
6460     }
6461     }
6462     element {
6463     namespace-uri: null;
6464     prefix: null;
6465     local-name: 'a';
6466     text-content: '';
6467     }
6468     }
6469     @@XMLTest:
6470     @@@QName: xp.doctype.intsubset.entity.parameter.internal.test
6471     @@@DEnt:
6472     @@@@test:value:
6473     <!DOCTYPE a [
6474     <!ENTITY % entity "entity value">
6475     ]>
6476     <a></a>
6477     @@@test:domTree:
6478     document {
6479     xml-version: '1.0';
6480     xml-encoding: null;
6481     xml-standalone: false;
6482     document-type {
6483     node-name: 'a';
6484     }
6485     element {
6486     namespace-uri: null;
6487     prefix: null;
6488     local-name: 'a';
6489     text-content: '';
6490     }
6491     }
6492    
6493     @@XMLTest:
6494     @@@QName: xp.doctype.internal.entity.root.element.text.only.test
6495     @@@DEnt:
6496     @@@@test:value:
6497     <!DOCTYPE a [
6498     <!ENTITY entity "entity value">
6499     ]>
6500     <a>&entity;</a>
6501     @@@test:domTree:
6502     document {
6503     xml-version: '1.0';
6504     xml-encoding: null;
6505     xml-standalone: false;
6506     document-type {
6507     node-name: 'a';
6508     general-entity {
6509     node-name: 'entity';
6510     text-content: 'entity value';
6511     has-replacement-tree: true;
6512     }
6513     }
6514     element {
6515     namespace-uri: null;
6516     prefix: null;
6517     local-name: 'a';
6518     general-entity-reference {
6519     node-name: 'entity';
6520     text {
6521     data: 'entity value';
6522     }
6523     }
6524     }
6525     }
6526     @@XMLTest:
6527     @@@QName: xp.doctype.internal.entity.root.element.text.mult.test
6528     @@@DEnt:
6529     @@@@test:value:
6530     <!DOCTYPE a [
6531     <!ENTITY entity "entity value">
6532     ]>
6533     <a>&entity; and &entity;</a>
6534     @@@test:domTree:
6535     document {
6536     xml-version: '1.0';
6537     xml-encoding: null;
6538     xml-standalone: false;
6539     document-type {
6540     node-name: 'a';
6541     general-entity {
6542     node-name: 'entity';
6543     text-content: 'entity value';
6544     has-replacement-tree: true;
6545     }
6546     }
6547     element {
6548     namespace-uri: null;
6549     prefix: null;
6550     local-name: 'a';
6551     general-entity-reference {
6552     node-name: 'entity';
6553     text {
6554     data: 'entity value';
6555     }
6556     }
6557     text { data: ' and '; }
6558     general-entity-reference {
6559     node-name: 'entity';
6560     text {
6561     data: 'entity value';
6562     }
6563     }
6564     }
6565     }
6566     @@XMLTest:
6567     @@@QName: xp.doctype.internal.entity.root.element.text.element.test
6568     @@@DEnt:
6569     @@@@test:value:
6570     <!DOCTYPE a [
6571     <!ENTITY entity "entity <p>value</p> with <e>element</e> ">
6572     ]>
6573     <a>&entity;</a>
6574 wakaba 1.6 @@@test:domTree:
6575     document {
6576     xml-version: '1.0';
6577     xml-encoding: null;
6578     xml-standalone: false;
6579     document-type {
6580     node-name: 'a';
6581 wakaba 1.11 general-entity {
6582     node-name: 'entity';
6583     has-replacement-tree: true;
6584     text { data: 'entity '; }
6585     element {
6586     node-name: 'p';
6587     text-content: 'value';
6588     }
6589     text { data: ' with '; }
6590     element {
6591     node-name: 'e';
6592     text-content: 'element';
6593     }
6594     }
6595 wakaba 1.6 }
6596     element {
6597     namespace-uri: null;
6598     prefix: null;
6599     local-name: 'a';
6600     general-entity-reference {
6601     node-name: 'entity';
6602     text {
6603     data: 'entity ';
6604     }
6605     element {
6606     namespace-uri: null;
6607     prefix: null;
6608     local-name: 'p';
6609     text {
6610     data: 'value';
6611     }
6612     }
6613     text {
6614     data: ' with ';
6615     }
6616     element {
6617     namespace-uri: null;
6618     prefix: null;
6619     local-name: 'e';
6620     text {
6621     data: 'element';
6622     }
6623     }
6624     text {
6625     data: ' ';
6626     }
6627     }
6628     }
6629     }
6630     @@XMLTest:
6631     @@@QName: xp.doctype.internal.entity.root.element.text.in.ent.test
6632     @@@DEnt:
6633     @@@@test:value:
6634     <!DOCTYPE a [
6635     <!ENTITY entity1 "entity value">
6636     <!ENTITY entity2 "e&entity1;n">
6637     ]>
6638     <a>&entity2;</a>
6639     @@@test:domTree:
6640     document {
6641     xml-version: '1.0';
6642     xml-encoding: null;
6643     xml-standalone: false;
6644     document-type {
6645     node-name: 'a';
6646 wakaba 1.11 general-entity {
6647     node-name: 'entity1';
6648     text-content: 'entity value';
6649     }
6650     general-entity {
6651     node-name: 'entity2';
6652     text { data: 'e'; }
6653     general-entity-reference {
6654     node-name: 'entity1';
6655     text-content: 'entity value';
6656     is-expanded: true;
6657     }
6658     text { data: 'n'; }
6659     }
6660 wakaba 1.6 }
6661     element {
6662     namespace-uri: null;
6663     prefix: null;
6664     local-name: 'a';
6665     general-entity-reference {
6666     node-name: 'entity2';
6667     text { data: 'e'; }
6668     general-entity-reference {
6669     node-name: 'entity1';
6670     text {
6671     data: 'entity value';
6672     }
6673     }
6674     text { data: 'n'; }
6675     }
6676 wakaba 1.8 }
6677     }
6678 wakaba 1.11
6679     @@XMLTest:
6680     @@@QName: xp.doctype.entity.value.charref.test
6681     @@@DEnt:
6682     @@@@test:value:
6683     <!DOCTYPE a [
6684     <!ENTITY entity1 "entity &#x21;value&#35;">
6685     <!ENTITY entity2 '&#x21;value&#35;'>
6686     ]>
6687     <a></a>
6688     @@@test:domTree:
6689     document {
6690     document-type {
6691     general-entity {
6692     node-name: 'entity1';
6693     text-content: 'entity !value#';
6694     has-replacement-tree: true;
6695     }
6696     general-entity {
6697     node-name: 'entity2';
6698     text-content: '!value#';
6699     has-replacement-tree: true;
6700     }
6701     }
6702     element { }
6703     }
6704    
6705     @@XMLTest:
6706     @@@QName: xp.predefined.in.content.test
6707     @@@DEnt:
6708     @@@@test:value:
6709     <a>_&lt;_&gt;_&quot;_&apos;_&amp;_</a>
6710     @@@test:domTree:
6711     document {
6712     element {
6713     text-content: '_<_>_"_' U+0027 '_&_';
6714     }
6715     }
6716     @@XMLTest:
6717     @@@QName: xp.predefined.in.attr.test
6718     @@@DEnt:
6719     @@@@test:value:
6720     <a at="_&lt;_&gt;_&quot;_&apos;_&amp;_"></a>
6721     @@@test:domTree:
6722     document {
6723     element {
6724     attribute {
6725     node-name: 'at';
6726     text-content: '_<_>_"_' U+0027 '_&_';
6727     }
6728     }
6729     }
6730     @@XMLTest:
6731     @@@QName: xp.predefined.in.content.in.entity.test
6732     @@@DEnt:
6733     @@@@test:value:
6734     <!DOCTYPE a [
6735     <!ENTITY ent "_&lt;_&gt;_&quot;_&apos;_&amp;_">
6736     ]>
6737     <a>&ent;</a>
6738     @@@test:domTree:
6739     document {
6740     document-type {
6741     general-entity {
6742     node-name: 'ent';
6743     text-content: '_<_>_"_' U+0027 '_&_';
6744     }
6745     }
6746     element {
6747     text-content: '_<_>_"_' U+0027 '_&_';
6748     }
6749     }
6750     @@XMLTest:
6751     @@@QName: xp.predefined.decl.ignore.test
6752     @@@DEnt:
6753     @@@@test:value:
6754     <!DOCTYPE a [
6755     <!ENTITY lt "&#x26;#x3C;">
6756     <!ENTITY gt "&#x3E;">
6757     <!ENTITY amp "&#x26;#x26;">
6758     <!ENTITY quot "&#x22;">
6759     <!ENTITY apos "&#x27;">
6760     <!ENTITY other "other">
6761     ]>
6762     <a>_&lt;_&gt;_&quot;_&apos;_&amp;_&other;_</a>
6763     @@@test:domTree:
6764     document {
6765     document-type {
6766     general-entity {
6767     node-name: 'other';
6768     text-content: 'other';
6769     }
6770     }
6771     element {
6772     text-content: '_<_>_"_' U+0027 '_&_other_';
6773     }
6774     }
6775    
6776 wakaba 1.8 @@XMLTest:
6777     @@@QName: xp.doctype.internal.attr.empty.test
6778     @@@DEnt:
6779     @@@@test:value:
6780     <!DOCTYPE a [
6781     <!ATTLIST a>
6782     ]>
6783     <a></a>
6784     @@@test:domTree:
6785     document {
6786     xml-version: '1.0';
6787     xml-encoding: null;
6788     xml-standalone: false;
6789     document-type {
6790     node-name: 'a';
6791     element-type-definition {
6792     node-name: 'a';
6793     }
6794     }
6795     element {
6796     namespace-uri: null;
6797     local-name: 'a';
6798     }
6799     }
6800     @@XMLTest:
6801     @@@QName: xp.doctype.internal.attr.cdata.implied.test
6802     @@@DEnt:
6803     @@@@test:value:
6804     <!DOCTYPE a [
6805     <!ATTLIST a
6806     at CDATA #IMPLIED
6807     >
6808     ]>
6809     <a></a>
6810     @@@test:domTree:
6811     document {
6812     xml-version: '1.0';
6813     xml-encoding: null;
6814     xml-standalone: false;
6815     document-type {
6816     node-name: 'a';
6817     element-type-definition {
6818     node-name: 'a';
6819     attribute-definition {
6820     node-name: 'at';
6821     declared-type: const (CDATA_ATTR);
6822     allowed-tokens: DOMStringList ();
6823     default-type: const (IMPLIED_DEFAULT);
6824     text-content: '';
6825     }
6826     }
6827     }
6828     element {
6829     namespace-uri: null;
6830     local-name: 'a';
6831     }
6832     }
6833     @@XMLTest:
6834     @@@QName: xp.doctype.internal.attr.types.implied.test
6835     @@@DEnt:
6836     @@@@test:value:
6837     <!DOCTYPE a [
6838     <!ATTLIST a
6839     at1 ID #IMPLIED
6840     at2 IDREF #IMPLIED
6841     at3 IDREFS #IMPLIED
6842     at4 ENTITY #IMPLIED
6843     at5 ENTITIES #IMPLIED
6844     at6 NMTOKEN #IMPLIED
6845     at7 NMTOKENS #IMPLIED
6846     at8 NOTATION (n1 | n2|n3) #IMPLIED
6847     at9 (e1| e2| e3 ) #IMPLIED
6848     >
6849     ]>
6850     <a></a>
6851     @@@test:domTree:
6852     document {
6853     xml-version: '1.0';
6854     xml-encoding: null;
6855     xml-standalone: false;
6856     document-type {
6857     node-name: 'a';
6858     element-type-definition {
6859     node-name: 'a';
6860     attribute-definition {
6861     node-name: 'at1';
6862     declared-type: const (ID_ATTR);
6863     allowed-tokens: DOMStringList ();
6864     default-type: const (IMPLIED_DEFAULT);
6865     text-content: '';
6866     }
6867     attribute-definition {
6868     node-name: 'at2';
6869     declared-type: const (IDREF_ATTR);
6870     allowed-tokens: DOMStringList ();
6871     default-type: const (IMPLIED_DEFAULT);
6872     text-content: '';
6873     }
6874     attribute-definition {
6875     node-name: 'at3';
6876     declared-type: const (IDREFS_ATTR);
6877     allowed-tokens: DOMStringList ();
6878     default-type: const (IMPLIED_DEFAULT);
6879     text-content: '';
6880     }
6881     attribute-definition {
6882     node-name: 'at4';
6883     declared-type: const (ENTITY_ATTR);
6884     allowed-tokens: DOMStringList ();
6885     default-type: const (IMPLIED_DEFAULT);
6886     text-content: '';
6887     }
6888     attribute-definition {
6889     node-name: 'at5';
6890     declared-type: const (ENTITIES_ATTR);
6891     allowed-tokens: DOMStringList ();
6892     default-type: const (IMPLIED_DEFAULT);
6893     text-content: '';
6894     }
6895     attribute-definition {
6896     node-name: 'at6';
6897     declared-type: const (NMTOKEN_ATTR);
6898     allowed-tokens: DOMStringList ();
6899     default-type: const (IMPLIED_DEFAULT);
6900     text-content: '';
6901     }
6902     attribute-definition {
6903     node-name: 'at7';
6904     declared-type: const (NMTOKENS_ATTR);
6905     allowed-tokens: DOMStringList ();
6906     default-type: const (IMPLIED_DEFAULT);
6907     text-content: '';
6908     }
6909     attribute-definition {
6910     node-name: 'at8';
6911     declared-type: const (NOTATION_ATTR);
6912     allowed-tokens: DOMStringList ('n1', 'n2', 'n3');
6913     default-type: const (IMPLIED_DEFAULT);
6914     text-content: '';
6915     }
6916     attribute-definition {
6917     node-name: 'at9';
6918     declared-type: const (ENUMERATION_ATTR);
6919     allowed-tokens: DOMStringList ('e1', 'e2', 'e3');
6920     default-type: const (IMPLIED_DEFAULT);
6921     text-content: '';
6922     }
6923     }
6924     }
6925     element {
6926     namespace-uri: null;
6927     local-name: 'a';
6928     }
6929     }
6930     @@XMLTest:
6931     @@@QName: xp.doctype.internal.attr.cdata.defaults.test
6932     @@@DEnt:
6933     @@@@test:value:
6934     <!DOCTYPE a [
6935     <!ATTLIST a
6936     at1 CDATA #IMPLIED
6937     at2 CDATA #REQUIRED
6938     at3 CDATA #FIXED "value3"
6939     at4 CDATA "value4"
6940     at5 CDATA #FIXED 'value5'
6941     at6 CDATA 'value6'
6942     >
6943     ]>
6944     <a></a>
6945     @@@test:domTree:
6946     document {
6947     xml-version: '1.0';
6948     xml-encoding: null;
6949     xml-standalone: false;
6950     document-type {
6951     node-name: 'a';
6952     element-type-definition {
6953     node-name: 'a';
6954     attribute-definition {
6955     node-name: 'at1';
6956     declared-type: const (CDATA_ATTR);
6957     allowed-tokens: DOMStringList ();
6958     default-type: const (IMPLIED_DEFAULT);
6959     text-content: '';
6960     }
6961     attribute-definition {
6962     node-name: 'at2';
6963     declared-type: const (CDATA_ATTR);
6964     allowed-tokens: DOMStringList ();
6965     default-type: const (REQUIRED_DEFAULT);
6966     text-content: '';
6967     }
6968     attribute-definition {
6969     node-name: 'at3';
6970     declared-type: const (CDATA_ATTR);
6971     allowed-tokens: DOMStringList ();
6972     default-type: const (FIXED_DEFAULT);
6973     text-content: 'value3';
6974     }
6975     attribute-definition {
6976     node-name: 'at4';
6977     declared-type: const (CDATA_ATTR);
6978     allowed-tokens: DOMStringList ();
6979     default-type: const (EXPLICIT_DEFAULT);
6980     text-content: 'value4';
6981     }
6982     attribute-definition {
6983     node-name: 'at5';
6984     declared-type: const (CDATA_ATTR);
6985     allowed-tokens: DOMStringList ();
6986     default-type: const (FIXED_DEFAULT);
6987     text-content: 'value5';
6988     }
6989     attribute-definition {
6990     node-name: 'at6';
6991     declared-type: const (CDATA_ATTR);
6992     allowed-tokens: DOMStringList ();
6993     default-type: const (EXPLICIT_DEFAULT);
6994     text-content: 'value6';
6995     }
6996     }
6997     }
6998     element {
6999     namespace-uri: null;
7000     local-name: 'a';
7001 wakaba 1.10 attribute {
7002     node-name: 'at3';
7003     text-content: 'value3';
7004     specified: false;
7005     }
7006     attribute {
7007     node-name: 'at4';
7008     text-content: 'value4';
7009     specified: false;
7010     }
7011     attribute {
7012     node-name: 'at5';
7013     text-content: 'value5';
7014     specified: false;
7015     }
7016     attribute {
7017     node-name: 'at6';
7018     text-content: 'value6';
7019     specified: false;
7020     }
7021 wakaba 1.9 }
7022     }
7023    
7024     @@XMLTest:
7025     @@@QName: xp.doctype.internal.attr.cdata.default.normalize.test
7026     @@@DEnt:
7027     @@@@test:value:
7028     <!DOCTYPE a [
7029     <!ATTLIST a
7030     at CDATA " default &#x0A;value "
7031     >
7032     ]>
7033     <a></a>
7034     @@@test:domTree:
7035     document {
7036     xml-version: '1.0';
7037     xml-encoding: null;
7038     xml-standalone: false;
7039     document-type {
7040     node-name: 'a';
7041     element-type-definition {
7042     node-name: 'a';
7043     attribute-definition {
7044     node-name: 'at';
7045     declared-type: const (CDATA_ATTR);
7046     allowed-tokens: DOMStringList ();
7047     default-type: const (EXPLICIT_DEFAULT);
7048     text-content: ' default ' U+000A 'value ';
7049     }
7050     }
7051     }
7052     element {
7053     namespace-uri: null;
7054     local-name: 'a';
7055 wakaba 1.10 attribute {
7056     node-name: 'at';
7057     text-content: ' default ' U+000A 'value ';
7058     specified: false;
7059     }
7060 wakaba 1.9 }
7061     }
7062     @@XMLTest:
7063     @@@QName: xp.doctype.internal.attr.nmtoken.default.normalize.test
7064     @@@DEnt:
7065     @@@@test:value:
7066     <!DOCTYPE a [
7067     <!ATTLIST a
7068     at NMTOKEN " default &#x0A;value "
7069     >
7070     ]>
7071     <a></a>
7072     @@@test:domTree:
7073     document {
7074     xml-version: '1.0';
7075     xml-encoding: null;
7076     xml-standalone: false;
7077     document-type {
7078     node-name: 'a';
7079     element-type-definition {
7080     node-name: 'a';
7081     attribute-definition {
7082     node-name: 'at';
7083     declared-type: const (NMTOKEN_ATTR);
7084     allowed-tokens: DOMStringList ();
7085     default-type: const (EXPLICIT_DEFAULT);
7086     text-content: ' default ' U+000A 'value ';
7087     }
7088     }
7089     }
7090     element {
7091     namespace-uri: null;
7092     local-name: 'a';
7093 wakaba 1.10 attribute {
7094     node-name: 'at';
7095     text-content: ' default ' U+000A 'value ';
7096     specified: false;
7097     }
7098 wakaba 1.9 }
7099     }
7100    
7101     @@XMLTest:
7102     @@@QName: xp.doctype.attrtype.no-value.test
7103     @@@DEnt:
7104     @@@@test:value:
7105     <!DOCTYPE a>
7106     <a at=" at value "></a>
7107     @@@test:domTree:
7108     document {
7109     xml-version: '1.0';
7110     xml-encoding: null;
7111     xml-standalone: false;
7112     document-type { }
7113     element {
7114     namespace-uri: null;
7115     local-name: 'a';
7116     attribute {
7117     namespace-uri: null;
7118     local-name: 'at';
7119     value: ' at value ';
7120     text {
7121     data: ' at value ';
7122     }
7123     schema-type-info: TypeInfo (null, null);
7124 wakaba 1.10 specified: true;
7125 wakaba 1.9 }
7126     }
7127     }
7128     @@XMLTest:
7129     @@@QName: xp.doctype.attrtype.cdata.test
7130     @@@DEnt:
7131     @@@@test:value:
7132     <!DOCTYPE a [
7133     <!ATTLIST a
7134     at CDATA #IMPLIED
7135     >
7136     ]>
7137     <a at=" at value "></a>
7138     @@@test:domTree:
7139     document {
7140     xml-version: '1.0';
7141     xml-encoding: null;
7142     xml-standalone: false;
7143     document-type { }
7144     element {
7145     namespace-uri: null;
7146     local-name: 'a';
7147     attribute {
7148     namespace-uri: null;
7149     local-name: 'at';
7150     value: ' at value ';
7151     text {
7152     data: ' at value ';
7153     }
7154     schema-type-info:
7155     TypeInfo ('http://www.w3.org/TR/REC-xml', 'CDATA');
7156 wakaba 1.10 specified: true;
7157 wakaba 1.9 }
7158     }
7159     }
7160     @@XMLTest:
7161     @@@QName: xp.doctype.attrtype.nmtoken.test
7162     @@@DEnt:
7163     @@@@test:value:
7164     <!DOCTYPE a [
7165     <!ATTLIST a
7166     at NMTOKEN #IMPLIED
7167     >
7168     ]>
7169     <a at=" at value "></a>
7170     @@@test:domTree:
7171     document {
7172     xml-version: '1.0';
7173     xml-encoding: null;
7174     xml-standalone: false;
7175     document-type { }
7176     element {
7177     namespace-uri: null;
7178     local-name: 'a';
7179     attribute {
7180     namespace-uri: null;
7181     local-name: 'at';
7182     value: 'at value';
7183     text {
7184     data: ' at value ';
7185     }
7186     schema-type-info:
7187     TypeInfo ('http://www.w3.org/TR/REC-xml', 'NMTOKEN');
7188 wakaba 1.10 specified: true;
7189 wakaba 1.9 }
7190     }
7191     }
7192    
7193     @@XMLTest:
7194     @@@QName: xp.doctype.attr.normalization.1.test
7195     @@@DEnt:
7196     @@@@test:value:
7197     <a at=" at &#xA;value "></a>
7198     @@@test:domTree:
7199     document {
7200     element {
7201     attribute {
7202 wakaba 1.10 node-name: 'at';
7203 wakaba 1.9 value: ' at ' U+000A 'value ';
7204     schema-type-info: TypeInfo (null, null);
7205 wakaba 1.10 specified: true;
7206 wakaba 1.9 }
7207     }
7208     }
7209     @@XMLTest:
7210     @@@QName: xp.doctype.attr.normalization.2.test
7211     @@@DEnt:
7212     @@@@test:value:
7213     <a at=" at &#xD;value "></a>
7214     @@@test:domTree:
7215     document {
7216     element {
7217     attribute {
7218     value: ' at ' U+000D 'value ';
7219     schema-type-info: TypeInfo (null, null);
7220 wakaba 1.10 specified: true;
7221 wakaba 1.9 }
7222     }
7223     }
7224     @@XMLTest:
7225     @@@QName: xp.doctype.attr.normalization.3.test
7226     @@@DEnt:
7227     @@@@test:value:
7228     <a at=" at &#x9;value "></a>
7229     @@@test:domTree:
7230     document {
7231     element {
7232     attribute {
7233 wakaba 1.10 node-name: 'at';
7234 wakaba 1.9 value: ' at ' U+0009 'value ';
7235     schema-type-info: TypeInfo (null, null);
7236 wakaba 1.10 specified: true;
7237     }
7238     }
7239     }
7240    
7241     @@XMLTest:
7242     @@@QName: xp.doctype.attr.specified.1.test
7243     @@@DEnt:
7244     @@@@test:value:
7245     <!DOCTYPE a [
7246     <!ATTLIST a
7247     at CDATA "default"
7248     >
7249     ]>
7250     <a></a>
7251     @@@test:domTree:
7252     document {
7253     document-type { }
7254     element {
7255     attribute {
7256     node-name: 'at';
7257     value: 'default';
7258     specified: false;
7259     }
7260     }
7261     }
7262     @@XMLTest:
7263     @@@QName: xp.doctype.attr.specified.2.test
7264     @@@DEnt:
7265     @@@@test:value:
7266     <!DOCTYPE a [
7267     <!ATTLIST a
7268     at CDATA "default"
7269     >
7270     ]>
7271     <a at2="specified"></a>
7272     @@@test:domTree:
7273     document {
7274     document-type { }
7275     element {
7276     attribute {
7277     node-name: 'at';
7278     value: 'default';
7279     specified: false;
7280     }
7281     attribute {
7282     node-name: 'at2';
7283     value: 'specified';
7284     specified: true;
7285     }
7286     }
7287     }
7288     @@XMLTest:
7289     @@@QName: xp.doctype.attr.specified.3.test
7290     @@@DEnt:
7291     @@@@test:value:
7292     <!DOCTYPE a [
7293     <!ATTLIST a
7294     at CDATA "default"
7295     >
7296     ]>
7297     <a at="specified"></a>
7298     @@@test:domTree:
7299     document {
7300     document-type { }
7301     element {
7302     attribute {
7303     node-name: 'at';
7304     value: 'specified';
7305     specified: true;
7306 wakaba 1.11 }
7307     }
7308     }
7309    
7310     @@XMLTest:
7311     @@@QName: xp.attr.literal.charref.test
7312     @@@DEnt:
7313     @@@@test:value:
7314     <a at1 = "value&#33;_&#x25;value"
7315     at2 = 'value&#x25;_&#33;value'></a>
7316     @@@test:domTree:
7317     document {
7318     element {
7319     attribute {
7320     node-name: 'at1';
7321     text-content: 'value!_%value';
7322     }
7323     attribute {
7324     node-name: 'at2';
7325     text-content: 'value%_!value';
7326     }
7327     }
7328     }
7329     @@XMLTest:
7330     @@@QName: xp.attr.literal.entref.test
7331     @@@DEnt:
7332     @@@@test:value:
7333     <!DOCTYPE a [
7334     <!ENTITY ent "entity&#x26;#33;_&#x26;#x29;value">
7335     ]>
7336     <a at1 = "value&ent;value"
7337     at2 = 'value&ent;value'></a>
7338     @@@test:domTree:
7339     document {
7340     document-type {
7341     general-entity {
7342     node-name: 'ent';
7343     text-content: 'entity!_)value';
7344     }
7345     }
7346     element {
7347     attribute {
7348     node-name: 'at1';
7349     text-content: 'valueentity!_)valuevalue';
7350     }
7351     attribute {
7352     node-name: 'at2';
7353     text-content: 'valueentity!_)valuevalue';
7354     }
7355     }
7356     }
7357     @@XMLTest:
7358     @@@QName: xp.attr.literal.entref.nest.test
7359     @@@DEnt:
7360     @@@@test:value:
7361     <!DOCTYPE a [
7362     <!ENTITY ent1 "entity&#x26;#33;_&#x26;#x29;value">
7363     <!ENTITY ent2 "@&ent1;@">
7364     ]>
7365     <a at1 = "value&ent2;value"
7366     at2 = 'value&ent2;value'></a>
7367     @@@test:domTree:
7368     document {
7369     document-type {
7370     general-entity {
7371     node-name: 'ent1';
7372     text-content: 'entity!_)value';
7373     }
7374     general-entity {
7375     node-name: 'ent2';
7376     text-content: '@entity!_)value@';
7377     }
7378     }
7379     element {
7380     attribute {
7381     node-name: 'at1';
7382     text-content: 'value@entity!_)value@value';
7383     }
7384     attribute {
7385     node-name: 'at2';
7386     text-content: 'value@entity!_)value@value';
7387 wakaba 1.9 }
7388 wakaba 1.6 }
7389     }
7390    
7391 wakaba 1.5 @@PerlDef:
7392     my $impl = $Message::DOM::ImplementationRegistry->get_implementation ({
7393     'Core' => '3.0',
7394     'XML' => '3.0',
7395     'XMLVersion' => ['1.0', '1.1'],
7396     });
7397     my $parser = <Class::ManakaiXMLParser>->new ($impl);
7398    
7399     for my $test_data (@$TestData) {
7400     $test->start_new_test ($test_data->{uri});
7401     my $doc_ent = $test_data->{entity}->{$test_data->{root_uri}};
7402 wakaba 1.14 my $not_ok;
7403 wakaba 1.12
7404     $parser->dom_config->set_parameter ('error-handler' => sub ($$) {
7405     my (undef, $err) = @_;
7406     my $err_type = $err->type;
7407     if ($test_data->{dom_error}->{$err_type}) {
7408     $test->assert_error_equals
7409     (actual_value => $err,
7410 wakaba 1.15 expected_hash => shift @{$test_data->{dom_error}
7411     ->{$err_type}});
7412 wakaba 1.12 } else { # Uncatched error
7413     warn $err;
7414 wakaba 1.14 unless ($err->severity == <C::c|DOMError.SEVERITY_WARNING>) {
7415     $test->failure_comment ('Unexpected error |'.$err->type.'|');
7416     $not_ok = true;
7417     }
7418 wakaba 1.12 }
7419     return true; # continue as far as possible
7420     });
7421    
7422     if ($test_data->{dom_tree}) { # Successful test
7423     try {
7424     my $doc = $parser->parse_string ($doc_ent->{<H::test:value>});
7425     $test->assert_dom_tree_equals
7426     (actual_value => $doc,
7427     expected_hash => $test_data->{dom_tree});
7428     for (values %{$test_data->{dom_error}||{}}) {
7429     if (@$_) {
7430     $test->failure_comment
7431     (@$_.' |DOMError|s of type |'.
7432 wakaba 1.13 $_->[0]->{type}->{value}.'| are not reported');
7433 wakaba 1.14 $not_ok = true;
7434 wakaba 1.12 }
7435     }
7436 wakaba 1.14 $not_ok ? $test->not_ok : $test->ok;
7437 wakaba 1.12 } catch Message::Util::IF::DTException with {
7438     #
7439     } catch Message::DOM::IF::LSException with {
7440 wakaba 1.14 # not_ok
7441     } otherwise {
7442     my $err = shift;
7443     warn $err;
7444     $test->not_ok;
7445 wakaba 1.12 };
7446     } else {
7447     try {
7448     my $doc = $parser->parse_string ($doc_ent->{<H::test:value>});
7449     } catch Message::Util::IF::DTException with {
7450     #
7451     } catch Message::DOM::IF::LSException with {
7452     #
7453 wakaba 1.14 } otherwise {
7454     my $err = shift;
7455     warn $err;
7456     $test->not_ok;
7457 wakaba 1.12 };
7458     for (values %{$test_data->{dom_error}||{}}) {
7459     if (@$_) {
7460     $test->failure_comment
7461     (@$_.' |DOMError|s of type |'.
7462 wakaba 1.13 $_->[0]->{type}->{value}.'| are not reported');
7463 wakaba 1.14 $not_ok = true;
7464 wakaba 1.12 }
7465     }
7466 wakaba 1.14 $not_ok ? $test->not_ok : $test->ok;
7467 wakaba 1.12 }
7468 wakaba 1.5 }
7469 wakaba 1.6
7470     @ResourceDef:
7471     @@QName: getCopyOfEntityState
7472     @@rdf:type: DISPerl|InlineCode
7473     @@ForCheck: ManakaiDOM|ForClass
7474     @@PerlDef:
7475     {%{$self->{$entity_type}->{$entity_name}},
7476     line => 1, column => 1, pos => 0}
7477 wakaba 1.1 ##ManakaiXMLParser
7478 wakaba 1.5
7479     ElementTypeBinding:
7480     @Name: XMLTests
7481     @ElementType:
7482     dis:ResourceDef
7483     @ShadowContent:
7484     @@ForCheck: ManakaiDOM|ForClass
7485     @@rdf:type: test|ParserTestSet
7486    
7487     ElementTypeBinding:
7488     @Name: XMLTest
7489     @ElementType:
7490     dis:ResourceDef
7491     @ShadowContent:
7492     @@ForCheck: ManakaiDOM|ForClass
7493     @@rdf:type: test|ParserTest
7494    
7495     ElementTypeBinding:
7496     @Name: DEnt
7497     @ElementType:
7498     dis:ResourceDef
7499     @ShadowContent:
7500     @@rdf:type: test|RootEntity
7501    
7502     ElementTypeBinding:
7503     @Name: Ent
7504     @ElementType:
7505     dis:ResourceDef
7506     @ShadowContent:
7507     @@rdf:type: test|Entity
7508 wakaba 1.1
7509 wakaba 1.3 ResourceDef:
7510     @QName: xp|get-location-from-token
7511     @rdf:type: DISPerl|BlockCode
7512     @enDesc:
7513     Creates a <IF::DOMCore:DOMLocator> object from a token.
7514     @PerlDef:
7515 wakaba 1.14 my $__d = $token->{type} ne '#EOF'
7516     ? $token->{location}->{char_d}
7517     : 0;
7518 wakaba 1.15 $__d -= $token->{location_d} if $token->{location_d};
7519 wakaba 1.3 $result = {
7520 wakaba 1.14 utf32_offset => $token->{location}->{pos} - $__d,
7521     line_number => $token->{location}->{line},
7522     column_number => $token->{location}->{column} - $__d,
7523 wakaba 1.3 };
7524 wakaba 1.14 $result->{utf32_offset} = 0 if $result->{utf32_offset} < 0;
7525     $result->{column_number} = 0 if $result->{column_number} < 0;
7526     ## 0 or 1, which should be?
7527 wakaba 1.3 @For: ManakaiDOM|ManakaiDOM3
7528 wakaba 1.1
7529     ElementTypeBinding:
7530     @Name: RuleDef
7531     @ElementType:
7532     dis:ResourceDef
7533     @ShadowContent:
7534     @@ForCheck: ManakaiDOM|ForClass
7535     @@rdf:type: Muf2003|RuleDefClass
7536    
7537     ElementTypeBinding:
7538     @Name: RuleParam
7539     @ElementType:
7540     dis:ResourceDef
7541     @ShadowContent:
7542     @@rdf:type: Muf2003|RuleParameter
7543    
7544     ElementTypeBinding:
7545     @Name: enImplNote
7546     @ElementType:
7547     dis:ImplNote
7548     @ShadowContent:
7549     @@lang:en
7550    
7551     ElementTypeBinding:
7552     @Name: ErrDef
7553     @ElementType:
7554     dis:ResourceDef
7555     @ShadowContent:
7556     @@rdf:type: DOMCore|DOMErrorType
7557     @@For: ManakaiDOM|DOM3
7558     @@ecore:textFormatter: ManakaiXMLParserExceptionFormatter
7559    
7560 wakaba 1.3 ElementTypeBinding:
7561     @Name: WFErrDef
7562     @ElementType:
7563     dis:ResourceDef
7564     @ShadowContent:
7565     @@rdf:type: DOMCore|DOMErrorType
7566     @@For: ManakaiDOM|DOM3
7567     @@ecore:textFormatter: ManakaiXMLParserExceptionFormatter
7568    
7569 wakaba 1.16 ElementTypeBinding:
7570     @Name: FatalErrDef
7571     @ElementType:
7572     dis:ResourceDef
7573     @ShadowContent:
7574     @@rdf:type: DOMCore|DOMErrorType
7575     @@For: ManakaiDOM|DOM3
7576     @@ecore:textFormatter: ManakaiXMLParserExceptionFormatter
7577    
7578 wakaba 1.3 WFErrDef:
7579     @QName: xp|wf-syntax-error
7580     @enDesc:
7581     The entity does not match to the production rule; it is not
7582     well-formed.
7583     @DOMCore:severity: DOMCore|SEVERITY_FATAL_ERROR
7584     @enMufDef:
7585     |%xp-error-token-type;|%xp-error-token-value
7586     (prefix => { (|}, suffix => {|)}); is not
7587     allowed%xp-error-lines (prefix => { (|}, suffix => {|)});
7588     @ecore:hasParameter:
7589     @@@: xp|error-token
7590     @@enDesc:
7591     The token that is not allowed.
7592    
7593     WFErrDef:
7594     @QName: xp|wf-pi-target-is-xml
7595     @enDesc:
7596     A processing instruction has its <CODE::PITarget> of
7597     <XML::xml> (in any case) which is not allowed.
7598     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7599     @enMufDef:
7600     Processing instruction target name cannot be |%p
7601     (name => {<Q::xp|name>});|
7602     @ecore:hasParameter:
7603     @@@: xp|error-token
7604     @@enDesc:
7605     The token that contains the name.
7606     @ecore:hasParameter:
7607     @@@: xp|name
7608     @@enDesc:
7609     A string that is specified as target name of the
7610     processing instruction.
7611     @ecore:hasParameter: xp|parent
7612    
7613     WFErrDef:
7614     @QName: xp|wf-no-end-tag
7615     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7616     @enDesc:
7617     An end-tag is not found.
7618     @enMufDef:
7619     End-tag |</%p (name => {<Q::xp|expected-element-type>});>| is required
7620     @ecore:hasParameter: xp|error-token
7621     @ecore:hasParameter:
7622     @@@: xp|node
7623     @@enDesc:
7624     The element node that is not closed.
7625     @ecore:hasParameter:
7626     @@@: xp|expected-element-type
7627     @@enDesc:
7628     The element type name of the element that is not closed.
7629    
7630     WFErrDef:
7631     @QName: xp|wf-unsupported-xml-version
7632     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7633     @enDesc:
7634     The XML version specified in the version declaration is not supported.
7635     @enMufDef:
7636     XML version |%p (name => {<Q::infoset|version>});| is not supported
7637     @ecore:hasParameter: xp|bad-token
7638     @ecore:hasParameter:
7639     @@@: xp|parent
7640     @@enDesc:
7641     The document node.
7642     @ecore:hasParameter:
7643     @@@: infoset|version
7644     @@enDesc:
7645     The specified XML version.
7646    
7647     WFErrDef:
7648     @QName: xp|wf-malformed-enc-name
7649     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7650     @enDesc:
7651     An <XA::encoding> pseudo-attribute value does not match
7652     to the procduction rule <CODE::EncName>.
7653     @enMufDef:
7654     Encoding name |%p (name => {<Q::xp|name>});| is not allowed
7655     @ecore:hasParameter: xp|error-token
7656     @ecore:hasParameter:
7657     @@@: xp|parent
7658     @@enDesc: The document node.
7659     @ecore:hasParameter:
7660     @@@: xp|name
7661     @@enDesc:
7662     The <XA::encoding> value.
7663    
7664     WFErrDef:
7665     @QName: xp|wf-malformed-xml-standalone
7666     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7667     @enDesc:
7668     An <XA::standalone> pseudo-attribute value is neither <XML::yes>
7669     or <XML::no>.
7670     @enMufDef:
7671     |standalone| pseudo-attribute value |%p (name => {<Q::xp|name>});|
7672     is not allowed
7673     @ecore:hasParameter: xp|error-token
7674     @ecore:hasParameter:
7675     @@@: xp|parent
7676     @@enDesc: The document node.
7677     @ecore:hasParameter:
7678     @@@: xp|name
7679     @@enDesc:
7680     The <XA::standalone> value.
7681    
7682     WFErrDef:
7683     @QName: xp|wf-legal-literal-character
7684     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7685     @enDesc:
7686     Each character in XML entity must match to the production
7687     rule <CODE::Char - RestrictedChar>.
7688     @enMufDef:
7689     Character %character-code-point
7690     (v => {<Q::xp|character-number>}); is not allowed
7691     @ecore:hasParameter:
7692     @@@: xp|character-number
7693     @@enDesc:
7694     The code position of the character being referred.
7695    
7696     WFErrDef:
7697     @QName: xp|wf-element-type-match
7698     @DOMCore:severity: DOMCore|SEVERITY_FATAL_ERROR
7699 wakaba 1.1 @enDesc:
7700 wakaba 1.3 The <CODE::Name> in an element's end-tag must match the element type
7701     in the start-tag.
7702     @enMufDef:
7703     End-tag |</%p (name => {<Q::xp|actual-element-type>});>| does
7704     not match to start-tag |<%p (name => {<Q::xp|expected-element-type>});>|
7705     @ecore:hasParameter: xp|error-token
7706     @ecore:hasParameter:
7707     @@@: xp|node
7708     @@enDesc:
7709     The current opening element node.
7710     @ecore:hasParameter:
7711     @@@: xp|expected-element-type
7712     @@enDesc:
7713     The element type name of the current element.
7714     @ecore:hasParameter:
7715     @@@: xp|actual-element-type
7716     @@enDesc:
7717     The <CODE::Name> occurs in the end-tag.
7718    
7719     WFErrDef:
7720     @QName: xp|wf-unique-att-spec
7721 wakaba 1.1 @DOMCore:severity: DOMCore|SEVERITY_ERROR
7722 wakaba 1.3 @enDesc:
7723     An attribute name <kwd:MUST-NOT> appear more than once in
7724     the same start-tag or empty-element tag.
7725 wakaba 1.1 @enMufDef:
7726 wakaba 1.3 Attribute |%p (name => {<Q::xp|name>});| is specified more
7727     than once in the same tag
7728     @ecore:hasParameter: xp|error-token
7729     @ecore:hasParameter:
7730     @@@: xp|name
7731     @@enDesc:
7732     The name of the attribute.
7733    
7734     WFErrDef:
7735     @QName: xp|wf-legal-character
7736     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7737     @enDesc:
7738     Characters referred to using character references <kwd:MUST>
7739     match the production for <CODE::Char>.
7740     @enMufDef:
7741     Reference to character %character-code-point
7742     (v => {<Q::xp|character-number>}); is not allowed
7743     @ecore:hasParameter: xp|error-token
7744     @ecore:hasParameter:
7745     @@@: xp|character-number
7746     @@enDesc:
7747     The code position of the character being referred.
7748     @ecore:hasParameter:
7749     @@@: xp|parent
7750     @@enDesc:
7751     The parent node in which the character reference has
7752     occurred, if available.
7753 wakaba 1.16
7754     FatalErrDef:
7755     @QName: xp|fatal-xml11-end-of-line-in-xml-declaration
7756     @DOMCore:severity: DOMCore|SEVERITY_ERROR
7757     @enDesc:
7758     An end-of-line character <CODE::U+0085> or <CODE::U+2028> is appeared
7759     within an XML declaration or text declaration.
7760     @enMufDef:
7761     End-of-line character %character-code-point
7762     (v => {<Q::xp|character-number>}); cannot be used within the
7763     XML or text declaration
7764     @ecore:hasParameter:
7765     @@@: xp|character-number
7766     @@enDesc:
7767     The code position of the end-of-line character.
7768 wakaba 1.1
7769 wakaba 1.3 XWParam:
7770 wakaba 1.1 @QName: xp|error-token
7771     @enDesc:
7772     The token where the parser found an error.
7773    
7774 wakaba 1.3 XWParam:
7775     @QName: xp|name
7776     @enDesc:
7777     A name.
7778    
7779     XWParam:
7780     @QName: xp|parent
7781     @enDesc:
7782     The parent node in which the error occurs.
7783    
7784     XWParam:
7785     @QName: xp|node
7786     @enDesc:
7787     The current node.
7788    
7789     XWParam:
7790     @QName: xp|actual-element-type
7791     @enDesc:
7792     The actual element type name occured in the source.
7793    
7794     XWParam:
7795     @QName: xp|expected-element-type
7796 wakaba 1.1 @enDesc:
7797 wakaba 1.3 The element type name expected.
7798    
7799     XWParam:
7800     @QName: xp|character-number
7801     @enDesc:
7802     The character code position.
7803    
7804     ElementTypeBinding:
7805     @Name: XWParam
7806     @ElementType:
7807     dis:ResourceDef
7808     @ShadowContent:
7809     @@For: =ManakaiDOM|all
7810     @@rdf:type: ecore|Parameter
7811 wakaba 1.1
7812     ElementTypeBinding:
7813     @Name:enMufDef
7814     @ElementType:
7815     ecore:defaultMessage
7816     @ShadowContent:
7817     @@lang:en
7818     @@ContentType:
7819     lang:muf
7820    
7821     ResourceDef:
7822     @QName: DOMImpl
7823     @AliasFor: DOMCore|DOMImplementation
7824     @For: ManakaiDOM|DOM
7825    
7826     ElementTypeBinding:
7827     @Name: Attr
7828     @ElementType:
7829     dis:ResourceDef
7830     @ShadowContent:
7831     @@rdf:type: DISLang|Attribute
7832     @@ForCheck: !=ManakaiDOM|ManakaiDOM
7833    
7834     ElementTypeBinding:
7835     @Name: Get
7836     @ElementType:
7837     dis:ResourceDef
7838     @ShadowContent:
7839     @@rdf:type: DISLang|AttributeGet
7840    
7841     ElementTypeBinding:
7842     @Name: Set
7843     @ElementType:
7844     dis:ResourceDef
7845     @ShadowContent:
7846     @@rdf:type: DISLang|AttributeSet
7847    
7848     ElementTypeBinding:
7849     @Name: enDesc
7850     @ElementType:
7851     dis:Description
7852     @ShadowContent:
7853     @@lang:en
7854    
7855     ElementTypeBinding:
7856     @Name: Method
7857     @ElementType:
7858     dis:ResourceDef
7859     @ShadowContent:
7860     @@rdf:type: DISLang|Method
7861     @@For: !=ManakaiDOM|ManakaiDOM
7862    
7863     ElementTypeBinding:
7864     @Name: Return
7865     @ElementType:
7866     dis:ResourceDef
7867     @ShadowContent:
7868     @@rdf:type: DISLang|MethodReturn
7869    
7870     ElementTypeBinding:
7871     @Name: Param
7872     @ElementType:
7873     dis:ResourceDef
7874     @ShadowContent:
7875     @@rdf:type: DISLang|MethodParameter
7876    
7877     ElementTypeBinding:
7878     @Name: PerlDef
7879     @ElementType:
7880     dis:Def
7881     @ShadowContent:
7882     @@ContentType: lang|Perl
7883    
7884     ElementTypeBinding:
7885     @Name: PropDef
7886     @ElementType:
7887     dis:ResourceDef
7888     @ShadowContent:
7889     @@rdf:type: rdf|Property
7890    
7891     ClsDef:
7892     @ClsQName: ManakaiXMLParserExceptionFormatter
7893    
7894     @ClsISA: ecore|MUErrorFormatter||ManakaiDOM|Perl
7895    
7896     @RuleDef:
7897     @@Name: xp-error-token-type
7898     @@enDesc:
7899     The type of the token the parser is encountered.
7900    
7901     @@Method:
7902     @@@Name: after
7903     @@@Param:
7904     @@@@Name: name
7905     @@@@Type: DOMString
7906     @@@@enDesc: The name of the method.
7907     @@@Param:
7908     @@@@Name: p
7909     @@@@Type: DISPerl|HASH
7910     @@@@enDesc: The set of the parameters to the method.
7911     @@@Param:
7912     @@@@Name: o
7913     @@@@Type: DISPerl|HASH
7914     @@@@enDesc: The option value.
7915     @@@Return:
7916     @@@@PerlDef:
7917     $p->{-result} = $o->{<H::xp|error-token>}->{type}
7918     if defined $o->{<H::xp|error-token>}->{type};
7919    
7920     @RuleDef:
7921     @@Name: xp-error-token-value
7922     @@enDesc:
7923     The value of the token the parser is encountered, if any.
7924    
7925     @@Method:
7926     @@@Name: after
7927     @@@Param:
7928     @@@@Name: name
7929     @@@@Type: DOMString
7930     @@@@enDesc: The name of the method.
7931     @@@Param:
7932     @@@@Name: p
7933     @@@@Type: DISPerl|HASH
7934     @@@@enDesc: The set of the parameters to the method.
7935     @@@Param:
7936     @@@@Name: o
7937     @@@@Type: DISPerl|HASH
7938     @@@@enDesc: The option value.
7939     @@@Return:
7940     @@@@PerlDef:
7941     $p->{-result} = $o->{<H::xp|error-token>}->{value}
7942     if defined $o->{<H::xp|error-token>}->{value};
7943    
7944     @RuleDef:
7945     @@Name: xp-error-lines
7946     @@enDesc:
7947     A copy of fragment of the source text that contains the line
7948     where the error occurred, if available.
7949    
7950     @@Method:
7951     @@@Name: after
7952     @@@Param:
7953     @@@@Name: name
7954     @@@@Type: DOMString
7955     @@@@enDesc: The name of the method.
7956     @@@Param:
7957     @@@@Name: p
7958     @@@@Type: DISPerl|HASH
7959     @@@@enDesc: The set of the parameters to the method.
7960     @@@Param:
7961     @@@@Name: o
7962     @@@@Type: DISPerl|HASH
7963     @@@@enDesc: The option value.
7964     @@@Return:
7965     @@@@PerlDef:
7966     my $pos = $o-><AG::DOMCore|DOMError.location>
7967     -><AG::DOMCore|DOMLocator.utf32Offset>;
7968     if ($pos > -1) {
7969 wakaba 1.6 my $src = $o->{<H::ecore|object>}->{entity}->[-1]->{reptxt};
7970 wakaba 1.1 my $start = $pos;
7971     $start = rindex ($$src, "\x0A", $start - 1) for 0..2;
7972     $start++;
7973     my $end = $pos;
7974     $end = index ($$src, "\x0A", $end + 1) for 0..2;
7975     $end = length $$src if $end < 0;
7976     $p->{-result} = substr $$src, $start, $end - $start;
7977     }
7978 wakaba 1.3
7979     @RuleDef:
7980     @@Name: character-code-point
7981     @@enDesc:
7982     The character code position, in <CODE::U+<VAR::HHHH>> notation.
7983    
7984     @@Method:
7985     @@@Name: after
7986     @@@Param:
7987     @@@@Name: name
7988     @@@@Type: DOMString
7989     @@@@enDesc: The name of the method.
7990     @@@Param:
7991     @@@@Name: p
7992     @@@@Type: DISPerl|HASH
7993     @@@@enDesc: The set of the parameters to the method.
7994     @@@Param:
7995     @@@@Name: o
7996     @@@@Type: DISPerl|HASH
7997     @@@@enDesc: The option value.
7998     @@@RuleParam:
7999     @@@@Name: v
8000     @@@@Type: DISPerl|Number
8001     @@@@enDesc:
8002     The name of the error parameter that contains the character code.
8003     @@@Return:
8004     @@@@PerlDef:
8005     $p->{-result} = sprintf 'U+%04X', $o->{$p->{v}};
8006 wakaba 1.1 ##XMLParserExceptionFormatter

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24