/[suikacvs]/messaging/manakai/lib/Message/Util/DIS.dis
Suika

Contents of /messaging/manakai/lib/Message/Util/DIS.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download)
Sat Apr 2 07:43:15 2005 UTC (20 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.15: +111 -50 lines
PerlCode clone methods implemented

1 wakaba 1.1 Module:
2     @QName:
3     Util:DIS
4     @FullName:
5     @@lang: en
6     @@@:
7     <QUOTE::DIS> Object Model
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
10    
11     @Description:
12     @@lang:en
13     @@@:
14 wakaba 1.14 This module provides an object model for <QUOTE::dis> document format.
15 wakaba 1.1
16     @Author:
17     @@FullName: Wakaba
18     @@Mail: w@suika.fam.cx
19     @License:
20     @@@:
21     license:Perl+MPL
22     @@Original:
23     @@@FullName:
24     manakai <CODE::lib/manakai/dis.pl>
25     @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.16 $Date: 2005/04/01 07:58:46 $
32 wakaba 1.1 @@ContentType:
33     dis:Date.RCS
34    
35     @Require:
36     @@Module:
37     @@@Name: SuikaWikiConfig21
38 wakaba 1.5 @@@QName:
39     Markup:SuikaWikiConfig21
40 wakaba 1.1 @@@WithFor:
41 wakaba 1.3 swcfg21:ForLatest
42     @@Module:
43     @@@Name: DIS
44     @@@WithFor:
45     DIS:ForLatest
46 wakaba 1.12 @@Module:
47     @@@Name: PerlCode
48     @@@WithFor:
49     ManakaiDOM:Perl
50 wakaba 1.3
51     @DefaultFor:
52     DIS:ForLatest
53 wakaba 1.1
54     Namespace:
55     @DIS:
56     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
57     @dis:
58     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
59     @dis2pm:
60     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
61 wakaba 1.5 @DISlib:
62     http://suika.fam.cx/~wakaba/archive/2004/dis/
63 wakaba 1.13 @disPerl:
64     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--Perl--
65 wakaba 1.3 @DOMCore:
66     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
67     @DOMLS:
68     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
69     @DOMMain:
70     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
71     @infoset:
72     http://www.w3.org/2001/04/infoset#
73 wakaba 1.1 @lang:
74     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
75     @license:
76     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
77     @ManakaiDOM:
78     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
79 wakaba 1.5 @Markup:
80     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
81 wakaba 1.3 @MDOMX:
82     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
83 wakaba 1.1 @owl:
84     http://www.w3.org/2002/07/owl#
85     @Perl:
86     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
87     @rdf:
88     http://www.w3.org/1999/02/22-rdf-syntax-ns#
89     @rdfs:
90     http://www.w3.org/2000/01/rdf-schema#
91 wakaba 1.3 @swcfg21:
92     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
93 wakaba 1.1 @TreeCore:\
94     @Util:
95     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
96    
97     ## -- "For" definitions
98    
99     ForDef:
100     @QName:
101     DIS:ForLatest
102     @Description:
103     @@lang:en
104     @@@:
105     For latest version of the <Module::Util:DIS> module implementation
106     @ISA:
107     ManakaiDOM:Perl
108    
109     ## -- Features
110    
111     ElementTypeBinding:
112     @Name: FeatureDef
113     @ElementType:
114     dis:ResourceDef
115     @ShadowContent:
116     @@rdf:type:
117     DOMMain:DOMFeature
118     @@AliasFor:
119     @@@@:
120     ::ManakaiDOM:all
121     @@@For:
122     !=ManakaiDOM:all
123    
124     ElementTypeBinding:
125     @Name: FeatureVerDef
126     @ElementType:
127     dis:ResourceDef
128     @ShadowContent:
129     @@rdf:type:
130     DOMMain:DOMFeature
131    
132     ElementTypeBinding:
133     @Name: featureQName
134     @ElementType:
135     dis:AppName
136     @ShadowContent:
137     @@ContentType:
138     dis:TypeQName
139    
140     FeatureDef:
141     @QName: Core
142     @FeatureVerDef:
143     @@QName: CoreFeature10
144     @@Version: 1.0
145     @@ISA: Core
146     @@FullName:
147     @@@lang:en
148     @@@@:
149     The <QUOTE::dis> object model, version 1.0
150     @@Description:
151     @@@lang:en
152     @@@@:
153     The <QUOTE::dis> object model, version 1.0.
154     @@DOMMain:requireFeature:
155     swcfg21:CoreFeature21
156    
157     ## -- SuikaWikiConfig/2.1 extended classes
158    
159     ClsDef:
160     @ClsQName: ManakaiDISImplementation
161     @ClsISA:
162 wakaba 1.3 swcfg21:ManakaiSWCFGImplementation::swcfg21:ForLatest
163 wakaba 1.1 @Description:
164     @@lang:en
165     @@@:
166     A <QUOTE::dis> implementation object.
167    
168     @Method:
169     @@Name: createDISDocument
170     @@Description:
171     @@@lang:en
172     @@@@:
173     Creates an empty <Class::ManakaiDISDocument> object.
174     @@Return:
175     @@@Type:ManakaiDISDocument
176     @@@Description:
177     @@@@lang:en
178     @@@@@:
179     The newly created <QUOTE::dis> document object.
180     @@@PerlDef:
181 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
182     .createSWCFGDocument>;
183     $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
184     .defaultElementTypeNamespaceURI>
185 wakaba 1.1 (<Q::dis:>);
186    
187     @Method:
188 wakaba 1.2 @@Name: createDISParser
189     @@Description:
190     @@@lang:en
191     @@@@:
192 wakaba 1.1 Creates a <Class::ManakaiDISParser> object.
193 wakaba 1.2 @@Return:
194     @@@Type: ManakaiDISParser
195     @@@Description:
196     @@@@lang:en
197     @@@@@:
198 wakaba 1.1 A newly created <QUOTE::dis> parser.
199 wakaba 1.2 @@@PerlDef:
200 wakaba 1.3 $r = bless $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
201     .createSWCFGParser>,
202 wakaba 1.1 <ClassName::ManakaiDISParser>;
203    
204     @Method:
205 wakaba 1.2 @@Name: createDISDatabase
206 wakaba 1.1 @@Description:
207     @@@lang:en
208     @@@@:
209 wakaba 1.2 Creates a new <QUOTE::dis> database.
210 wakaba 1.1 @@Return:
211 wakaba 1.2 @@@Type:ManakaiDISDatabase
212 wakaba 1.4 @@@Description:
213     @@@@lang:en
214     @@@@@:
215 wakaba 1.2 A newly created <QUOTE::dis> parser.
216 wakaba 1.4 @@@PerlDef:
217 wakaba 1.2 $r = bless {
218     forDef => {
219 wakaba 1.5 <Q::ManakaiDOM:all> => bless ({
220 wakaba 1.2 uri => <Q::ManakaiDOM:all>,
221     isa => {<Q::ManakaiDOM:all> => 1},
222     revISA => {},
223 wakaba 1.5 }, <ClassName::ManakaiDISForDefinition>),
224 wakaba 1.2 },
225     resDef => {},
226 wakaba 1.9 modDef => {},
227     seq => 0,
228 wakaba 1.3 }, <ClassName::ManakaiDISDatabase>;
229    
230     @Method:
231     @@Name: tfurisToURI
232     @@Description:
233     @@@lang:en
234     @@@@:
235     Converts a pair of name URI reference and <QUOTE::for> URI reference
236     into a <TYPE::dis:TFQNames>-expanded URI reference.
237     @@Param:
238     @@@Name: typeURI
239     @@@Type: NameURI
240     @@@Description:
241     @@@@lang:en
242     @@@@@:
243     A URI reference to identify a resource.
244     @@@InCase:
245     @@@@Value:
246     @@@@@is-null:1
247     @@@@Description:
248     @@@@@lang:en
249     @@@@@@:
250     Equivalent to <Q::DOMMain:any> (for historical reason).
251     @@Param:
252     @@@Name: forURI
253     @@@Type: ForURI
254     @@@Description:
255     @@@@lang:en
256     @@@@@:
257     A <QUOTE::for> URI reference.
258     @@@InCase:
259     @@@@Value:
260     @@@@@is-null:1
261     @@@@Description:
262     @@@@@lang:en
263     @@@@@@:
264     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
265     @@Return:
266     @@@Type:
267     DISCore:TFURI::ManakaiDOM:all
268     @@@Description:
269     @@@@lang:en
270     @@@@@:
271     The <TYPE::dis:TFQNames>-expanded URI references.
272     @@@PerlDef:
273     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
274     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
275 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
276    
277     @ResourceDef:
278     @@QName: tfurisToURI
279     @@rdf:type:
280     dis2pm:BlockCode
281     @@enDesc:
282     Converts a pair of name URI reference and <QUOTE::for> URI reference
283     into a <TYPE::dis:TFQNames>-expanded URI reference.
284     @@PerlDef:
285     if ($furi eq <Q::ManakaiDOM:all>) {
286     $uri = $turi;
287 wakaba 1.3 } else {
288     ## NOTE: [RFC 3986]
289     ## fragment := *(pchar / "/" / "?")
290     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
291     ## unreserved := ALPHA / DIGIT / [._~-]
292     ## sub-delims := [!$&'()*+,;=]
293     ## NOTE: [XPointer Framework]
294     ## SchemeData := *EscapedData
295     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
296     ## / "(" SchemeData ")"
297     ## NormalChar := UnicodeChar - [()^]
298 wakaba 1.5 my $__turi = $turi;
299     my $__furi = $furi;
300     for my $__uri ($__turi, $__furi) {
301 wakaba 1.4 $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
302 wakaba 1.3 }
303 wakaba 1.4 $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
304 wakaba 1.5 qq<t:tf($__turi,$__furi)>;
305 wakaba 1.3 }
306 wakaba 1.2
307 wakaba 1.5 @ResourceDef:
308 wakaba 1.6 @@QName: tfpurisToURI
309     @@rdf:type:
310     dis2pm:BlockCode
311     @@enDesc:
312     Converts a set of name URI reference and <QUOTE::for> URI reference
313     and <QUOTE::for+> URI references into a URi reference.
314     @@PerlDef:
315     if ($furi eq <Q::ManakaiDOM:all> and @{$forp} == 0) {
316     $uri = $turi;
317     } elsif (@{$forp}) {
318     my $__turi = $turi;
319     my $__furi = $furi;
320     for my $__uri ($__turi, $__furi) {
321     $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
322     }
323     my @__fp;
324     for my $__uri (@{$forp}) {
325     my $__fpuri = $__uri;
326     $__fpuri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}
327     {sprintf '%%%02X', ord $1}ge;
328     push @__fp, $__fpuri;
329     }
330     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
331     qq<t:tfp($__turi,$__furi,>.join (',', @__fp).q<)>;
332     } else {
333     my $__turi = $turi;
334     my $__furi = $furi;
335     for my $__uri ($__turi, $__furi) {
336     $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
337     }
338     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
339     qq<t:tf($__turi,$__furi)>;
340     }
341    
342     @ResourceDef:
343 wakaba 1.5 @@QName: getChildResourceURI
344     @@rdf:type:
345     dis2pm:BlockCode
346     @@enDesc:
347     Gets an anonymous URI reference of a child resource of another
348     resource.
349     @@PerlDef:
350     my $__parent = $parentURI;
351     my $__ln = $localName;
352     for my $__uri ($__parent, $__ln) {
353 wakaba 1.6 $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
354 wakaba 1.5 }
355     $result = q<data:,200411tf#xmlns(t=data:,200411tf%23)>.
356     qq<t:child($__parent,$__ln)>;
357    
358 wakaba 1.8 @IntMethod:
359     @@Name: camelCaseToUnderscoreName
360     @@enDesc:
361     Converts a camelCase name to a underscored_name.
362     @@ManakaiDOM:isStatic:1
363     @@Param:
364     @@@Name: camelName
365     @@@Type:
366     DISLang:String
367     @@@enDesc:
368     The source name.
369     @@Return:
370     @@@Type:
371     DISLang:String
372     @@@enDesc:
373     The result name.
374     @@@PerlDef:
375     $r = $camelName;
376     $r =~ s/^([A-Z0-9]+)$/lc $1/ge;
377     $r =~ s/([A-Z][A-Z0-9]*)$/"_".lc $1/ge;
378     $r =~ s/([A-Z0-9])([A-Z0-9]*)([A-Z0-9])/$1.lc ($2)."_".lc $3/ge;
379     $r =~ s/([A-Z])/"_".lc $1/ge;
380     $r =~ s/(?=[0-9](?!$))/_/g;
381 wakaba 1.9
382     @Method:
383     @@Name: plLoadDISDatabase
384     @@enDesc:
385     Loads a database from a file that was saved by
386     <M::ManakaiDISDatabase.plStore>.
387     \
388     {NOTE:: <QUOTE::dis> documents restored from external file
389     would have different <A::ManakaiDISDocument.implementation>
390     than this <Class::ManakaiDISImplementation>, even if
391     it has been created by this implementation
392     and stored in the same session.
393     \
394     }
395     @@Param:
396     @@@Name:fileName
397     @@@Type:
398     DISLang:String
399     @@@enDesc:
400     An environment-dependent file name.
401     @@Return:
402     @@@Type: ManakaiDISDatabase
403     @@@SimpleException:
404     @@@PerlDef:
405     use Storable qw/retrieve/;
406     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
407     $r = retrieve $fileName;
408    
409     ## Restores weak references
410     require Scalar::Util;
411     for my $doc (values %{$r->{<Q::DIS:sourceFile>}}) {
412     Scalar::Util::weaken ($doc->{<Q::TreeCore:node>}->{<Q::DIS:db>});
413     }
414     for my $def (values %{$r->{modDef}},
415     values %{$r->{forDef}},
416     values %{$r->{resDef}}) {
417     Scalar::Util::weaken ($def->{db});
418     }
419 wakaba 1.1 ##DISImplementation
420    
421 wakaba 1.9 ElementTypeBinding:
422     @Name: SimpleException
423     @ElementType:
424     dis:Description
425     @ShadowContent:
426     @@lang:en
427     @@@:
428     - Exception of type <PerlModule::Error::Simple>:::
429     I/O error or other error reported by <PerlModule::Storable>.
430    
431     ## TODO: Formal description required for simple exception
432    
433 wakaba 1.1 ClsDef:
434     @ClsQName: ManakaiDISParser
435     @ClsISA:
436 wakaba 1.3 swcfg21:ManakaiSWCFGParser::swcfg21:ForLatest
437 wakaba 1.1 @Description:
438     @@lang:en
439     @@@:
440     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
441     @Method:
442 wakaba 1.3 @@Name: parse
443     @@Description:
444     @@@lang:en
445     @@@@:
446 wakaba 1.1 Parses a <QUOTE::dis> document and returns it as an object tree.
447 wakaba 1.3 @@Param:
448     @@@Name: input
449     @@@Type:
450     DOMLS:LSInput::ManakaiDOM:ManakaiDOM3
451     @@@Description:
452     @@@@lang:en
453     @@@@@:
454 wakaba 1.1 The input source.
455 wakaba 1.3 @@Return:
456     @@@Type: ManakaiDISDocument
457     @@@Description:
458     @@@@lang:en
459     @@@@@:
460 wakaba 1.1 The <QUOTE::dis> document object created from the <P::input>.
461     @@@RaiseException:
462     @@@@@:
463     swcfg21:SWCFG_PARSE_ERR
464     @@@@Description:
465     @@@@@lang:en
466     @@@@@@:
467     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
468     document.
469     @@@PerlDef:
470     __DEEP{
471 wakaba 1.3 $r = $self-><M::swcfg21:ManakaiSWCFGParser
472     ::swcfg21:ForLatest.parse> ($input);
473 wakaba 1.1 }__;
474     if (defined $r) {
475     $r = bless $r, <ClassName::ManakaiDISDocument>;
476 wakaba 1.4 $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
477     .defaultElementTypeNamespaceURI>
478     (<Q::dis:>);
479 wakaba 1.1 }
480     ##DISParser
481    
482     ClsDef:
483     @ClsQName: ManakaiDISNode
484     @Description:
485     @@lang:en
486     @@@:
487     <QUOTE::dis> node objects.
488 wakaba 1.7 @ImplNote:
489     @@lang:en
490     @@@:
491     This class does not inherit
492     <Class::swcfg21:ManakaiSWCFGNode::swcfg21:ForLatest>, since
493     inheriting classes such as <Class::ManakaiDISElement> indirectly
494     inherit it.
495 wakaba 1.1
496     @MethodRedef:
497     @@Name:lookupNamespacePrefix
498     @@Description:
499     @@@lang:en
500     @@@@:
501     Looks up the namespace prefix associated to the given
502     namespace URI. The default namespaces are ignored.
503     @@Param:
504     @@@Name:namespaceURI
505 wakaba 1.3 @@@Type: AnyURI
506 wakaba 1.1 @@@Description:
507     @@@@lang:en
508     @@@@@:
509     The namespace URI to look for.
510     @@@InCase:
511     @@@@Value:
512     @@@@@is-null:1
513     @@@@Description:
514     @@@@@lang:en
515     @@@@@@:
516     The <DOM::null> namespace.
517     @@NamedParam:
518     @@@Name: makeNewBinding
519     @@@Type:
520     DOMMain:boolean
521     @@@Description:
522     @@@@lang:en
523     @@@@@:
524     Whether a new namespace prefix should be bound when
525     no namespace URI has been associated yet.
526     @@@InCase:
527     @@@@Value:true
528     @@@@Description:
529     @@@@@lang:en
530     @@@@@@:
531     New binding is made if no prefix associated.
532     @@@InCase:
533     @@@@Value:false
534     @@@@Description:
535     @@@@@lang:en
536     @@@@@@:
537     Simply returns the <DOM::null> if no prefix associated.
538     @@Return:
539     @@@Type:
540 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
541 wakaba 1.1 @@@Description:
542     @@@@lang:en
543     @@@@@:
544     An associated namespace prefix. If more than one prefix
545     are associated to the namespace URI, the returned prefix
546     is implementation dependent.
547     @@@InCase:
548     @@@@Value:
549     @@@@@is-null:1
550     @@@@Description:
551     @@@@@lang:en
552     @@@@@@:
553     No associated namespace prefix found.
554     @@@PerlDef:
555     $r = null;
556 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
557     .ownerDocument> || $self;
558 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
559 wakaba 1.1 if (defined $namespaceURI) {
560     FIND: {
561     for my $prefix (keys %$binds) {
562     if (defined $binds->{$prefix} and
563     $binds->{$prefix} eq $namespaceURI) {
564     $r = $prefix;
565     last FIND;
566     }
567     }
568 wakaba 1.7
569     ## From module list
570     try {
571     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
572     -><AG::ManakaiDISDocument.disDatabase>;
573     for my $mod_uri (keys %{$db->{modDef}}) {
574     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
575     my $mod_ln = $mod-><AG::ManakaiDISModuleDefinition.localName>;
576     next if exists $binds->{$mod_ln};
577     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
578     .getPropertyText>
579     (<Q::dis:Namespace>, '');
580     if ($ns_uri eq $namespaceURI) {
581     $r = $mod_ln;
582     last FIND;
583     }
584     }
585     } catch <Class::ManakaiDISException> with {
586     my $err = shift;
587     $err->throw
588     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
589     };
590    
591 wakaba 1.1 last FIND unless $makeNewBinding;
592     ## Not found
593     if ($namespaceURI =~ /(\w+)$/) {
594     my $prefix = $1;
595     unless (exists $binds->{$prefix}) {
596     $binds->{$prefix} = $namespaceURI;
597     $r = $prefix;
598     last FIND;
599     }
600     }
601     my $i = 1;
602     {
603     unless (exists $binds->{'ns'.$i}) {
604     $binds->{$r = 'ns'.$i} = $namespaceURI;
605     last FIND;
606     }
607     $i++;
608     redo;
609     }
610     } # FIND
611     } else { ## Null namespace
612     FIND: {
613     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
614     $r = 'nu'.'ll';
615     last FIND;
616     }
617     for my $prefix (keys %$binds) {
618     if (not defined $prefix) {
619     $r = $prefix;
620     last FIND;
621     }
622     }
623     last FIND unless $makeNewBinding;
624     ## Not found
625     my $i = '';
626     {
627     unless (exists $binds->{'nu'.'ll'.$i}) {
628     $binds->{$r = 'nu'.'ll'.$i} = null;
629     last FIND;
630     }
631     $i++;
632     redo;
633     }
634     }
635     }
636    
637     @MethodRedef:
638     @@Name:lookupNamespaceURI
639     @@Description:
640     @@@lang:en
641     @@@@:
642     Looks up the namespace URI associated to the given prefix.
643     @@Param:
644     @@@Name:prefix
645     @@@Type:
646 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
647 wakaba 1.1 @@@Description:
648     @@@@lang:en
649     @@@@@:
650     The namespace URI to look for.
651     @@NamedParam:
652     @@@Name: makeNewBinding
653     @@@Type:
654     DOMMain:boolean
655     @@@Description:
656     @@@@lang:en
657     @@@@@:
658     Whether a new binding should be created if no namespace URI
659     is associated with the <P::prefix> or not.
660     @@@InCase:
661     @@@@Value:true
662     @@@@Description:
663     @@@@@lang:en
664     @@@@@@:
665     A new binding to the temporary namespace URI
666     exactly same as <P::prefix> is created
667     if no binding found.
668     @@@InCase:
669     @@@@Value:false
670     @@@@Description:
671     @@@@@lang:en
672     @@@@@@:
673     No new binding is created if no binding found. Note that
674     even if no association newly created, this method
675     returns the <DOM::null> value.
676 wakaba 1.12 @@NamedParam:
677     @@@Name: raisePrefixException
678     @@@Type:
679     DOMMain:boolean
680     @@@enDesc:
681     Whehter an exception should be thrown if <P::prefix>
682     is not declared or not.
683 wakaba 1.1 @@Return:
684 wakaba 1.3 @@@Type: AnyURI
685 wakaba 1.1 @@@Description:
686     @@@@lang:en
687     @@@@@:The associated namespace URI.
688     @@@InCase:
689     @@@@Value:
690     @@@@@is-null:1
691     @@@@Description:
692     @@@@@lang:en
693     @@@@@@:
694 wakaba 1.3 No namespace URI is associated to the prefix or
695 wakaba 1.1 the <DOM::null> namespace is associated.
696 wakaba 1.12 @@@UndeclaredPrefixException:
697 wakaba 1.1 @@@PerlDef:
698 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
699     .ownerDocument> || $self;
700 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
701 wakaba 1.1 if (exists $binds->{$prefix}) {
702     $r = $binds->{$prefix};
703     } else {
704 wakaba 1.7 ## From module list
705     FIND: {
706     try {
707     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
708     -><AG::ManakaiDISDocument.disDatabase>;
709     for my $mod_uri (keys %{$db->{modDef}}) {
710     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
711     if ($mod-><AG::ManakaiDISModuleDefinition.localName>
712     eq $prefix) {
713     $r = $mod-><M::ManakaiDISPropertyAccessor
714     .getPropertyText>
715     (<Q::dis:Namespace>, null);
716     last FIND;
717     }
718     }
719     } catch <Class::ManakaiDISException> with {
720     my $err = shift;
721     $err->throw
722     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
723     };
724     if ($makeNewBinding) {
725     $r = $binds->{$prefix} = $prefix;
726 wakaba 1.12 } elsif ($raisePrefixException) {
727     __EXCEPTION{DIS:UNDECLARED_NS_PREFIX_ERR::
728     infoset:prefix => {$prefix},
729     MDOMX:param-name => 'prefix',
730     DIS:sourceNode => {$self},
731     }__;
732 wakaba 1.7 } else {
733     $r = null;
734     }
735     } # FIND
736 wakaba 1.1 }
737    
738     @IntMethod:
739     @@Name:getNodeReference
740     @@Description:
741     @@@lang:en
742     @@@@:
743     Returns a new reference to the node object.
744     @@ManakaiDOM:isStatic:1
745     @@Param:
746     @@@Name:object
747     @@@Type:
748     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
749     @@@Description:
750     @@@@lang:en
751     @@@@@:
752     The node object to be referred.
753     @@Return:
754     @@@Type: ManakaiDISNode
755     @@@Description:
756     @@@@lang:en
757     @@@@@:
758     A newly created reference.
759     @@@PerlDef:
760     my $class;
761 wakaba 1.5 if ($object->{<Q::swcfg21:nodeType>} eq '#element') {
762 wakaba 1.1 $class = <ClassName::ManakaiDISElement>;
763 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#comment') {
764 wakaba 1.1 $class = <ClassName::ManakaiDISComment>;
765 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#document') {
766 wakaba 1.1 $class = <ClassName::ManakaiDISDocument>;
767 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#fragment') {
768 wakaba 1.1 $class = <ClassName::ManakaiDISDocumentFragment>;
769     } else {
770     __ASSERT{DISPerl:invariant::
771 wakaba 1.5 msg => {qq[Node type: "$object->{<Q::swcfg21:nodeType>}" ].
772 wakaba 1.1 qq[(ref: "@{[ref $object]}")]},
773     }__;
774     }
775     $r = $object-><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
776     .newReference> ($class);
777    
778 wakaba 1.2 @Attr:
779     @@Name:ownerDISDocument
780     @@Description:
781     @@@lang:en
782     @@@@:
783     The <QUOTE::dis> document object associated with this node.
784     @@Get:
785 wakaba 1.3 @@@Type:ManakaiDISDocument
786 wakaba 1.2 @@@Description:
787     @@@@lang:en
788     @@@@@:
789     The document object associated with this node.
790     @@@InCase:
791     @@@@Value:
792     @@@@@is-null:1
793     @@@@Description:
794     @@@@@lang:en
795     @@@@@@:
796     This node is a document node.
797     @@@PerlDef:
798     $r = <ClassM::ManakaiDISNode.getNodeReference>
799     ($self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>})
800     if $self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>};
801 wakaba 1.1 ##DISNode
802    
803     ClsDef:
804     @ClsQName: ManakaiDISElement
805 wakaba 1.7 @ClsISA: ManakaiDISNode
806 wakaba 1.1 @ClsISA:
807 wakaba 1.3 swcfg21:ManakaiSWCFGElement::swcfg21:ForLatest
808 wakaba 1.1 @Description:
809     @@lang:en
810     @@@:
811     <QUOTE::dis> element node objects.
812    
813     @Method:
814     @@Name: forMatch
815     @@Description:
816     @@@lang:en
817     @@@@:
818     Tests whether this element is for a <QUOTE::for> or not.
819     @@Param:
820     @@@Name: forArg
821     @@@Type: ForURI
822     @@@Description:
823     @@@@lang:en
824     @@@@@:
825     The <QUOTE::For> URI reference to test against.
826     @@Param:
827     @@@Name: forpArg
828     @@@Type: ForURIList
829     @@@Description:
830     @@@@lang:en
831     @@@@@:
832     The <QUOTE::For+> URI references to test against.
833     @@@InCase:
834     @@@@Value:
835     @@@@@is-null:1
836     @@@@Description:
837     @@@@@lang:en
838     @@@@@@:
839     No additional <QUOTE::For> URI reference.
840 wakaba 1.3 Equivalent to an empty array reference.
841 wakaba 1.1 @@Return:
842     @@@Type:
843     DOMMain:boolean
844     @@@Description:
845     @@@@lang:en
846     @@@@@:
847     Whether this element is for <P::forArg> and <P::forpArg> or not.
848 wakaba 1.2 @@@UndeclaredPrefixException:
849     @@@NoDBException:
850     @@@PerlDef:
851 wakaba 1.3 $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
852     $forpArg ||= [];
853 wakaba 1.2
854     FORMATCH: {
855     __DEEP{
856 wakaba 1.10 my $for_res = $self-><AG::ManakaiDISNode.ownerDISDocument>
857     -><AG::ManakaiDISDocument.disDatabase>
858     -><M::ManakaiDISDatabase.getFor> ($forArg);
859     my $forp_res = [map {
860     $self-><AG::ManakaiDISNode.ownerDISDocument>
861     -><AG::ManakaiDISDocument.disDatabase>
862     -><M::ManakaiDISDatabase.getFor> ($_)
863     } @{$forpArg}];
864    
865     my @ce = @{$self-><M::ManakaiDISElement.disAllChildElements>};
866 wakaba 1.2 for my $ce (@ce) {
867 wakaba 1.3 my $et = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
868     .expandedURI>;
869 wakaba 1.2 if ($et eq <Q::dis:ForCheck>) {
870 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
871     ::swcfg21:ForLatest.value>];
872 wakaba 1.9 FCs: for my $f (@$fors) {
873 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
874 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
875 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
876     -><AG::ManakaiDISDocument.disDatabase>
877     -><M::ManakaiDISDatabase.getFor> ($uri);
878 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
879 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
880     if ($arg_res eq $for) {
881 wakaba 1.2 $r = false;
882     last FORMATCH;
883     }
884     }
885     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
886 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
887 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
888     -><AG::ManakaiDISDocument.disDatabase>
889     -><M::ManakaiDISDatabase.getFor> ($uri);
890 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
891 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
892     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
893 wakaba 1.2 $r = false;
894     last FORMATCH;
895     }
896     }
897     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
898 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
899 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
900     -><AG::ManakaiDISDocument.disDatabase>
901     -><M::ManakaiDISDatabase.getFor> ($uri);
902 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
903 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
904     if ($arg_res eq $for) {
905 wakaba 1.2 next FCs;
906     }
907     }
908     $r = false;
909     last FORMATCH;
910     } else { ## -- ISA
911 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
912 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
913     -><AG::ManakaiDISDocument.disDatabase>
914     -><M::ManakaiDISDatabase.getFor> ($uri);
915 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
916 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
917     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
918 wakaba 1.2 next FCs;
919     }
920     }
921     $r = false;
922     last FORMATCH;
923     }
924     } # FCs
925     } # dis:ForCheck
926     } # children
927    
928     my $has_for = false;
929     for my $ce (@ce) {
930 wakaba 1.11 if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
931 wakaba 1.3 .expandedURI> eq
932 wakaba 1.2 <Q::dis:For>) {
933 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
934     ::swcfg21:ForLatest.value>];
935 wakaba 1.2 my $ok = true;
936     $has_for = true;
937 wakaba 1.9 AFOR: for my $f (@$fors) {
938 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
939 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
940 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
941     -><AG::ManakaiDISDocument.disDatabase>
942     -><M::ManakaiDISDatabase.getFor> ($uri);
943 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
944 wakaba 1.10 if ($for eq $for_res) {
945 wakaba 1.2 $ok = false;
946     last AFOR;
947     }
948     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
949 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
950 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
951     -><AG::ManakaiDISDocument.disDatabase>
952     -><M::ManakaiDISDatabase.getFor> ($uri);
953 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
954 wakaba 1.10 if ($for_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
955 wakaba 1.2 $ok = false;
956     last AFOR;
957     }
958     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
959 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
960 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
961     -><AG::ManakaiDISDocument.disDatabase>
962     -><M::ManakaiDISDatabase.getFor> ($uri);
963 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
964 wakaba 1.10 unless ($for eq $for_res) {
965 wakaba 1.2 $ok = false;
966     last AFOR;
967     }
968     } else { ## -- ISA
969 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
970 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
971     -><AG::ManakaiDISDocument.disDatabase>
972     -><M::ManakaiDISDatabase.getFor> ($uri);
973 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
974 wakaba 1.10 unless ($for_res-><M::ManakaiDISForDefinition.isaURI>($uri)){
975 wakaba 1.2 $ok = false;
976     last AFOR;
977     }
978     }
979     } # AFOR
980 wakaba 1.3 if ($ok) {
981     $r = true;
982     last FORMATCH;
983     }
984 wakaba 1.2 } # dis:For
985     } # $ce
986     $r = $has_for ? false : true;
987     }__;
988     } # FORMATCH
989 wakaba 1.1
990     @Method:
991     @@Name: mediaTypeMatch
992     @@Description:
993     @@@lang:en
994     @@@@:
995     Tests whether the content media type of this element matches to
996     a type or not.
997     @@Param:
998     @@@Name: mediaType
999     @@@Type: MediaTypeURI
1000     @@@Description:
1001     @@@@lang:en
1002     @@@@@:
1003     A media type URI reference to test against.
1004     @@Param:
1005 wakaba 1.3 @@@Name: defaultMediaType
1006 wakaba 1.1 @@@Type: MediaTypeURI
1007     @@@Description:
1008     @@@@lang:en
1009     @@@@@:
1010     The default media type for this element.
1011     @@@InCase:
1012     @@@@Value:
1013     @@@@@is-null:1
1014     @@@@Description:
1015     @@@@@lang:en
1016     @@@@@@:
1017     No default type provided. All <P::mediaType> will match.
1018 wakaba 1.12 @@ForParam:
1019     @@ForpParam:
1020 wakaba 1.1 @@Return:
1021     @@@Type:
1022     DOMMain:boolean
1023     @@@Description:
1024     @@@@lang:en
1025     @@@@@:
1026     Whether this element is of <P::mediaType> or not.
1027 wakaba 1.2 @@@PerlDef:
1028     if (defined $mediaType) {
1029     __DEEP{
1030     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1031 wakaba 1.12 (<Q::dis:ContentType>, for_arg => $forArg,
1032     forp_arg => $forpArg);
1033 wakaba 1.2 my $ct;
1034     $ct = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1035     $ct = $defaultMediaType unless defined $ct;
1036     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
1037     -><AG::ManakaiDISDocument.disDatabase>
1038     -><M::ManakaiDISDatabase.getResource> ($ct);
1039     $res-><AS::ManakaiDISResourceDefinition.isReferred> ($ctn or $self);
1040 wakaba 1.7 unless ($res-><M::ManakaiDISResourceDefinition
1041 wakaba 1.10 .isSubsetOfURI> ($mediaType)) {
1042 wakaba 1.2 $r = false;
1043     } else {
1044     $r = true;
1045     }
1046     }__;
1047     } else {
1048     $r = true;
1049     }
1050 wakaba 1.1
1051     @Method:
1052 wakaba 1.10 @@Name:mediaTypeURI
1053     @@enDesc:
1054     The URI reference of the media type of this element.
1055     @@Type: MediaTypeURI
1056     @@NamedParam:
1057     @@@Name:defaultMediaType
1058     @@@Type:MediaTypeURI
1059     @@@enDesc:
1060     The default media type URI reference.
1061     @@@nullCase:
1062     @@@@enDesc:
1063     No default is specified.
1064     @@ForParam:
1065     @@ForpParam:
1066     @@Return:
1067     @@@enDesc:
1068     The media type URI reference of this element.
1069     @@@nullCase:
1070     @@@@enDesc:
1071     This element has no media type information and
1072     <P::defaultMediaType> parameter is not provided.
1073     @@@UndeclaredPrefixException:
1074     @@@PerlDef:
1075     __DEEP{
1076     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1077     (<Q::dis:ContentType>, for_arg => $forArg,
1078     forp_arg => $forpArg);
1079     $r = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1080     }__;
1081    
1082     @Method:
1083 wakaba 1.1 @@Name: prefixToURI
1084     @@Description:
1085     @@@lang:en
1086     @@@@:
1087     Converts a namespace prefix into associated URI reference.
1088     @@Param:
1089     @@@Name: prefix
1090     @@@Type:
1091 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
1092 wakaba 1.1 @@@Description:
1093     @@@@lang:en
1094     @@@@@:
1095     A namespace prefix to look for.
1096     @@@InCase:
1097     @@@@Value:
1098     @@@@@is-null:1
1099     @@@@Description:
1100     @@@@@lang:en
1101     @@@@@@:
1102     Returns the default namespace URI.
1103     @@NodeParam:
1104     @@Return:
1105 wakaba 1.3 @@@Type: AnyURI
1106 wakaba 1.1 @@@Description:
1107     @@@@lang:en
1108     @@@@@: The URI references associated.
1109     @@@UndeclaredPrefixException:
1110     @@@PerlDef:
1111 wakaba 1.3 if (defined $prefix) {
1112 wakaba 1.1 __DEEP{
1113 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1114     .lookupNamespaceURI> ($prefix);
1115 wakaba 1.1 }__;
1116     unless (defined $r) {
1117     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
1118     infoset:prefix => {$prefix},
1119     MDOMX:param-name => 'prefix',
1120     DIS:sourceNode => {$node},
1121     }__;
1122     }
1123 wakaba 1.7 } else { ## Default namespace
1124     __DEEP{
1125     $r = ($self-><AG::ManakaiDISNode.ownerDISDocument> || $self)
1126     -><AG::ManakaiDISDocument.moduleElement>
1127     -><AG::ManakaiDISModuleElement.definingNamespaceURI>;
1128     }__;
1129 wakaba 1.1 }
1130    
1131     @Method:
1132     @@QName: qnameToURI
1133     @@Description:
1134     @@@lang:en
1135     @@@@:
1136     Converts a qualified name (<TYPE::dis:TypeQName>) to
1137     an expanded URI reference.
1138     @@Param:
1139     @@@Name: qname
1140     @@@Type:
1141     dis:TypeQName
1142     @@@Description:
1143     @@@@lang:en
1144     @@@@@:
1145     A qualified name.
1146     @@NodeParam:
1147 wakaba 1.13 @@NamedParam:
1148     @@@Name: defaultNamespaceURI
1149     @@@Type: AnyURI
1150     @@@enDesc:
1151     Default namespace URI reference.
1152     @@@nullCase:
1153     @@@@enDesc:
1154     The default namespace is the namespace defined by the module
1155     to which this resource belongs.
1156 wakaba 1.1 @@Return:
1157     @@@Type: AnyURI
1158     @@@Description:
1159     @@@@lang:en
1160     @@@@@:
1161     The expanded URI reference.
1162     @@@UndeclaredPrefixException:
1163     @@@PerlDef:
1164     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1165 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1166 wakaba 1.1 __DEEP{
1167     if (defined $lname) {
1168     $r = $self-><M::ManakaiDISElement.prefixToURI> ($prefix) . $lname;
1169     } else { ## In default namespace
1170 wakaba 1.13 if (defined $defaultNamespaceURI) {
1171     $r = $defaultNamespaceURI . $prefix;
1172     } else {
1173     $r = $self-><M::ManakaiDISElement.prefixToURI> (null) . $prefix;
1174     }
1175 wakaba 1.1 }
1176 wakaba 1.4 }__;
1177 wakaba 1.1
1178     @Method:
1179     @@QName: qnameToPair
1180     @@Description:
1181     @@@lang:en
1182     @@@@:
1183     Converts a qualified name (<TYPE::dis:TypeQName>) to
1184     a pair of namespace URI and local name.
1185     @@Param:
1186     @@@Name: qname
1187     @@@Type:
1188     dis:TypeQName
1189     @@@Description:
1190     @@@@lang:en
1191     @@@@@:
1192     A qualified name.
1193     @@NodeParam:
1194     @@Return:
1195     @@@Type:
1196     Perl:ARRAY
1197     @@@Description:
1198     @@@@lang:en
1199     @@@@@:
1200     A list of namespace URI and local name.
1201     @@@UndeclaredPrefixException:
1202     @@@PerlDef:
1203     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1204 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1205 wakaba 1.1 __DEEP{
1206     if (defined $lname) {
1207     $r = [$self-><M::ManakaiDISElement.prefixToURI> ($prefix), $lname];
1208     } else { ## In default namespace
1209     $r = [$self-><M::ManakaiDISElement.prefixToURI> (null), $prefix];
1210     }
1211 wakaba 1.4 }__;
1212 wakaba 1.1
1213     @Method:
1214 wakaba 1.3 @@Name: tfqnamesToURI
1215 wakaba 1.1 @@Description:
1216     @@@lang:en
1217     @@@@:
1218 wakaba 1.3 Converts a <TYPE::dis:TFQNames>
1219 wakaba 1.1 into an expanded URI reference.
1220     @@Param:
1221     @@@Name: tfqnames
1222     @@@Type:
1223 wakaba 1.3 dis:TFQNames
1224 wakaba 1.1 @@@Description:
1225     @@@@lang:en
1226     @@@@@:
1227 wakaba 1.3 A <TYPE::dis:TFQNames> to identify a resource.
1228 wakaba 1.1 @@Param:
1229     @@@Name: defaultTypeURI
1230     @@@Type: NameURI
1231     @@@Description:
1232     @@@@lang:en
1233     @@@@@:
1234     A name URI reference used if it is missing from
1235     <P::tfqnames>.
1236     @@@InCase:
1237     @@@@Value:
1238     @@@@@is-null:1
1239     @@@@Description:
1240     @@@@@lang:en
1241     @@@@@@:
1242     Equivalent to <Q::DOMMain:any>.
1243     @@Param:
1244     @@@Name: defaultForURI
1245     @@@Type: ForURI
1246     @@@Description:
1247     @@@@lang:en
1248     @@@@@:
1249     A <QUOTE::for> URI reference used if it is missing from
1250     <P::tfqnames>.
1251     @@@InCase:
1252     @@@@Value:
1253     @@@@@is-null:1
1254     @@@@Description:
1255     @@@@@lang:en
1256     @@@@@@:
1257     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1258     @@NodeParam:
1259     @@Return:
1260     @@@Type:
1261 wakaba 1.3 DISCore:TFURI::ManakaiDOM:all
1262 wakaba 1.1 @@@Description:
1263     @@@@lang:en
1264     @@@@@:
1265 wakaba 1.3 The <TYPE::dis:TFQNames>-expanded URI references.
1266 wakaba 1.1 @@@UndeclaredPrefixException:
1267     @@@PerlDef:
1268 wakaba 1.15 my ($typeq, $forq) = split /\s*[:|][:|]\s*/, $tfqnames, 2;
1269 wakaba 1.1 my ($typeURI, $forURI);
1270     if (defined $forq) {
1271     __DEEP{
1272     $typeURI = $typeq eq ''
1273     ? defined $defaultTypeURI ? $defaultTypeURI
1274     : <Q::DOMMain:any>
1275     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1276     }__;
1277     if (length $forq) {
1278     $forURI = $self-><M::ManakaiDISElement.qnameToURI> ($forq, %opt);
1279     } else {
1280     $forURI = <Q::ManakaiDOM:all>;
1281     }
1282     } else { ## "For" omitted
1283     __DEEP{
1284     $typeURI = $typeq eq ''
1285     ? defined $defaultTypeURI ? $defaultTypeURI
1286     : <Q::DOMMain:any>
1287     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1288     }__;
1289 wakaba 1.3 $forURI = defined $defaultForURI ? $defaultForURI
1290     : <Q::ManakaiDOM:all>;
1291 wakaba 1.1 }
1292 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
1293 wakaba 1.2
1294     @Method:
1295     @@Name: disGetAttribute
1296     @@enDesc:
1297     Gets an attribute node.
1298     @@Param:
1299     @@@Name: attrName
1300     @@@Type: AnyURI
1301     @@@enDesc:
1302     The name expanded URI of the node to retrieve.
1303     @@ForParam:
1304     @@ForpParam:
1305     @@MediaTypeParam:
1306     @@MediaTypeDefaultParam:
1307     @@Return:
1308     @@@Type: ManakaiDISElement
1309     @@@enDesc:
1310     The attribute (property) element node.
1311     @@@nullCase:
1312     @@@@enDesc:
1313     No attribute node found.
1314     @@@PerlDef:
1315 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1316     (for_arg => $forArg, forp_arg => $forpArg)}) {
1317 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1318     .expandedURI> eq $attrName and
1319 wakaba 1.12 $c-><M::ManakaiDISElement.mediaTypeMatch>
1320     ($mediaType, $defaultMediaType,
1321     for_arg => $forArg, forp_arg => $forpArg)) {
1322 wakaba 1.2 $r = $c;
1323     last;
1324     }
1325     }
1326    
1327     @Method:
1328     @@Name: disGetAttributeList
1329     @@enDesc:
1330     Gets attribute nodes.
1331 wakaba 1.3 @@Param:
1332     @@@Name: attrName
1333     @@@Type: AnyURI
1334     @@@enDesc:
1335     The name expanded URI of the node to retrieve.
1336 wakaba 1.2 @@ForParam:
1337     @@ForpParam:
1338     @@MediaTypeParam:
1339     @@MediaTypeDefaultParam:
1340     @@Return:
1341     @@@Type: ManakaiDISElementList
1342     @@@enDesc:
1343     The attribute (property) element nodes.
1344     @@@PerlDef:
1345     $r = bless [], <ClassName::ManakaiDISElementList>;
1346 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1347     (for_arg => $forArg, forp_arg => $forpArg)}) {
1348 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1349     .expandedURI> eq $attrName and
1350 wakaba 1.12 $c-><M::ManakaiDISElement.mediaTypeMatch>
1351     ($mediaType, $defaultMediaType,
1352     for_arg => $forArg, forp_arg => $forpArg)) {
1353 wakaba 1.2 push @$r, $c;
1354     }
1355     }
1356    
1357 wakaba 1.4 @Method:
1358 wakaba 1.2 @@Name: disChildElements
1359     @@enDesc:
1360 wakaba 1.10 A list of child elements, with <QUOTE::for> check.
1361 wakaba 1.4 @@ForParam:
1362     @@ForpParam:
1363     @@Return:
1364     @@@Type: ManakaiDISElementList
1365 wakaba 1.2 @@@enDesc:
1366     The current snapshot of child nodes.
1367     @@@PerlDef:
1368 wakaba 1.4 $r = bless [], <ClassName::ManakaiDISElementList>;
1369     __DEEP{
1370     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1371     .childNodes>}) {
1372     ## $cn is an #element.
1373     my $dn = $cn->{<Q::TreeCore:node>}
1374     -><M::ManakaiDOM:ManakaiDOMNodeObject
1375     ::ManakaiDOM:Perl.newReference>
1376     (<ClassName::ManakaiDISElement>);
1377     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1378     push @$r, $dn;
1379     }
1380     }__;
1381 wakaba 1.5
1382 wakaba 1.10 @Method:
1383     @@Name: disAllChildElements
1384     @@enDesc:
1385     A list of child elements, without <QUOTE::for> check.
1386     @@Return:
1387     @@@Type: ManakaiDISElementList
1388     @@@enDesc:
1389     The current snapshot of child nodes.
1390     @@@PerlDef:
1391     $r = bless [], <ClassName::ManakaiDISElementList>;
1392     __DEEP{
1393     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1394     .childNodes>}) {
1395     ## $cn is an #element.
1396     my $dn = $cn->{<Q::TreeCore:node>}
1397     -><M::ManakaiDOM:ManakaiDOMNodeObject
1398     ::ManakaiDOM:Perl.newReference>
1399     (<ClassName::ManakaiDISElement>);
1400     push @$r, $dn;
1401     }
1402     }__;
1403    
1404 wakaba 1.2 @Attr:
1405     @@Name: qnameValueURI
1406     @@enDesc:
1407     The element value (written as <TYPE::dis:TypeQName>), as URI reference.
1408     \
1409     {NOTE:: What should be if list value?
1410     \
1411     }
1412     @@Get:
1413     @@@Type:AnyURI
1414     @@@nullCase:
1415     @@@@enDesc:
1416     No value.
1417     @@@UndeclaredPrefixException:
1418 wakaba 1.3 @@@PerlDef:
1419 wakaba 1.4 __DEEP{
1420 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1421 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1422 wakaba 1.14 $r = $self-><M::ManakaiDISElement.qnameToURI> ($v, node => $self);
1423 wakaba 1.4 } else {
1424     $r = null;
1425     }
1426     }__;
1427    
1428     @Attr:
1429     @@Name: qnameValueLocalName
1430     @@enDesc:
1431     The local name part of the element value (assumed as
1432     written as <TYPE::dis:TypeQName>).
1433     \
1434     {NOTE:: What should be if list value?
1435     \
1436     }
1437     @@Get:
1438     @@@Type:
1439     DISCore:LocalName
1440     @@@nullCase:
1441     @@@@enDesc:
1442     No value.
1443     @@@PerlDef:
1444     __DEEP{
1445 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1446 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1447 wakaba 1.15 my ($n, $v) = split /\s*[:|]\s*/, $v, 2;
1448 wakaba 1.4 $r = defined $v ? $v : $n;
1449     } else {
1450     $r = null;
1451     }
1452     }__;
1453    
1454     @Attr:
1455     @@Name: qnameValueNamespaceURI
1456     @@enDesc:
1457     The namespace URI of the element value (assumed as written
1458     in <TYPE::dis:TypeQName>).
1459     \
1460     {NOTE:: What should be if list value?
1461     \
1462     }
1463     @@Get:
1464     @@@Type:AnyURI
1465     @@@nullCase:
1466     @@@@enDesc:
1467     No value.
1468     @@@UndeclaredPrefixException:
1469     @@@PerlDef:
1470     __DEEP{
1471 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1472 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1473 wakaba 1.15 my ($p, $v) = split /\s*[:|]\s*/, $v, 2;
1474 wakaba 1.14 $r = $self-><M::ManakaiDISElement.prefixToURI>
1475 wakaba 1.4 (defined $v ? $p : null);
1476     } else {
1477     $r = null;
1478     }
1479     }__;
1480 wakaba 1.2
1481 wakaba 1.6 @Method:
1482 wakaba 1.3 @@Name: tfqnamesValueURI
1483 wakaba 1.2 @@enDesc:
1484 wakaba 1.3 The element value (written as <TYPE::dis:TFQNames>),
1485 wakaba 1.2 as URI reference.
1486     \
1487     {NOTE:: What should be if list value?
1488     \
1489     }
1490 wakaba 1.6 @@Param:
1491     @@@Name: defaultTypeURI
1492     @@@Type: NameURI
1493     @@@Description:
1494     @@@@lang:en
1495     @@@@@:
1496     A name URI reference used if it is missing from
1497     <P::tfqnames>.
1498     @@@InCase:
1499     @@@@Value:
1500     @@@@@is-null:1
1501     @@@@Description:
1502     @@@@@lang:en
1503     @@@@@@:
1504     Equivalent to <Q::DOMMain:any>.
1505     @@Param:
1506     @@@Name: defaultForURI
1507     @@@Type: ForURI
1508     @@@Description:
1509     @@@@lang:en
1510     @@@@@:
1511     A <QUOTE::for> URI reference used if it is missing from
1512     <P::tfqnames>.
1513     @@@InCase:
1514     @@@@Value:
1515     @@@@@is-null:1
1516     @@@@Description:
1517     @@@@@lang:en
1518     @@@@@@:
1519     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1520     @@Return:
1521 wakaba 1.2 @@@Type:ResourceURI
1522     @@@nullCase:
1523     @@@@enDesc:
1524     No value.
1525     @@@UndeclaredPrefixException:
1526 wakaba 1.3 @@@PerlDef:
1527 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1528 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1529     __DEEP{
1530 wakaba 1.14 $r = $self-><M::ManakaiDISElement.tfqnamesToURI>
1531 wakaba 1.6 ($v, $defaultTypeURI, $defaultForURI);
1532 wakaba 1.2 }__;
1533     } else {
1534     $r = null;
1535     }
1536 wakaba 1.7
1537     @Method:
1538     @@Name: elementTypeMatch
1539     @@enDesc:
1540     Returns whether the element type of this element matches
1541     with another element type (either the same element type or
1542     this type is a subtype of another type).
1543     @@Param:
1544     @@@Name: etype
1545     @@@Type: ResourceURI
1546     @@@enDesc:
1547     An element type name URI reference to test.
1548     @@Return:
1549     @@@Type:
1550     DOMMain:boolean
1551     @@@TrueCase:
1552     @@@@enDesc:
1553     Either the element type expanded URI reference of this element is
1554     same as <P::etype> or it is a sub-element type of <P::etype>.
1555     @@@FalseCase:
1556     @@@@enDesc:
1557     This element is not of <P::etype>.
1558     @@@NoDBException:
1559     @@@PerlDef:
1560     __DEEP{
1561 wakaba 1.14 my $et = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1562 wakaba 1.7 .expandedURI>;
1563     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1564     -><AG::ManakaiDISDocument.disDatabase>
1565     -><M::ManakaiDISDatabase.getResource> ($et);
1566     $r = $rdef-><M::ManakaiDISResourceDefinition.isSubsetOfURI> ($etype);
1567     }__;
1568    
1569     @Attr:
1570     @@Name: isResourceElement
1571     @@enDesc:
1572     Whether this element defines a resource or not.
1573     \
1574     {NOTE:: An element defines a resource if its element type is
1575     <Q::dis:ResourceDef> or its subtype.
1576     \
1577     }
1578     @@Get:
1579     @@@Type:
1580     DOMMain:boolean
1581     @@@TrueCase:
1582     @@@@enDesc:
1583     This element defines a resource.
1584     @@@FalseCase:
1585     @@@@enDesc:
1586     This element does not define any resource.
1587     @@@NoDBException:
1588     @@@PerlDef:
1589     __DEEP{
1590     $r = $self-><M::ManakaiDISElement.elementTypeMatch>
1591     (<Q::dis:ResourceDef>);
1592     }__;
1593    
1594     @Attr:
1595     @@Name: isPropertyElement
1596     @@enDesc:
1597     Whether this element is a property or not.
1598     \
1599     {NOTE:: An element is a property if its element type is
1600     <Q::rdf:type> or if its element type's <Q::rdf:type>
1601     property is <Q::rdf:Property> or is <Q::dis:subsetOf>
1602     <Q::rdf:Property>.
1603     \
1604     }
1605     @@Get:
1606     @@@Type:
1607     DOMMain:boolean
1608     @@@TrueCase:
1609     @@@@enDesc:
1610     This element is a property.
1611     @@@FalseCase:
1612     @@@@enDesc:
1613     This element is not a property.
1614     @@@NoDBException:
1615     @@@PerlDef:
1616     __DEEP{
1617     my $xn = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1618     .expandedURI>;
1619     if ($xn eq <Q::rdf:type>) {
1620     $r = true;
1621     } else {
1622     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1623     -><AG::ManakaiDISDocument.disDatabase>
1624     -><M::ManakaiDISDatabase.getResource> ($xn);
1625     $r = $rdef-><M::ManakaiDISResourceDefinition.isTypeURI>
1626     (<Q::rdf:Resource>);
1627     }
1628     }__;
1629 wakaba 1.1 ##DISElement
1630    
1631     ClsDef:
1632 wakaba 1.4 @ClsQName: ManakaiDISModuleElement
1633     @ClsISA: ManakaiDISElement
1634     @enDesc:
1635     The <Q::dis:Module> elements.
1636    
1637     @Attr:
1638     @@Name: requireElement
1639     @@enDesc:
1640     The <Q::dis:Require> child element. The element is
1641     newly created if not exist.
1642     @@Type: ManakaiDISElement
1643     @@Get:
1644     @@@PerlDef:
1645     __DEEP{
1646     $r = $self-><M::swcfg21:SWCFGNode
1647     ::swcfg21:ForLatest.getAttributeNS>
1648     (<Q::dis:>, 'Require', make_new_node => true);
1649     }__;
1650    
1651     @Attr:
1652     @@Name: defaultForURI
1653     @@enDesc:
1654     The value of <Q::dis:DefaultFor> attribute.
1655     @@Type: ForURI
1656     @@Get:
1657     @@@enDesc:
1658     The value of <Q::dis:DefaultFor> child element. If missing,
1659     <Q::ManakaiDOM:all> is returned.
1660     @@@PerlDef:
1661     __DEEP{
1662     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1663     .getAttributeNS>
1664     (<Q::dis:>, 'DefaultFor');
1665     if ($df) {
1666     $r = $df-><AG::ManakaiDISElement.qnameValueURI>
1667     || <Q::ManakaiDOM:all>;
1668     } else {
1669     $r = <Q::ManakaiDOM:all>;
1670     }
1671     }__;
1672     @@Set:
1673     @@@PerlDef:
1674     __DEEP{
1675     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1676     (<Q::dis:>, 'DefaultFor' => $given);
1677     }__;
1678 wakaba 1.7
1679     @Attr:
1680     @@Name: definingNamespaceURI
1681     @@enDesc:
1682     The value of <Q::dis:NamespaceURI> attribute, i.e.
1683     the URI reference of the namespace that this module primary
1684     defines.
1685     \
1686     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
1687     \
1688     }
1689     @@Type: AnyURI
1690     @@Get:
1691     @@@PerlDef:
1692     __DEEP{
1693     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1694     .getAttributeNS>
1695     (<Q::dis:>, 'Namespace');
1696     if ($df) {
1697 wakaba 1.14 $r = $df-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1698 wakaba 1.7 } else {
1699     __ASSERT{DISPerl:invariant::
1700     msg => {qq["dis:Namespace" attribute not found]},
1701     }__;
1702     }
1703     }__;
1704     @@Set:
1705     @@@PerlDef:
1706     __DEEP{
1707     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1708     (<Q::dis:>, 'Namespace' => $given);
1709     }__;
1710 wakaba 1.4 ##DISModuleElement
1711    
1712     ClsDef:
1713 wakaba 1.2 @ClsQName: ManakaiDISElementList
1714     @enDesc:
1715     @@lang:en
1716     @@@:
1717     Lists of elements.
1718     \
1719     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
1720     later changes to the tree does not affect this type of objects.
1721     \
1722     }
1723     ##DISElementList
1724    
1725     ClsDef:
1726 wakaba 1.1 @ClsQName: ManakaiDISComment
1727 wakaba 1.7 @ClsISA: ManakaiDISNode
1728 wakaba 1.1 @ClsISA:
1729 wakaba 1.3 swcfg21:ManakaiSWCFGComment::swcfg21:ForLatest
1730 wakaba 1.1 @Description:
1731     @@lang:en
1732     @@@:
1733     <QUOTE::dis> comment node objects.
1734     ##DISComment
1735    
1736     ClsDef:
1737     @ClsQName: ManakaiDISDocumentFragment
1738 wakaba 1.7 @ClsISA: ManakaiDISNode
1739 wakaba 1.1 @ClsISA:
1740 wakaba 1.3 swcfg21:ManakaiSWCFGDocumentFragment::swcfg21:ForLatest
1741 wakaba 1.1 @Description:
1742     @@lang:en
1743     @@@:
1744     <QUOTE::dis> document fragment node objects.
1745     ##DISDocumentFragment
1746    
1747     ClsDef:
1748     @ClsQName: ManakaiDISDocument
1749 wakaba 1.7 @ClsISA: ManakaiDISNode
1750 wakaba 1.1 @ClsISA:
1751 wakaba 1.3 swcfg21:ManakaiSWCFGDocument::swcfg21:ForLatest
1752 wakaba 1.1 @Description:
1753     @@lang:en
1754     @@@:
1755     <QUOTE::dis> document node objects.
1756 wakaba 1.2
1757     @Attr:
1758 wakaba 1.4 @@Name: moduleElement
1759     @@enDesc:
1760     The <Q::dis:Module> element in this document. The element is
1761     newly created if not exist.
1762     @@Type: ManakaiDISModuleElement
1763     @@Get:
1764     @@@PerlDef:
1765     __DEEP{
1766     $r = $self-><M::swcfg21:SWCFGNode
1767     ::swcfg21:ForLatest.getAttributeNS>
1768     (<Q::dis:>, 'Module', make_new_node => true);
1769     }__;
1770     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
1771    
1772     @Attr:
1773 wakaba 1.2 @@Name: disDatabase
1774     @@enDesc:
1775     Associated <QUOTE::dis> database.
1776    
1777     @@Type: ManakaiDISDatabase
1778     @@Get:
1779     @@@NoDBException:
1780     @@@PerlDef:
1781     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
1782 wakaba 1.5 $r = $self->{<Q::TreeCore:node>}->{<Q::db>};
1783 wakaba 1.2 } else {
1784     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
1785     }
1786     @@Set:
1787     @@@PerlDef:
1788     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
1789     require Scalar::Util;
1790     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
1791 wakaba 1.5
1792     @Method:
1793     @@Name: disChildElements
1794     @@enDesc:
1795 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
1796 wakaba 1.5 @@ForParam:
1797     @@ForpParam:
1798     @@Return:
1799     @@@Type: ManakaiDISElementList
1800     @@@enDesc:
1801     The current snapshot of child nodes.
1802     @@@PerlDef:
1803     $r = bless [], <ClassName::ManakaiDISElementList>;
1804     __DEEP{
1805     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1806     .childNodes>}) {
1807     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1808     .nodeType> eq '#element';
1809     my $dn = $cn->{<Q::TreeCore:node>}
1810     -><M::ManakaiDOM:ManakaiDOMNodeObject
1811     ::ManakaiDOM:Perl.newReference>
1812     (<ClassName::ManakaiDISElement>);
1813     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1814     push @$r, $dn;
1815     }
1816     }__;
1817 wakaba 1.10
1818     @Method:
1819     @@Name: disAllChildElements
1820     @@enDesc:
1821     A list of child elements, without <QUOTE::for> checks.
1822     @@Return:
1823     @@@Type: ManakaiDISElementList
1824     @@@enDesc:
1825     The current snapshot of child nodes.
1826     @@@PerlDef:
1827     $r = bless [], <ClassName::ManakaiDISElementList>;
1828     __DEEP{
1829     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1830     .childNodes>}) {
1831     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1832     .nodeType> eq '#element';
1833     my $dn = $cn->{<Q::TreeCore:node>}
1834     -><M::ManakaiDOM:ManakaiDOMNodeObject
1835     ::ManakaiDOM:Perl.newReference>
1836     (<ClassName::ManakaiDISElement>);
1837     push @$r, $dn;
1838     }
1839     }__;
1840 wakaba 1.1 ##DISDocument
1841 wakaba 1.2
1842     PropDef:
1843     @QName: db
1844     @enDesc:
1845     Associated <QUOTE::dis> database.
1846     @rdfs:domain: ManakaiDISDocument
1847     @rdfs:range: ManakaiDISDatabase
1848    
1849     ## -- Definition object database
1850    
1851     ClsDef:
1852     @ClsQName: ManakaiDISDatabase
1853     @enDesc:
1854     Resource database created from <QUOTE::dis> source data.
1855 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
1856 wakaba 1.2
1857     @Method:
1858     @@Name: getModule
1859     @@Description:
1860     @@@lang:en
1861     @@@@:
1862     Returns a <QUOTE::dis> module definition.
1863     @@Param:
1864 wakaba 1.9 @@@Name: moduleURI
1865 wakaba 1.2 @@@Type: ModuleURI
1866     @@@Description:
1867     @@@@lang:en
1868     @@@@@:
1869     A <QUOTE::dis> module URI reference.
1870 wakaba 1.9 @@ForParam:
1871 wakaba 1.2 @@Return:
1872     @@@Type: ManakaiDISModuleDefinition
1873     @@@Description:
1874     @@@@lang:en
1875     @@@@@:
1876     The module definition.
1877     @@@PerlDef:
1878 wakaba 1.9 my $modURI;
1879     if (defined $forArg) {
1880     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
1881     $uri => $modURI}__;
1882     } else {
1883     $modURI = $moduleURI;
1884     }
1885 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
1886     $r = $self->{modDef}->{$modURI};
1887     } else {
1888     $r = $self->{modDef}->{$modURI}
1889     = bless {
1890     uri => $modURI,
1891     db => $self,
1892     for => <Q::ManakaiDOM:all>,
1893     forp => [],
1894     }, <ClassName::ManakaiDISModuleDefinition>;
1895     require Scalar::Util;
1896     Scalar::Util::weaken ($r->{db});
1897     }
1898    
1899     @Method:
1900     @@Name: getFor
1901     @@Description:
1902     @@@lang:en
1903     @@@@:
1904     Returns a <QUOTE::for> definition object.
1905     @@Param:
1906     @@@Name: forURI
1907     @@@Type: ForURI
1908     @@@Description:
1909     @@@@lang:en
1910     @@@@@:
1911     A <QUOTE::for> URI reference.
1912     @@@InCase:
1913     @@@@Value:
1914     @@@@@is-null:1
1915     @@@@Description:
1916     @@@@@lang:en
1917     @@@@@@:
1918     Defaulted to <Q::ManakaiDOM:all>.
1919     @@Return:
1920     @@@Type: ManakaiDISForDefinition
1921     @@@PerlDef:
1922     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
1923     if (defined $self->{forDef}->{$forURI}) {
1924     $r = $self->{forDef}->{$forURI};
1925     } else {
1926     $r = $self->{forDef}->{$forURI}
1927     = bless {
1928     uri => $forURI,
1929     isa => {<Q::ManakaiDOM:all> => true},
1930     revISA => {},
1931     db => $self,
1932     }, <ClassName::ManakaiDISForDefinition>;
1933     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
1934     require Scalar::Util;
1935     Scalar::Util::weaken ($r->{db});
1936     }
1937    
1938     @Method:
1939     @@Name: getResource
1940     @@Description:
1941     @@@lang:en
1942     @@@@:
1943     Returns a <QUOTE::dis> resource definition.
1944     @@Param:
1945 wakaba 1.9 @@@Name: resourceURI
1946 wakaba 1.2 @@@Type: ResourceURI
1947     @@@Description:
1948     @@@@lang:en
1949     @@@@@:
1950     A <QUOTE::dis> resource URI reference.
1951 wakaba 1.3 @@@nullCase:
1952 wakaba 1.2 @@@@Description:
1953     @@@@@lang:en
1954     @@@@@@:
1955     Defaulted to <Q::DOMMain:any>.
1956 wakaba 1.9 @@ForParam:
1957 wakaba 1.2 @@Return:
1958     @@@Type: ManakaiDISResourceDefinition
1959     @@@Description:
1960     @@@@lang:en
1961     @@@@@:
1962     The resource definition.
1963     @@@PerlDef:
1964 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
1965     my $resURI;
1966     if (defined $forArg) {
1967     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
1968     $uri => $resURI}__;
1969     } else {
1970     $resURI = $resourceURI;
1971     }
1972 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
1973     $r = $self->{resDef}->{$resURI};
1974     } else {
1975     $r = $self->{resDef}->{$resURI}
1976     = bless {
1977     uri => $resURI,
1978 wakaba 1.6 aliasURI => {$resURI => true},
1979 wakaba 1.2 subOf => {},
1980     supOf => {},
1981     db => $self,
1982     for => <Q::ManakaiDOM:all>,
1983     forp => [],
1984 wakaba 1.9 seq => -1,
1985 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
1986     require Scalar::Util;
1987     Scalar::Util::weaken ($r->{db});
1988     }
1989 wakaba 1.3
1990     @Method:
1991     @@Name: getSourceFile
1992     @@enDesc:
1993     Gets <QUOTE::dis> source document.
1994     @@Param:
1995     @@@Name: fileName
1996     @@@Type: FileURI
1997     @@@enDesc:
1998     A URI reference identifying a file.
1999     @@Return:
2000     @@@Type: ManakaiDISDocument
2001     @@@enDesc:
2002     The <QUOTE::dis> source document.
2003     @@@nullCase:
2004     @@@@enDesc:
2005     No document associated with that <P::fileName>.
2006     @@@PerlDef:
2007     $r = $self->{<Q::sourceFile>}->{$fileName};
2008     @Method:
2009     @@Name: setSourceFile
2010     @@enDesc:
2011     Puts <QUOTE::dis> source document object.
2012     @@Param:
2013     @@@Name: fileName
2014     @@@Type: FileURI
2015     @@@enDesc:
2016 wakaba 1.4 A URI reference identifying a file. If there is already a
2017 wakaba 1.3 source document, then the association has been updated.
2018     @@Param:
2019     @@@Name: doc
2020     @@@Type: ManakaiDISDocument
2021     @@@enDesc:
2022     The document object to set.
2023     @@Return:
2024     @@@PerlDef:
2025     $self->{<Q::sourceFile>}->{$fileName} = $doc;
2026 wakaba 1.4
2027     @Method:
2028     @@Name: loadModule
2029     @@enDesc:
2030     Loads definitions from a <QUOTE::dis> document.
2031     @@Param:
2032     @@@Name: doc
2033     @@@Type:ManakaiDISDocument
2034     @@@enDesc:
2035     The source <QUOTE::dis> document object. Its
2036     <A::ManakaiDISDocument.disDatabase> must be this database.
2037     @@Param:
2038     @@@Name: resolver
2039     @@@Type: DISModuleResolver
2040     @@@enDesc:
2041     The resolver to convert module name into <QUOTE::dis> document object.
2042     @@ForParam:
2043     @@Return:
2044     @@@RaiseException:
2045     @@@@@: NO_MODULE_QNAME_ERR
2046     @@@@enDesc:
2047     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2048     @@@RaiseException:
2049     @@@@@: UNABLE_TO_GET_MODULE_ERR
2050     @@@@enDesc:
2051     The implementation is unable to get a module source.
2052 wakaba 1.5 @@@ForDefDupException:
2053     @@@ForDefNoQNameException:
2054     @@@ResDefDupException:
2055     @@@ElementNotAllowedException:
2056 wakaba 1.7 @@@RaiseException:
2057     @@@@@:NO_REQUIRED_ATTR_ERR
2058     @@@@enDesc:
2059     The <Q::dis:Module> element does not have
2060     <Q::dis:Namespace> attribute.
2061 wakaba 1.4 @@@PerlDef:
2062     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2063     if ref $resolver eq 'CODE';
2064     ## -- Module Name, URI
2065     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2066     my $mod_node;
2067     my $mod_name_node;
2068     __DEEP{
2069     $mod_node = $doc-><AG::ManakaiDISDocument.moduleElement>;
2070     $mod_name_node = $mod_node-><M::swcfg21:SWCFGNode
2071     ::swcfg21:ForLatest.getAttributeNS>
2072     (<Q::dis:>, 'QName');
2073     unless ($mod_name_node) {
2074     __UNDEEP{
2075     __EXCEPTION{NO_MODULE_QNAME_ERR::
2076     DIS:sourceNode => {$mod_node},
2077     }__;
2078     }__;
2079     }
2080 wakaba 1.5 my $mod_name_uri = $mod_name_node
2081     -><AG::ManakaiDISElement.qnameValueURI>;
2082 wakaba 1.9 my $mod = $self-><M::ManakaiDISDatabase.getModule>
2083     ($mod_name_uri, for_arg => $forArg);
2084 wakaba 1.4
2085 wakaba 1.14 unless ($mod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2086 wakaba 1.4 ## -- Initializes Module Definition Object
2087     $mod->{nameURI} = $mod_name_uri;
2088     $mod->{localName} = $mod_name_node-><AG::ManakaiDISElement
2089     .qnameValueLocalName>;
2090     $mod->{namespaceURI} = $mod_name_node-><AG::ManakaiDISElement
2091     .qnameValueNamespaceURI>;
2092     $mod->{for} = $forArg;
2093     $mod->{src} = $mod_node;
2094 wakaba 1.5 $mod->{<Q::isDefined>} = true;
2095 wakaba 1.4 $self-><M::ManakaiDISDatabase.setSourceFile>
2096 wakaba 1.5 ($mod->{nameURI} => $doc);
2097    
2098 wakaba 1.9 $mod->{<Q::DIS:sourceFile>}
2099     = $mod->{src}
2100     -><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.ownerDocument>
2101     -><M::swcfg21:SWCFGNode::swcfg21:ForLatest.flag>
2102     (<Q::swcfg21:fileName>);
2103 wakaba 1.5
2104 wakaba 1.12 ## -- Loads "for" definition
2105     my $root_elements
2106     = $doc-><M::ManakaiDISDocument.disAllChildElements>;
2107     if ($mod->{for} eq <Q::ManakaiDOM:all>) {
2108     for my $el (@$root_elements) {
2109 wakaba 1.14 next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2110 wakaba 1.12 .expandedURI> eq <Q::dis:ForDef>;
2111     $self-><M::ManakaiDISDatabase.loadFor> ($mod, $el);
2112     }
2113     }
2114    
2115 wakaba 1.5 ## -- Loads "for all"
2116 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2117     ($mod->{nameURI}, for_arg => <Q::ManakaiDOM:all>);
2118 wakaba 1.5 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2119     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2120 wakaba 1.9 ($self, $rmod->{uri}, $mod->{namespaceURI},
2121     $mod->{localName}, <Q::ManakaiDOM:all>);
2122 wakaba 1.5 unless ($rdoc) {
2123     __UNDEEP{
2124     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2125 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2126 wakaba 1.5 DIS:namespaceURI => {$mod->{namespaceURI}},
2127     DIS:localName => {$mod->{localName}},
2128 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2129 wakaba 1.5 DIS:sourceNode => {$mod->{src}},
2130     }__;
2131     }__;
2132     }
2133     $self-><M::ManakaiDISDatabase.loadModule>
2134 wakaba 1.9 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>);
2135 wakaba 1.5 } # Unless "for all" loaded
2136 wakaba 1.4
2137     ## -- Loads Required Modules
2138 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2139 wakaba 1.4 my $req_node = $mod_node-><AG::ManakaiDISModuleElement
2140     .requireElement>;
2141 wakaba 1.10 for my $rm (@{$req_node-><M::ManakaiDISElement
2142     .disAllChildElements>}) {
2143 wakaba 1.4 next unless $rm-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2144     .expandedURI> eq <Q::dis:Module>;
2145     my ($uri, $nuri, $ln, $for);
2146 wakaba 1.14 my $mqn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2147 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'QName');
2148     if ($mqn) {
2149 wakaba 1.14 my $mqv = $mqn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2150 wakaba 1.4 .value>;
2151 wakaba 1.14 my $mqp = $mqn-><M::ManakaiDISElement.qnameToPair>
2152 wakaba 1.4 ($mqv, node => $mqn);
2153     ($nuri, $ln) = @$mqp;
2154     } else {
2155 wakaba 1.14 my $mn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2156 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'Name');
2157     if ($mn) {
2158     $nuri = $mod->{namespaceURI};
2159 wakaba 1.14 $ln = $mn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2160 wakaba 1.4 } else {
2161     $nuri = $mod->{namespaceURI};
2162     $ln = $mod->{localName};
2163     }
2164     }
2165 wakaba 1.14 my $wfn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2166 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'WithFor');
2167     if ($wfn) {
2168     $for = $wfn-><AG::ManakaiDISElement.qnameValueURI>;
2169     } else {
2170     $for = $mod->{for};
2171     }
2172 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2173     ($nuri . $ln, for_arg => $for);
2174 wakaba 1.4 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2175     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2176 wakaba 1.9 ($self, $rmod->{uri}, $nuri, $ln, $for);
2177 wakaba 1.4 unless ($rdoc) {
2178     __UNDEEP{
2179     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2180 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2181 wakaba 1.4 DIS:namespaceURI => {$nuri},
2182     DIS:localName => {$ln},
2183     DIS:for => {$for},
2184     DIS:sourceNode => {$rm},
2185     }__;
2186     }__;
2187     }
2188     $self-><M::ManakaiDISDatabase.loadModule>
2189     ($rdoc, $resolver, for_arg => $for);
2190     }
2191     } # Child Module elements
2192    
2193 wakaba 1.12 ## -- Loads child resources
2194 wakaba 1.10 $root_elements = $doc-><M::ManakaiDISDocument.disChildElements>
2195     (for_arg => $forArg);
2196 wakaba 1.5 for my $el (@$root_elements) {
2197 wakaba 1.11 if ($el-><AG::ManakaiDISElement.isResourceElement>) {
2198 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2199 wakaba 1.9 ($mod, null, null, $el,
2200 wakaba 1.7 for_arg => $forArg);
2201     } else {
2202 wakaba 1.14 my $et = $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2203 wakaba 1.7 .expandedURI>;
2204     if ({
2205 wakaba 1.5 <Q::dis:ForDef> => 1,
2206     <Q::dis:Module> => 1,
2207     <Q::dis:ImplNote> => 1,
2208 wakaba 1.7 }->{$et}) {
2209     #
2210     } else {
2211     __UNDEEP{
2212     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2213     DIS:elementType => {$et},
2214     DIS:sourceNode => {$el},
2215     DIS:uri => {$mod->{uri}},
2216     }__;
2217 wakaba 1.5 }__;
2218 wakaba 1.7 }
2219     } # element types
2220     }
2221    
2222     my $dn = $mod_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2223     .getAttributeNS>
2224     (<Q::dis:>, 'Namespace');
2225 wakaba 1.14 unless ($dn and defined $dn-><M::swcfg21:SWCFGNode
2226     ::swcfg21:ForLatest.value>) {
2227 wakaba 1.7 __UNDEEP{
2228     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2229     DIS:elementType => {<Q::dis:Namespace>},
2230     DIS:sourceNode => {$mod_node},
2231 wakaba 1.5 }__;
2232 wakaba 1.7 }__;
2233 wakaba 1.5 }
2234     } # Unless this module loaded
2235     }__; # Deep
2236    
2237     @Method:
2238     @@Name: loadFor
2239     @@enDesc:
2240     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2241     @@Param:
2242     @@@Name: mod
2243     @@@Type: ManakaiDISModuleDefinition
2244     @@@enDesc:
2245     The module in which the <QUOTE::for> to load is defined.
2246     @@Param:
2247     @@@Name: el
2248     @@@Type:ManakaiDISElement
2249     @@@enDesc:
2250     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2251     @@Return:
2252     @@@ForDefDupException:
2253     @@@ForDefNoQNameException:
2254     @@@ElementNotAllowedException:
2255     @@@PerlDef:
2256     __DEEP{
2257     my $qn_node = $el-><M::swcfg21:SWCFGNode
2258     ::swcfg21:ForLatest.getAttributeNS>
2259     (<Q::dis:>, 'QName');
2260     unless ($qn_node) {
2261     __UNDEEP{
2262     __EXCEPTION{NO_FOR_QNAME_ERR::
2263     DIS:sourceNode => {$qn_node},
2264     }__;
2265     }__;
2266     }
2267     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2268     my $for = $self-><M::ManakaiDISDatabase.getFor> ($qn_uri);
2269    
2270 wakaba 1.14 unless ($for-><AG::ManakaiDISForDefinition.isDefined>) {
2271 wakaba 1.10 ## -- Initializes "For" Definition Object
2272 wakaba 1.5 $for->{src} = $el;
2273     $for->{<Q::isDefined>} = true;
2274     $for->{<Q::definingModule>} = $mod->{uri};
2275    
2276 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2277 wakaba 1.5 my $xn = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2278     .expandedURI>;
2279     if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2280     my $sfor = $self-><M::ManakaiDISDatabase.getFor>
2281 wakaba 1.7 ($ce-><AG::ManakaiDISElement.qnameValueURI>);
2282 wakaba 1.5 $for-><M::ManakaiDISForDefinition.addISA> ($sfor);
2283 wakaba 1.14 $sfor-><AS::ManakaiDISForDefinition.isReferred> ($ce);
2284 wakaba 1.5 ## TODO: warn if dis:Implement
2285     } elsif ({
2286     <Q::dis:Description> => 1,
2287     <Q::dis:ImplNote> => 1,
2288     <Q::dis:FullName> => 1,
2289     <Q::dis:QName> => 1,
2290     }->{$xn}) {
2291     #
2292     } else {
2293     __UNDEEP{
2294     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2295     DIS:elementType => {$xn},
2296     DIS:sourceNode => {$ce},
2297     DIS:uri => {$mod->{uri}},
2298     }__;
2299     }__;
2300     }
2301     }
2302     } else {
2303     __UNDEEP{
2304     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
2305     DIS:sourceNode => {$el},
2306     DIS:anotherSourceNode => {$for->{src}},
2307     }__;
2308     }__;
2309     } # isDefine?
2310     }__; # DEEP
2311    
2312     @Method:
2313     @@Name: loadResource
2314     @@enDesc:
2315     Loads definition of a <QUOTE::dis> resource from a
2316     <Q::dis:ResourceDef> element.
2317     @@Param:
2318     @@@Name: mod
2319     @@@Type: ManakaiDISModuleDefinition
2320     @@@enDesc:
2321     The module in which the resource to load is defined.
2322     @@Param:
2323     @@@Name: parentResource
2324     @@@Type: ManakaiDISResourceDefinition
2325     @@@enDesc:
2326 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
2327 wakaba 1.5 @@@nullCase:
2328     @@@@enDesc:
2329     The resource to load is a root resource, i.e. <P::el> is
2330     a direct child of the document node.
2331     @@Param:
2332 wakaba 1.7 @@@Name: dynParent
2333 wakaba 1.9 @@@Type: ManakaiDISResourceDefinition
2334 wakaba 1.7 @@@enDesc:
2335     The dynamic parent resource of the resource to load.
2336 wakaba 1.9 @@@nullCase:
2337 wakaba 1.7 @@@@enDesc:
2338 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
2339     a direct child of the document node.
2340 wakaba 1.7 @@Param:
2341 wakaba 1.5 @@@Name: el
2342     @@@Type:ManakaiDISElement
2343     @@@enDesc:
2344     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
2345     @@ForParam:
2346     @@ForpParam:
2347     @@Return:
2348     @@@ResDefDupException:
2349     @@@ElementNotAllowedException:
2350     @@@PerlDef:
2351     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2352     $forpArg ||= [];
2353     __DEEP{
2354 wakaba 1.6 ## -- Node names
2355    
2356     ## Unique resource identifier generated from node id
2357     my $node_id = $el-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.nodeID>;
2358     my $node_uri;
2359     __CODE{tfpurisToURI:: $turi => $node_id, $furi => $forArg,
2360     $forp => $forpArg, $uri => $node_uri}__;
2361    
2362     ## User defined resource identifiers
2363 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
2364     (<Q::dis:QName>, for_arg => $forArg,
2365     forp_arg => $forpArg);
2366     my $res;
2367     if ($qn_node) {
2368     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2369 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2370     ($qn_uri, for_arg => $forArg);
2371 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2372 wakaba 1.5 __UNDEEP{
2373     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2374 wakaba 1.9 DIS:uri => {$res->{uri}},
2375 wakaba 1.5 DIS:sourceNode => {$qn_node},
2376     DIS:anotherSourceNode => {$res->{src}},
2377     }__;
2378 wakaba 1.6 }__;
2379 wakaba 1.5 }
2380     $res->{nameURI} = $qn_uri;
2381     $res->{localName} = $qn_node-><AG::ManakaiDISElement
2382     .qnameValueLocalName>;
2383     $res->{namespaceURI} = $qn_node-><AG::ManakaiDISElement
2384     .qnameValueNamespaceURI>;
2385     } else { ## Anonymous or local
2386     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
2387     (<Q::dis:Name>, for_arg => $forArg,
2388     forp_arg => $forpArg);
2389     if ($n_node) {
2390     if ($parentResource) {
2391     my $puri = $parentResource->{uri};
2392     my $ru;
2393 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2394     ::swcfg21:ForLatest.value>;
2395 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
2396     $localName => $ln,
2397     $result => $ru}__;
2398 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2399     ($ru, for_arg => $forArg);
2400 wakaba 1.5 $res->{nameURI} = $ru;
2401 wakaba 1.14 $res->{localName} = $n_node-><M::swcfg21:SWCFGNode
2402     ::swcfg21:ForLatest.value>;
2403 wakaba 1.5 $res->{<Q::isAnon>} = true;
2404     } else { ## Root local name resource
2405 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2406 wakaba 1.7 ::swcfg21:ForLatest.value>;
2407     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
2408     .getPropertyText>
2409     (<Q::dis:Namespace>, null);
2410     my $qn_uri = $ns_uri . $ln;
2411 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2412     ($qn_uri, for_arg => $forArg);
2413 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2414 wakaba 1.6 __UNDEEP{
2415     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2416 wakaba 1.9 DIS:uri => {$res->{uri}},
2417 wakaba 1.6 DIS:sourceNode => {$n_node},
2418     DIS:anotherSourceNode => {$res->{src}},
2419     }__;
2420     }__;
2421     }
2422     $res->{nameURI} = $qn_uri;
2423 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
2424     $res->{localName} = $ln;
2425 wakaba 1.5 }
2426     } else {
2427 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2428 wakaba 1.5 $res->{<Q::isAnon>} = true;
2429     }
2430 wakaba 1.6 } # anon
2431 wakaba 1.5 $res->{for} = $forArg;
2432     $res->{forp} = $forpArg;
2433     $res->{src} = $el;
2434     $res->{<Q::definingModule>} = $mod->{uri};
2435 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
2436     (<Q::DIS:resource>, $res);
2437 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
2438     = $parentResource ? $parentResource->{uri} : null;
2439     $res->{<Q::dynamicParentResource>}
2440 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
2441     unless ($res->{uri} eq $node_uri) {
2442     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2443     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
2444     }
2445 wakaba 1.7 $res->{<Q::isDefined>} = true;
2446 wakaba 1.9 $res->{seq} = $self->{seq}++;
2447    
2448 wakaba 1.6 ## -- Alias
2449     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
2450     (<Q::dis:AliasFor>, for_arg => $forArg,
2451     forp_arg => $forpArg);
2452     if ($al_node) {
2453     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
2454     ($node_id, $forArg);
2455     my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
2456     ($canon_uri);
2457 wakaba 1.14 $canon_res-><AS::ManakaiDISResourceDefinition.isReferred> ($al_node);
2458 wakaba 1.11 $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias>
2459     ($res, node => $al_node);
2460 wakaba 1.6 $res = $canon_res;
2461     }
2462 wakaba 1.5
2463 wakaba 1.11 ## -- Registers as child
2464     $parentResource-><M::ManakaiDISPropertyAccessor
2465     .addPropertyResourceList>
2466     (<Q::DIS:childResource>, $res)
2467     if $parentResource;
2468     $dynParent-><M::ManakaiDISPropertyAccessor
2469     .addPropertyResourceList>
2470     (<Q::DIS:dynamicChildResource>, $res)
2471     if $dynParent;
2472    
2473 wakaba 1.7 my $is_multires = false;
2474     my @props;
2475     my @cres;
2476 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
2477     (for_arg => $forArg, forp_arg => $forpArg)};
2478 wakaba 1.7 while (@ce0) {
2479     my $ce = shift @ce0;
2480     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
2481     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
2482     $res->{<Q::rdf:type>}->{$type_uri} = true;
2483     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
2484 wakaba 1.14 $type-><AS::ManakaiDISResourceDefinition.isReferred> ($ce);
2485 wakaba 1.7 if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
2486     (<Q::dis:MultipleResource>)) {
2487     $is_multires = true;
2488     }
2489     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
2490     (<Q::dis:subsetOf>)) {
2491     my $sres = $self-><M::ManakaiDISDatabase.getResource>
2492     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
2493     ($node_id, $forArg));
2494     $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
2495 wakaba 1.11 } elsif ($ce-><AG::ManakaiDISElement.isResourceElement>) {
2496 wakaba 1.7 push @cres, $ce;
2497     } else {
2498     ## Property and invalid element is not checked, since not
2499     ## all property definitions has loaded at this stage.
2500     push @props, $ce;
2501     }
2502     } # @ce0
2503    
2504     ## -- Child resources
2505     unless ($is_multires) {
2506     for my $re (@cres) {
2507     unless ($al_node) {
2508     $self-><M::ManakaiDISDatabase.loadResource>
2509     ($mod, $res, $res, $re,
2510     for_arg => $forArg, forp_arg => $forpArg);
2511 wakaba 1.5 } else {
2512 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
2513     (<Q::dis:aliasChild>, for_arg => $forArg,
2514     forp_arg => $forpArg);
2515     if ($ac and $ac-><M::swcfg21:SWCFGNode
2516     ::swcfg21:ForLatest.value>) {
2517     $self-><M::ManakaiDISDatabase.loadResource>
2518     ($mod, $res, $res, $re,
2519     for_arg => $forArg, forp_arg => $forpArg);
2520     }
2521 wakaba 1.4 }
2522     }
2523 wakaba 1.7 }
2524 wakaba 1.5
2525 wakaba 1.7 ## -- Multiple representations
2526     if ($is_multires) {
2527     for my $pe (@props) {
2528     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
2529 wakaba 1.10 (<Q::dis:resourceFor>)) {
2530 wakaba 1.14 my $for_uri = $pe-><AG::ManakaiDISElement.qnameValueURI>;
2531 wakaba 1.7 my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
2532 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($pe);
2533 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2534     ($mod, $parentResource, $res, $el,
2535     for_arg => $forArg,
2536     forp_arg => [@{$forpArg}, $for_uri]);
2537     }
2538     }
2539     }
2540 wakaba 1.5 }__; # DEEP
2541 wakaba 1.8
2542     @Method:
2543     @@Name: checkUndefinedResource
2544     @@enDesc:
2545     Checks whether there is referred but undefined resource or not.
2546     @@Return:
2547     @@@RaiseException:
2548     @@@@@: FOR_NOT_DEFINED_ERR
2549     @@@@enDesc:
2550     There is a <QUOTE::for> that is referred but not defined.
2551     @@@RaiseException:
2552     @@@@@: RESOURCE_NOT_DEFINED_ERR
2553     @@@@enDesc:
2554     There is a resource that is referred but not defined.
2555     @@@PerlDef:
2556     for my $fd (values %{$self->{forDef}}) {
2557     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
2558     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
2559     __EXCEPTION{FOR_NOT_DEFINED_ERR::
2560     DIS:uri => {$fd->{uri}},
2561     DIS:sourceNode => {$ref},
2562     }__;
2563     }
2564     }
2565     for my $fd (values %{$self->{resDef}}) {
2566     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
2567     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
2568     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2569     DIS:uri => {$fd->{uri}},
2570     DIS:sourceNode => {$ref},
2571     }__;
2572     }
2573     }
2574 wakaba 1.5
2575 wakaba 1.9
2576     @Method:
2577     @@Name: plStore
2578     @@enDesc:
2579     Saves this database to an external file.
2580     \
2581     {NOTE:: Saved files can be loaded by
2582     <M::ManakaiDISImplementation.plLoadDISDatabase>.
2583     \
2584     }
2585     @@Param:
2586     @@@Name: fileName
2587     @@@Type:
2588     DISLang:String
2589     @@@enDesc:
2590     An environment-dependent file name of external database to save.
2591     \
2592     {NOTE:: If there is already a file named as <P::fileName>, then
2593     it is overwritten.
2594     \
2595     }
2596     @@Return:
2597     @@@SimpleException:
2598     @@@PerlDef:
2599     use Storable qw/nstore/;
2600     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
2601     nstore $self, $fileName;
2602 wakaba 1.15
2603     @Method:
2604     @@Name: xcrefToResource
2605     @@enDesc:
2606     Returns a resource object selected by an exception code
2607     reference (<Q::DOMMain:XCodeRef>).
2608     @@Param:
2609     @@@Name: xcref
2610     @@@Type:
2611     DOMMain:XCodeRef::ManakaiDOM:all
2612     @@@enDesc:
2613     Exception code to select.
2614     @@Param:
2615     @@@Name: contextNode
2616     @@@Type: ManakaiDISElement
2617     @@@enDesc:
2618     A context element node. Namespace prefixes in
2619     <P::xcref> are resolved against this node.
2620 wakaba 1.16 @@ForParam:
2621 wakaba 1.15 @@NodeParam:
2622     @@Return:
2623     @@@Type:
2624     Perl:ARRAY::ManakaiDOM:all
2625     @@@enDesc:
2626     A reference to the array containing two or three
2627     resource definitions (<Class::ManakaiDISResourceDefinition>).
2628     The first (index <CODE::0>) resource is an exception class.
2629     The second (index <CODE::1>) resource is an exception code
2630     constant. The third (index <CODE::2>) resource
2631     is an exception subtype or <DOM::null> if the reference identifies
2632     no subtype.
2633     @@@RaiseException:
2634     @@@@@: RESOURCE_NOT_DEFINED_ERR
2635     @@@@enDesc:
2636     The resource identified by the <P::xcref> is not defined
2637     or not an exception.
2638     @@@PerlDef:
2639     my ($q1, $q2, $q3) = split /\s*\.\s*/, $xcref, 3;
2640     my $r = [];
2641     __DEEP{
2642     if (defined $q3) {
2643     $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
2644 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2645     ($q3, null, $forArg, node => $node));
2646 wakaba 1.15 $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
2647     .getPropertyResource>
2648     (<Q::dis2pm:parentResource>);
2649     } elsif (defined $q2) {
2650     if ($q2 =~ /:/) {
2651     $r->[1] = $self-><M::ManakaiDISDatabase.getResource>
2652 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2653     ($q2, null, $forArg, node => $node));
2654 wakaba 1.15 } else {
2655     $r->[0] = $self-><M::ManakaiDISDatabase.getResource>
2656 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2657     ($q1, null, $forArg, node => $node));
2658 wakaba 1.15 $r->[1] = $r->[0]-><M::ManakaiDISResourceDefinition
2659     .getConstResourceByName> ($q2);
2660     }
2661 wakaba 1.16 } else { ## $q1 only
2662 wakaba 1.15 $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
2663 wakaba 1.16 ($contextNode-><M::ManakaiDISElement.tfqnamesToURI>
2664     ($q1, null, $forArg, node => $node));
2665 wakaba 1.15 if ($r->[2]-><M::ManakaiDISResourceDefinition
2666     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
2667     $r->[1] = $r->[2]-><M::ManakaiDISPropertyAccessor
2668     .getPropertyResource>
2669     (<Q::dis2pm:parentResource>);
2670     } else {
2671     $r->[1] = $r->[2]; CORE::delete $r->[2];
2672     }
2673     }
2674    
2675     if ($r->[2] and
2676     not $r->[2]-><M::ManakaiDISResourceDefinition
2677     .isTypeURI> (<Q::ManakaiDOM:ExceptionOrWarningSubType>)) {
2678     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2679     DIS:uri => {$r->[2]->{uri}},
2680     DIS:expectedType => {<Q::ManakaiDOM:ExceptionOrWarningSubType>},
2681     DIS:sourceNode => {$node},
2682     DIS:sourceCode => {$xcref},
2683     }__}__;
2684     }
2685 wakaba 1.16 $r->[2]-><AS::ManakaiDISResourceDefinition.isReferred>
2686     ($node or $contextNode)
2687     if $r->[2];
2688 wakaba 1.15
2689     if (not $r->[1] or
2690     not $r->[1]-><M::ManakaiDISResourceDefinition
2691     .isTypeURI> (<Q::ManakaiDOM:Const>)) {
2692     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2693     DIS:uri => {$r->[1]->{uri}},
2694     DIS:localName => {$r->[1]->{localName}},
2695     DIS:expectedType => {<Q::ManakaiDOM:Const>},
2696     DIS:sourceNode => {$node},
2697     DIS:sourceCode => {$xcref},
2698     }__}__;
2699     }
2700 wakaba 1.16 $r->[1]-><AS::ManakaiDISResourceDefinition.isReferred>
2701 wakaba 1.15 ($node or $contextNode);
2702    
2703     unless ($r->[0]) {
2704     my $cg = $r->[1]-><M::ManakaiDISPropertyAccessor
2705     .getPropertyResource>
2706     (<Q::dis2pm:parentResource>);
2707     $r->[0] = $cg-><M::ManakaiDISPropertyAccessor
2708     .getPropertyResource>
2709     (<Q::dis2pm:parentResource>) if $cg;
2710     }
2711     if (not $r->[0] or
2712     not $r->[0]-><M::ManakaiDISResourceDefinition
2713 wakaba 1.16 .isTypeURI> (<Q::DOMException:AnyExceptionClass>)) {
2714 wakaba 1.15 __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2715     DIS:uri => {$r->[0]->{uri}},
2716     DIS:localName => {$r->[0]->{localName}},
2717 wakaba 1.16 DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
2718 wakaba 1.15 DIS:sourceNode => {$node},
2719     DIS:sourceCode => {$xcref},
2720     }__}__;
2721     }
2722 wakaba 1.16 $r->[0]-><AS::ManakaiDISResourceDefinition.isReferred>
2723 wakaba 1.15 ($node or $contextNode);
2724     }__;
2725 wakaba 1.2 ##DISDatabase
2726    
2727 wakaba 1.8 PropDef:
2728 wakaba 1.9 @QName: resource
2729     @enDesc:
2730     Resources defined in a module.
2731     @rdfs:range: ManakaiDISResourceDefinition
2732     @rdfs:domain: ManakaiDISModuleDefinition
2733    
2734     PropDef:
2735 wakaba 1.8 @QName:
2736     dis2pm:parentResource
2737     @enDesc:
2738     Static parent resource. No parent for root resources.
2739    
2740     PropDef:
2741     @QName: dynamicParentResource
2742     @enDesc:
2743     Dynamic parent resource. No parent for root resources.
2744    
2745 wakaba 1.11 PropDef:
2746     @QName: childResource
2747     @enDesc:
2748     Static child resources.
2749    
2750     PropDef:
2751     @QName: dynamicChildResource
2752     @enDesc:
2753     Dynamic child resources.
2754    
2755 wakaba 1.5 ElementTypeBinding:
2756     @Name: ForDefDupException
2757     @ElementType:
2758     ManakaiDOM:raises
2759     @ShadowContent:
2760     @@@: FOR_ALREADY_DEFINED_ERR
2761     @@Description:
2762     @@@lang:en
2763     @@@@:
2764     The <QUOTE::for> is already defined elsewhere.
2765    
2766     ElementTypeBinding:
2767     @Name: ForDefNoQNameException
2768     @ElementType:
2769     ManakaiDOM:raises
2770     @ShadowContent:
2771     @@@: NO_FOR_QNAME_ERR
2772     @@Description:
2773     @@@lang:en
2774     @@@@:
2775     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
2776    
2777     ElementTypeBinding:
2778     @Name: ResDefDupException
2779     @ElementType:
2780     ManakaiDOM:raises
2781     @ShadowContent:
2782     @@@: RESOURCE_ALREADY_DEFINED_ERR
2783     @@Description:
2784     @@@lang:en
2785     @@@@:
2786     The <QUOTE::dis> resource is already defined elsewhere.
2787    
2788     ElementTypeBinding:
2789     @Name: ElementNotAllowedException
2790     @ElementType:
2791     ManakaiDOM:raises
2792     @ShadowContent:
2793     @@@: ELEMENT_NOT_ALLOWED_ERR
2794     @@Description:
2795     @@@lang:en
2796     @@@@:
2797     An element has found where it is not allowed.
2798    
2799 wakaba 1.4 IFClsDef:
2800     @QName:
2801     @@@: DISModuleResolver
2802     @@ForCheck: ForIF
2803     @QName:
2804     @@@: ManakaiDISModuleResolver
2805     @@ForCheck: ForClass
2806     @enDesc:
2807     Objects implementing <IF::DISModuleResolver> interface
2808     are used to convert module name into <QUOTE::dis> document object.
2809     \
2810     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
2811     as a method parameter where <IF::DISModuleResolver> is
2812     expected.
2813     \
2814     }
2815     @Method:
2816     @@Name: uriToDocument
2817     @@enDesc:
2818     Returns a <QUOTE::dis> document from module name information.
2819     @@Param:
2820     @@@Name: disDB
2821     @@@Type: ManakaiDISDatabase
2822     @@@enDesc:
2823     The <QUOTE::dis> database.
2824     @@Param:
2825     @@@Name: moduleURI
2826     @@@Type: ModuleURI
2827     @@@enDesc:
2828     The URI reference of the module.
2829     \
2830     {NOTE:: This parameter is redundant, since it can be
2831     composed from other three parameters.
2832     \
2833     }
2834     @@Param:
2835     @@@Name: moduleNamespaceURI
2836     @@@Type: AnyURI
2837     @@@enDesc:
2838     The namespace URI of the module name.
2839     @@Param:
2840     @@@Name: moduleLocalName
2841     @@@Type:
2842     DISCore:LocalName
2843     @@@enDesc:
2844     The local name of the module name.
2845     @@Param:
2846     @@@Name: moduleFor
2847     @@@Type: ForURI
2848     @@@enDesc:
2849     The <QUOTE::for> URI reference for which the module is defined.
2850     @@Return:
2851     @@@Type: ManakaiDISDocument
2852     @@@enDesc:
2853     The <QUOTE::dis> document. It don't have to be a newly created
2854     object.
2855     @@@nullCase:
2856     @@@@enDesc:
2857     The method is unable to resolve the reference.
2858     @@@PerlDef:
2859     $r = $self->(@_);
2860     @ManakaiDOM:inputNormalizer:
2861     @@ContentType:
2862     lang:Perl
2863     @@@:
2864     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
2865     if ref $INPUT eq 'CODE';
2866     @@ImplNote:
2867     @@@lang:en
2868     @@@@:
2869     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
2870     ##DISModuleResolver
2871    
2872 wakaba 1.3 PropDef:
2873     @QName: sourceFile
2874     @enDesc:
2875     Source <QUOTE::dis> documents.
2876     @rdfs:domain: ManakaiDISDatabase
2877     @rdfs:range: ManakaiDISDocument
2878    
2879 wakaba 1.2 ClsDef:
2880     @ClsQName: ManakaiDISModuleDefinition
2881     @enDesc:
2882     <QUOTE::dis> module definitions.
2883     @ClsISA: ManakaiDISPropertyAccessor
2884 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2885 wakaba 1.2
2886     @Attr:
2887     @@Name: uri
2888     @@Type: ModuleURI
2889     @@Description:
2890     @@@lang:en
2891     @@@@:
2892     The URI reference of this <QUOTE::dis> module.
2893     @@Get:
2894     @@@PerlDef:
2895     $r = $self->{uri};
2896    
2897     @Attr:
2898     @@Name: nameURI
2899     @@Type: NameURI
2900     @@enDesc:
2901     The URI reference of this module, without
2902     <QUOTE::for> identifier.
2903     @@Get:
2904 wakaba 1.3 @@@PerlDef:
2905 wakaba 1.4 $r = $self->{nameURI};
2906 wakaba 1.2
2907     @Attr:
2908     @@Name: localName
2909     @@enDesc:
2910     The local name of this module.
2911     @@Type:
2912 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
2913 wakaba 1.2 @@Get:
2914     @@@PerlDef:
2915     $r = $self->{localName};
2916    
2917     @Attr:
2918     @@Name: namespaceURI
2919     @@Type: AnyURI
2920     @@enDesc:
2921     The namespace URI of the name of this resource.
2922     @@Get:
2923     @@@PerlDef:
2924     $r = $self->{namespaceURI};
2925    
2926     @Attr:
2927     @@Name: forURI
2928     @@Type: ForURI
2929     @@enDesc:
2930     The <QUOTE::for> URI reference for which this module is defined.
2931     @@Get:
2932     @@@PerlDef:
2933     $r = $self->{for};
2934    
2935     @Attr:
2936     @@Name: isDefined
2937     @@Description:
2938     @@@lang:en
2939     @@@@:
2940     Whether this module is defined or not.
2941     @@Type:
2942     DOMMain:boolean
2943     @@Get:
2944     @@@PerlDef:
2945     $r = $self->{<Q::isDefined>};
2946 wakaba 1.8
2947     @Attr:
2948     @@Name: plFullyQualifiedName
2949     @@enDesc:
2950     The fully-qualified Perl class package name.
2951     @@Type:
2952     Perl:package-name::ManakaiDOM:all
2953     @@Get:
2954     @@@NoPerlModuleNameException:
2955     @@@PerlDef:
2956     __DEEP{
2957     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2958     ($self->{namespaceURI});
2959     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2960     __UNDEEP{
2961     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2962     DIS:uri => {$self->{namespaceURI}},
2963     DIS:sourceNode => {$self->{src}},
2964     }__;
2965     }__;
2966     }
2967     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2968     (<Q::dis:AppName>, for_arg => $self->{for},
2969 wakaba 1.10 media_type => <Q::lang:Perl>,
2970     default_media_type => <Q::lang:Perl>);
2971 wakaba 1.8 if ($an) {
2972     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2973     $r =~ s/::$//g;
2974     $r .= '::' . $self->{localName};
2975     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2976     (<Q::ManakaiDOM:moduleSuffix>,
2977     for_arg => $self->{for},
2978     media_type => <Q::lang:Perl>,
2979     default_media_type => <Q::lang:Perl>);
2980     if ($sf) {
2981     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2982     }
2983     } else {
2984 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
2985 wakaba 1.8 }
2986     }__;
2987    
2988     @Attr:
2989     @@Name: plInterfaceName
2990     @@enDesc:
2991     The fully-qualified Perl interface package name.
2992     @@Type:
2993     Perl:package-name::ManakaiDOM:all
2994     @@Get:
2995     @@@NoPerlModuleNameException:
2996     @@@PerlDef:
2997     __DEEP{
2998     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2999     ($self->{namespaceURI});
3000     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
3001     __UNDEEP{
3002     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3003     DIS:uri => {$self->{namespaceURI}},
3004     DIS:sourceNode => {$self->{src}},
3005     }__;
3006     }__;
3007     }
3008     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
3009     (<Q::dis:AppName>, for_arg => $self->{for},
3010     forp_arg => [<Q::ManakaiDOM:ForIF>],
3011 wakaba 1.10 media_type => <Q::lang:Perl>,
3012     default_media_type => <Q::lang:Perl>);
3013 wakaba 1.8 if ($an) {
3014     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3015     $r =~ s/::$//g;
3016     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
3017     (<Q::ManakaiDOM:moduleSuffix>,
3018     for_arg => $self->{for},
3019     forp_arg => [<Q::ManakaiDOM:ForIF>],
3020     media_type => <Q::lang:Perl>,
3021     default_media_type => <Q::lang:Perl>);
3022     if ($sf) {
3023     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3024     }
3025     } else {
3026 wakaba 1.14 $r = $self-><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>;
3027 wakaba 1.8 }
3028     }__;
3029 wakaba 1.13
3030     @Method:
3031     @@Name: plAddRequireModule
3032     @@enDesc:
3033     Adds a <QUOTE::dis> module into the list of modules that
3034     defines a Perl module file referred by Perl module file
3035     defined by this module.
3036     @@Param:
3037     @@@Name: moduleArg
3038     @@@Type: ManakaiDISModuleDefinition
3039     @@@enDesc:
3040     A module definition.
3041     @@Return:
3042     @@@RaiseException:
3043     @@@@@: RESOURCE_NOT_DEFINED_ERR
3044     @@@@enDesc:
3045     The module group to which <P::moduleArg> belongs
3046     is not defined.
3047     @@@PerlDef:
3048     __DEEP{
3049     my $pack = $moduleArg-><AG::ManakaiDISModuleDefinition
3050     .plFullyQualifiedName>;
3051     $self->{<Q::DIS:plRequireModule>}->{$pack} = true;
3052     }__;
3053 wakaba 1.2 ##DISModuleDefinition
3054    
3055 wakaba 1.13 PropDef:
3056     @QName: plRequireModule
3057     @enDesc:
3058     A list of Perl package name that this resource is referring.
3059    
3060 wakaba 1.8 ElementTypeBinding:
3061     @Name: NoPerlModuleNameException
3062     @ElementType:
3063     ManakaiDOM:raises
3064     @ShadowContent:
3065     @@@: RESOURCE_NOT_DEFINED_ERR
3066     @@Description:
3067     @@@lang:en
3068     @@@@:
3069     The module group corresponding to the namespace URI
3070     of this module is not defined.
3071    
3072 wakaba 1.2 ClsDef:
3073     @ClsQName: ManakaiDISForDefinition
3074     @Description:
3075     @@lang:en
3076     @@@:
3077     <QUOTE::dis> <QUOTE::for> definitions.
3078 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3079 wakaba 1.2
3080     @Attr:
3081     @@Name: uri
3082     @@Type: ForURI
3083     @@Description:
3084     @@@lang:en
3085     @@@@:
3086     The URI reference of this <QUOTE::for>.
3087     @@Get:
3088     @@@PerlDef:
3089     $r = $self->{uri};
3090 wakaba 1.10
3091     @IntMethod:
3092     @@Operator:
3093     @@@@:eq
3094     @@@ContentType:
3095     lang:Perl
3096     @@enDesc:
3097     Whether two <QUOTE::for> definitions are equal or not.
3098     Two <QUOTE::for> definitions are equal iff one's URI reference
3099     is one of another's URI reference.
3100     \
3101     {NOTE:: Aliases for <QUOTE::for> is not allowed.
3102     \
3103     }
3104     @@ImplNote:
3105     @@@lang:en
3106     @@@@:
3107     In the current implementation, two are equal iff two are
3108     equal as reference.
3109     @@Param:
3110     @@@Name: anotherFor
3111     @@@Type: ManakaiDISForDefinition
3112     @@@enDesc:
3113     Another <QUOTE::for> definition to compare.
3114     @@Return:
3115     @@@Type:
3116     DOMMain:boolean
3117     @@@enDesc:
3118     Whether two resources are equal or not.
3119     @@@PerlDef:
3120     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
3121     $r = $self->{uri} eq $anotherFor->{uri};
3122     } else {
3123     $r = false;
3124     }
3125 wakaba 1.2
3126     @Method:
3127     @@Name: isaURI
3128     @@Description:
3129     @@@lang:en
3130     @@@@:
3131     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
3132     @@Param:
3133     @@@Name: superURI
3134     @@@Type: ForURI
3135     @@@Description:
3136     @@@@lang:en
3137     @@@@@:
3138     Another <QUOTE::for> URI reference to test.
3139     @@Return:
3140     @@@Type:
3141     DOMMain:boolean
3142     @@@TrueCase:
3143     @@@@enDesc:
3144     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
3145     @@@FalseCase:
3146     @@@@enDesc:
3147     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
3148     @@@PerlDef:
3149     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
3150    
3151     @Attr:
3152     @@Name: isDefined
3153     @@Description:
3154     @@@lang:en
3155     @@@@:
3156     Whether this <QUOTE::for> is already defined or not.
3157     @@Type:
3158     DOMMain:boolean
3159     @@Get:
3160     @@@TrueCase:
3161     This <QUOTE::for> is already defined.
3162     @@@FalseCase:
3163     This <QUOTE::for> is not defined.
3164     @@@PerlDef:
3165     $r = $self->{<Q::isDefined>};
3166    
3167     @Attr:
3168     @@Name: isReferred
3169     @@Description:
3170     @@@lang:en
3171     @@@@:
3172     Whether this <QUOTE::for> is referred somewhere or not.
3173 wakaba 1.9 @@Type: ManakaiDISElement
3174 wakaba 1.2 @@Get:
3175     @@@InCase:
3176     @@@@Type:ManakaiDISElement
3177     @@@@enDesc:
3178     This <QUOTE::for> is referred by the element.
3179     @@@nullCase:
3180     This <QUOTE::for> is not referred.
3181     @@@PerlDef:
3182     $r = $self->{<Q::isReferred>};
3183     @@Set:
3184     @@@InCase:
3185     @@@@Type:ManakaiDISElement
3186     @@@@enDesc:
3187     This <QUOTE::for> is referred by the element.
3188     @@@PerlDef:
3189 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3190 wakaba 1.2
3191     @Attr:
3192     @@Name: definingModule
3193     @@Description:
3194     @@@lang:en
3195     @@@@:
3196     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
3197     @@Type: ManakaiDISModuleDefinition
3198     @@Get:
3199     @@@Description:
3200     @@@@lang:en
3201     @@@@@:
3202     The module object.
3203 wakaba 1.3 @@@nullCase:
3204 wakaba 1.2 @@@@Description:
3205     @@@@@lang:en
3206     @@@@@@:
3207     This <QUOTE::for> is not associated to any module.
3208     @@@PerlDef:
3209     $r = $self->{db}
3210     -><M::ManakaiDISDatabase.getResource>
3211     ($self->{<Q::definingModule>})
3212     if defined $self->{<Q::definingModule>};
3213 wakaba 1.5
3214 wakaba 1.2 @Method:
3215 wakaba 1.5 @@Name: addISA
3216 wakaba 1.2 @@enDesc:
3217 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3218     <QUOTE::for>.
3219 wakaba 1.2 @@Param:
3220 wakaba 1.5 @@@Name: superFor
3221     @@@Type: ManakaiDISForDefinition
3222     @@@enDesc:
3223     A <QUOTE::for> definition object.
3224 wakaba 1.2 @@Return:
3225     @@@PerlDef:
3226 wakaba 1.5 my @from = ($self->{uri},
3227     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3228     my @to = ($superFor->{uri},
3229     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3230 wakaba 1.7 __DEEP{
3231     for my $from (@from) {
3232     for my $to (@to) {
3233     $self->{db}-><M::ManakaiDISDatabase.getFor>
3234     ($from)->{isa}->{$to} = true;
3235     $self->{db}-><M::ManakaiDISDatabase.getFor>
3236     ($to)->{revISA}->{$from} = true;
3237     }
3238 wakaba 1.5 }
3239 wakaba 1.7 }__;
3240 wakaba 1.5
3241 wakaba 1.2 ##DISForDefinition
3242    
3243     ClsDef:
3244     @ClsQName: ManakaiDISResourceDefinition
3245     @enDesc:
3246     <QUOTE::dis> resource definitions.
3247     @ClsISA: ManakaiDISPropertyAccessor
3248 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3249 wakaba 1.2
3250     @Attr:
3251     @@Name: uri
3252     @@Type: ResourceURI
3253     @@Description:
3254     @@@lang:en
3255     @@@@:
3256     The URI reference of this <QUOTE::dis> resource.
3257     @@Get:
3258     @@@PerlDef:
3259     $r = $self->{uri};
3260    
3261     @Attr:
3262     @@Name: nameURI
3263     @@Type: NameURI
3264     @@enDesc:
3265     The URI reference of this <QUOTE::dis> resource, without
3266     <QUOTE::for> identifier.
3267     @@Get:
3268     @@@nullCase:
3269     @@@@enDesc:
3270     This resource does not have its name URI reference.
3271 wakaba 1.3 @@@PerlDef:
3272 wakaba 1.4 $r = $self->{nameURI};
3273 wakaba 1.2
3274     @Attr:
3275     @@Name: localName
3276     @@enDesc:
3277     The local name of this resource.
3278     @@Type:
3279 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3280 wakaba 1.2 @@Get:
3281     @@@nullCase:
3282     @@@@enDesc:
3283     This resource does not have its local name.
3284     @@@PerlDef:
3285     $r = $self->{localName};
3286    
3287     @Attr:
3288     @@Name: namespaceURI
3289     @@Type: AnyURI
3290     @@enDesc:
3291     The namespace URI of the name of this resource.
3292     @@Get:
3293     @@@nullCase:
3294     The name of this resource does not have its namespace
3295     or this resource does not have its name.
3296     @@@PerlDef:
3297     $r = $self->{namespaceURI};
3298    
3299     @Attr:
3300     @@Name: isAnonymous
3301     @@enDesc:
3302     Whether this <QUOTE::dis> resource has name or not.
3303     @@Type:
3304     DOMMain:boolean
3305     @@Get:
3306     @@@TrueCase:
3307     This resource does not have any global unique name.
3308     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
3309     @@@FalseCase:
3310     This resource does have its formal name.
3311     <A::ManakaiDISResourceDefinition.uri> is a URI reference
3312     generated from the name and the <QUOTE::for> URI reference
3313     of this resource.
3314     @@@PerlDef:
3315     $r = $self->{<Q::isAnon>};
3316    
3317     @Attr:
3318     @@Name: forURI
3319     @@enDesc:
3320     The <QUOTE::for> URI reference for which this resource is defined.
3321     @@Type:ForURI
3322     @@Get:
3323     @@@PerlDef:
3324     $r = $self->{for};
3325    
3326     @Attr:
3327     @@Name: forpURI
3328     @@enDesc:
3329     The <QUOTE::for+> URI references for which this resource is defined.
3330     @@Type: ForURIList
3331     @@Get:
3332 wakaba 1.15 @@@enDesc:
3333     List of <QUOTE::for> URI references. Note that this list is
3334     <QUOTE::dead>.
3335 wakaba 1.3 @@@PerlDef:
3336 wakaba 1.15 $r = [@{$self->{forp}}];
3337    
3338     @Method:
3339     @@Name: isForURI
3340     @@enDesc:
3341     Tests whether this resource is defined for a <QUOTE::for>
3342     or <QUOTE::for+> URI reference or not.
3343     @@Param:
3344     @@@Name:forURI
3345     @@@Type:ForURI
3346     @@@enDesc:
3347     A <QUOTE::for> URI reference to test.
3348     @@Return:
3349     @@@Type:
3350     DOMMain:boolean::ManakaiDOM:all
3351     @@@TrueCase:
3352     @@@@enDesc:
3353     This resource is for <P::forURI>.
3354     @@@FalseCase:
3355     @@@@enDesc:
3356     This resource is not for <P::forURI>.
3357     @@@PerlDef:
3358     __DEEP{
3359     for my $this_for_uri ($self->{for}, @{$self->{forp}}) {
3360     if ($this_for_uri eq $forURI) { ## Shortcut
3361     $r = true;
3362     last;
3363     }
3364     my $this_for = $self->{db}-><M::ManakaiDISDatabase.getFor>
3365     ($this_for_uri);
3366     if ($this_for-><M::ManakaiDISForDefinition.isaURI> ($forURI)) {
3367     $r = true;
3368     last;
3369     }
3370     }
3371     }__;
3372 wakaba 1.2
3373     @Method:
3374 wakaba 1.7 @@Name: isSubsetOfURI
3375 wakaba 1.2 @@Description:
3376     @@@lang:en
3377     @@@@:
3378     Whether this resource is a subset of another resource or not.
3379     @@Param:
3380     @@@Name: superURI
3381     @@@Type: ResourceURI
3382     @@@Description:
3383     @@@@lang:en
3384     @@@@@:
3385     Another resource URI reference to test.
3386     @@Return:
3387     @@@Type:
3388     DOMMain:boolean
3389     @@@TrueCase:
3390     @@@@enDesc:
3391     <P::superURI> is a super-resource of this resource.
3392     @@@FalseCase:
3393     @@@@enDesc:
3394     <P::superURI> is not a super-resource of this resource.
3395     @@@PerlDef:
3396 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
3397 wakaba 1.2
3398 wakaba 1.7 @Method:
3399     @@Name: addSuperResource
3400     @@enDesc:
3401     Adds a <QUOTE::dis> resource to the list of super-resource
3402     of this <QUOTE::dis> resource.
3403     @@Param:
3404     @@@Name: superRes
3405     @@@Type: ManakaiDISResourceDefinition
3406     @@@enDesc:
3407     A <QUOTE::dis> resource definition object.
3408     @@Return:
3409     @@@PerlDef:
3410     my @from = ($self->{uri},
3411     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
3412     my @to = ($superRes->{uri},
3413     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
3414     __DEEP{
3415     for my $from (@from) {
3416     for my $to (@to) {
3417     $self->{db}-><M::ManakaiDISDatabase.getResource>
3418     ($from)->{subOf}->{$to} = true;
3419     $self->{db}-><M::ManakaiDISDatabase.getResource>
3420     ($to)->{supOf}->{$from} = true;
3421     }
3422     }
3423     }__;
3424    
3425 wakaba 1.2 @Attr:
3426     @@Name: isDefined
3427     @@Description:
3428     @@@lang:en
3429     @@@@:
3430     Whether this resource is already defined or not.
3431     @@Type:
3432     DOMMain:boolean
3433     @@Get:
3434     @@@TrueCase:
3435     This resource is already defined.
3436     @@@FalseCase:
3437     This resource is not defined.
3438     @@@PerlDef:
3439     $r = $self->{<Q::isDefined>};
3440    
3441     @Attr:
3442     @@Name: isReferred
3443     @@Description:
3444     @@@lang:en
3445     @@@@:
3446     Whether this resource is referred or not.
3447 wakaba 1.7 @@Type: ManakaiDISElement
3448 wakaba 1.2 @@Get:
3449 wakaba 1.7 @@@enDesc:
3450 wakaba 1.9 An element that referres this resource.
3451 wakaba 1.2 @@@nullCase:
3452     This resource is not referred.
3453     @@@PerlDef:
3454     $r = $self->{<Q::isReferred>};
3455     @@Set:
3456 wakaba 1.7 @@@enDesc:
3457 wakaba 1.9 An element that referres this resource.
3458 wakaba 1.2 @@@PerlDef:
3459 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3460 wakaba 1.2
3461     @Attr:
3462     @@Name: definingModule
3463     @@Description:
3464     @@@lang:en
3465     @@@@:
3466     The <QUOTE::dis> module in which this resource is defined.
3467 wakaba 1.8 \
3468     {NOTE:: Method name should have been <CODE::ownerModule> or some.
3469     \
3470     }
3471 wakaba 1.2 @@Type: ManakaiDISModuleDefinition
3472     @@Get:
3473     @@@Description:
3474     @@@@lang:en
3475     @@@@@:
3476     The module object.
3477 wakaba 1.3 @@@nullCase:
3478 wakaba 1.2 @@@@Description:
3479     @@@@@lang:en
3480     @@@@@@:
3481     This resource is not associated to any module.
3482     @@@PerlDef:
3483     $r = $self->{db}
3484     -><M::ManakaiDISDatabase.getModule>
3485     ($self->{<Q::definingModule>})
3486     if defined $self->{<Q::definingModule>};
3487     @@Set:
3488     @@@Description:
3489     @@@@lang:en
3490     @@@@@:
3491     The module object to which the <QUOTE::defining module> is set.
3492     @@@PerlDef:
3493     $self->{<Q::defininingModule>}
3494     = $given-><AG::ManakaiDISModuleDefinition.uri>;
3495    
3496 wakaba 1.6 @Method:
3497     @@Name: mergeAsAlias
3498     @@enDesc:
3499     Merges another resource definition as an alias of this resource.
3500     @@Param:
3501     @@@Name: aliasResource
3502     @@@Type: ManakaiDISResourceDefinition
3503     @@@enDesc:
3504     A resource to merge.
3505     \
3506     {NOTE:: After merging all references to <P::aliasResource>
3507     should be discarded.
3508     \
3509     }
3510 wakaba 1.11 @@NodeParam:
3511 wakaba 1.6 @@Return:
3512 wakaba 1.11 @@@RaiseException:
3513     @@@@@:MERGE_ITSELF_ERR
3514     @@@@@@enDesc:
3515     An attempt is made to merge this resource itself.
3516     @@@PerlDef:
3517     if ($self eq $aliasResource) {
3518     __EXCEPTION{MERGE_ITSELF_ERR::
3519     DIS:uri => {$self->{uri}},
3520     DIS:sourceNode => {$node},
3521     }__;
3522     }
3523 wakaba 1.6 for my $uri ($aliasResource->{uri},
3524     grep {$aliasResource->{aliasURI}->{$_}}
3525     keys %{$aliasResource->{aliasURI}}) {
3526     $self->{aliasURI}->{$uri} = true;
3527     $self->{db}->{resDef}->{$uri} = $self;
3528     $self->{subOf}->{$uri} = true;
3529     $self->{supOf}->{$uri} = true;
3530     }
3531     for my $uri (grep {$aliasResource->{subOf}->{$_}}
3532     keys %{$aliasResource->{subOf}}) {
3533     $self->{subOf}->{$uri} = true;
3534     }
3535     for my $uri (grep {$aliasResource->{supOf}->{$_}}
3536     keys %{$aliasResource->{supOf}}) {
3537     $self->{supOf}->{$uri} = true;
3538     }
3539     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
3540     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
3541     __DEEP{
3542     for my $from (@from) {
3543     for my $to (@to) {
3544     $self->{db}-><M::ManakaiDISDatabase.getResource>
3545     ($from)->{subOf}->{$to} = true;
3546     $self->{db}-><M::ManakaiDISDatabase.getResource>
3547     ($to)->{supOf}->{$from} = true;
3548     }
3549     }
3550     }__;
3551 wakaba 1.7
3552     @Method:
3553     @@Name: isTypeURI
3554     @@enDesc:
3555     Tests whether this resource is of a type or not.
3556     @@Param:
3557     @@@Name: typeURI
3558     @@@Type: ResourceURI
3559     @@@enDesc:
3560     A type URI reference to test.
3561     @@Return:
3562     @@@Type:
3563     DOMMain:boolean
3564     @@@TrueCase:
3565     @@@@enDesc:
3566     This is a <P::typeURI> resource.
3567     @@@FalseCase:
3568     @@@@enDesc:
3569     This is not a <P::typeURI> resource.
3570     @@@PerlDef:
3571 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
3572     $r = $self->{<Q::rdf:type>}->{$typeURI};
3573     } else {
3574     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
3575     keys %{$self->{<Q::rdf:type>}}) {
3576     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
3577     ($t_type_uri);
3578     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3579     ($typeURI)) {
3580     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
3581     last;
3582     }
3583 wakaba 1.7 }
3584     }
3585 wakaba 1.8
3586     @Attr:
3587     @@Name: plName
3588     @@enDesc:
3589     The Perl name of this resource.
3590     @@Get:
3591     @@@Type:
3592     DISLang:String
3593     @@@enDesc:
3594     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
3595     \
3596     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
3597     <CHAR::COLON> prefix).
3598     \
3599     - <Q::DISLang:Attribute>::: Method name.
3600     \
3601     - <Q::DISLang:Method>::: Method name.
3602     @@@nullCase:
3603     @@@@enDesc:
3604     Either the type of this resource is not listed above
3605     or this Perl constructure is anonymous.
3606     @@@RaiseException:
3607     @@@@@: NO_LOCAL_NAME_ERR
3608     @@@@enDesc:
3609     The type of this resource is either
3610     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
3611     the local name of this resource is not defined.
3612     @@@RaiseException:
3613     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
3614     @@@@enDesc:
3615     The Perl method name constructed from the source
3616     result in a reserved name.
3617     @@@PerlDef:
3618     __DEEP{
3619     if (exists $self->{<Q::dis2pm:name>}) {
3620     $r = $self->{<Q::dis2pm:name>};
3621     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3622     (<Q::ManakaiDOM:Const>) or
3623     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3624     (<Q::ManakaiDOM:ConstGroup>)) {
3625     $r = $self->{localName};
3626     unless (defined $r) {
3627     __UNDEEP{
3628     __EXCEPTION{NO_LOCAL_NAME_ERR::
3629     DIS:sourceNode => {$self->{src}},
3630     }__;
3631     }__;
3632     }
3633     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3634     (<Q::DISLang:Method>) or
3635     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3636     (<Q::DISLang:Attribute>)) {
3637     if (defined $self->{localName}) {
3638     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
3639     ($self->{localName});
3640     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
3641     (<Q::ManakaiDOM:isForInternal>, false)) {
3642     $r = '_' . $r;
3643     }
3644     if ({
3645     import => 1,
3646     unimport => 1,
3647     isa => 1,
3648     can => 1,
3649     new => 1,
3650     as_string => 1,
3651     stringify => 1,
3652     clone => 1,
3653     }->{$r} or $r =~ /^___/) {
3654     __UNDEEP{
3655     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
3656     DIS:uri => {$self->{uri}},
3657     DIS:soruceNode => {$self->{src}},
3658     DIS:generatedName => {$r},
3659     }__;
3660     }__;
3661 wakaba 1.11 }
3662     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
3663 wakaba 1.8 .plMethodOperator>) {
3664     $r = {
3665     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
3666     <Q::DISPerl:AsStringMethod> => 'as_string',
3667 wakaba 1.16 <Q::DISPerl:NewMethod> => 'new',
3668     <Q::DISPerl:CloneMethod> => 'clone',
3669 wakaba 1.8 }->{$op_uri};
3670     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
3671     } else {
3672     $r = null;
3673     }
3674     } else {
3675     $r = null;
3676     }
3677     $self->{<Q::dis2pm:name>} = $r;
3678     }__;
3679    
3680     @Attr:
3681     @@Name: plFullyQualifiedName
3682     @@enDesc:
3683     The fully-qualified Perl name of this resource.
3684     @@Type:
3685     DISLang:String::ManakaiDOM:all
3686     @@Get:
3687     @@@enDesc:
3688     Fully-qualified name.
3689     \
3690     - <Q::ManakaiDOM:Class>::: Class package name.
3691     \
3692     - <Q::ManakaiDOM:IF>::: Interface package name.
3693     \
3694     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
3695     type symbol such as <CODE::$>).
3696     @@@nullCase:
3697     @@@@enDesc:
3698     Otherwise.
3699     @@@NoPerlModuleNameException:
3700     @@@RaiseException:
3701     @@@@@: NO_LOCAL_NAME_ERR
3702     @@@@enDesc:
3703     The local name of this resource is not defined.
3704     @@@PerlDef:
3705     __DEEP{
3706     if (exists $self->{<Q::dis2pm:name>}) {
3707     $r = $self->{<Q::dis2pm:name>};
3708     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3709     (<Q::ManakaiDOM:Class>) or
3710     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3711     (<Q::ManakaiDOM:IF>) or
3712     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3713     (<Q::DISPerl:ScalarVariable>)) {
3714 wakaba 1.14 my $an_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3715 wakaba 1.8 (<Q::dis:AppName>, for_arg => $self->{for},
3716     forp_arg => $self->{forp},
3717     media_type => <Q::lang:Perl>);
3718     if ($an_node) {
3719     ## NOTE: "lang:Perl" is fully-qualified name by definition
3720 wakaba 1.14 $r = $an_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3721 wakaba 1.8 } else {
3722 wakaba 1.10 unless (defined $self->{localName}) {
3723     __UNDEEP{
3724     __EXCEPTION{NO_LOCAL_NAME_ERR::
3725     DIS:sourceNode => {$self->{src}},
3726     }__;
3727     }__;
3728     }
3729 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3730     (<Q::ManakaiDOM:IF>)) {
3731     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3732 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plInterfaceName>
3733 wakaba 1.8 . '::' . $self->{localName};
3734     } else {
3735     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3736 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
3737 wakaba 1.8 . '::' . $self->{localName};
3738     }
3739     }
3740     } else {
3741     $r = null;
3742     }
3743     $self->{<Q::dis2pm:name>} = $r;
3744     }__;
3745    
3746     @Attr:
3747 wakaba 1.15 @@Name: plVariableName
3748     @@enDesc:
3749     The Perl variable name with prefix.
3750     @@Type:
3751     lang:Perl::ManakaiDOM:all
3752     @@Get:
3753     @@@nullCase:
3754     @@@@enDesc:
3755     This resource does not define any Perl variable.
3756     @@@PerlDef:
3757     $r = $self->{localName};
3758     if (defined $r) {
3759     __DEEP{
3760     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3761     (<Q::Perl:Array>)) {
3762     $r = '@' . $r;
3763     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3764     (<Q::Perl:Hash>)) {
3765     $r = '%' . $r;
3766     } else {
3767     $r = '$' . $r;
3768     }
3769     }__;
3770     }
3771    
3772     @Attr:
3773 wakaba 1.8 @@Name: plMethodOperator
3774     @@enDesc:
3775     The operator to overload by this method.
3776     @@Type:
3777     DISLang:String::ManakaiDOM:all
3778     @@Get:
3779     @@@enDesc:
3780     The operator, either Perl <CODE::use operator> operator name
3781     of manakai operator URI reference.
3782     @@@nullCase:
3783     @@@@enDesc:
3784     Either this resource does not define a Perl method or
3785     this method does not overload any operator.
3786     @@@UndeclaredPrefixException:
3787     @@@RaiseException:
3788     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
3789     @@@@enDesc:
3790     Media type of the <Q::dis:Operator> node is not supported.
3791     @@@PerlDef:
3792     __DEEP{
3793     if (exists $self->{<Q::dis:Operator>}) {
3794     $r = $self->{<Q::dis:Operator>};
3795     } else {
3796     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3797     (<Q::dis:Operator>, for_arg => $self->{for},
3798     forp_arg => $self->{forp});
3799     if ($op_node) {
3800     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3801 wakaba 1.12 (<Q::lang:Perl>, for_arg => $self->{for},
3802     for_arg => $self->{forp})) {
3803 wakaba 1.14 $r = $op_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3804 wakaba 1.8 } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3805 wakaba 1.12 (<Q::dis:TypeQName>, for_arg => $self->{for},
3806     for_arg => $self->{forp})) {
3807 wakaba 1.8 $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
3808     } else {
3809 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
3810     (for_arg => $self->{for},
3811     forp_arg => $self->{forp});
3812 wakaba 1.8 __UNDEEP{
3813     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3814     DIS:uri => {$ct_uri},
3815 wakaba 1.10 DIS:sourceNode => {$op_node},
3816 wakaba 1.8 }__;
3817     }__;
3818     }
3819     } else {
3820     $r = null;
3821     }
3822     $self->{<Q::dis:Operator>} = $r;
3823     }
3824     }__;
3825    
3826     @Attr:
3827     @@Name: disDataTypeResource
3828     @@enDesc:
3829     <Q::dis:Type> attribute value of this resource.
3830     @@Type: ManakaiDISResourceDefinition
3831     @@Get:
3832     @@@RaiseException:
3833     @@@@@:NO_DIS_TYPE_ERR
3834     @@@@enDesc:
3835     <Q::dis:Type> attribute is not specified.
3836     @@@PerlDef:
3837     __DEEP{
3838     if (defined $self->{<Q::dis:Type>}) {
3839 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
3840     ($self->{<Q::dis:Type>});
3841 wakaba 1.8 } else {
3842     $self->{<Q::dis2pm:TypeNode>}
3843     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3844     (<Q::dis:Type>, for_arg => $self->{for},
3845     forp_arg => $self->{forp});
3846     if ($self->{<Q::dis2pm:TypeNode>}) {
3847     $r = $self->{<Q::dis:Type>}
3848     = $self->{<Q::dis2pm:TypeNode>}
3849     -><AG::ManakaiDISElement.qnameValueURI>;
3850     } else {
3851     my $pr = $self-><M::ManakaiDISPropertyAccessor
3852     .getPropertyResource>
3853     (<Q::DIS:dynamicParentResource>);
3854     if ($pr) {
3855     $r = $pr-><AG::ManakaiDISResourceDefinition
3856     .disDataTypeResource>;
3857     $self->{<Q::dis2pm:TypeNode>}
3858     = $pr->{<Q::dis2pm:TypeNode>};
3859     } else { ## No parent
3860     __UNDEEP{
3861     __EXCEPTION{NO_DIS_TYPE_ERR::
3862     DIS:sourceNode => {$self->{src}},
3863     }__;
3864     }__;
3865     }
3866     }
3867 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
3868     $r-><AS::ManakaiDISResourceDefinition.isReferred>
3869     ($self->{<Q::dis2pm:TypeNode>});
3870 wakaba 1.8 }
3871     }__;
3872    
3873     @Attr:
3874     @@Name: disDataTypeNode
3875     @@enDesc:
3876     <Q::dis:Type> node for this resource.
3877     @@Get:
3878     @@@Type: ManakaiDISElement
3879     @@@RaiseException:
3880     @@@@@:NO_DIS_TYPE_ERR
3881     @@@@enDesc:
3882     <Q::dis:Type> attribute is not specified.
3883     @@@PerlDef:
3884     __DEEP{
3885     $self-><AG::ManakaiDISResourceDefinition.disDataTypeNode>;
3886     }__;
3887     $r = $self->{<Q::dis2pm:TypeNode>};
3888    
3889     @Attr:
3890     @@Name: disActualDataTypeResource
3891     @@enDesc:
3892     <Q::dis:actualType> attribute value of this resource.
3893     @@Type: ManakaiDISResourceDefinition
3894     @@Get:
3895     @@@RaiseException:
3896     @@@@@:NO_DIS_TYPE_ERR
3897     @@@@enDesc:
3898     <Q::dis:actualType> attribute is not specified,
3899     and <Q::dis:Type> attribute, neigher.
3900     @@@PerlDef:
3901     __DEEP{
3902     if (defined $self->{<Q::dis:actualType>}) {
3903 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
3904     ($self->{<Q::dis:actualType>});
3905 wakaba 1.8 } else {
3906     $self->{<Q::dis2pm:actualTypeNode>}
3907     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3908     (<Q::dis:actualType>, for_arg => $self->{for},
3909     forp_arg => $self->{forp});
3910     if ($self->{<Q::dis2pm:actualTypeNode>}) {
3911     $r = $self->{<Q::dis:actualType>}
3912     = $self->{<Q::dis2pm:actualTypeNode>}
3913     -><AG::ManakaiDISElement.qnameValueURI>;
3914     } elsif (defined $self->{<Q::dis:Type>}) {
3915     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
3916     $self->{<Q::dis2pm:actualTypeNode>}
3917     = $self->{<Q::dis2pm:TypeNode>};
3918     } else {
3919     $self->{<Q::dis2pm:actualTypeNode>}
3920     = $self->{<Q::dis2pm:TypeNode>}
3921     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3922     (<Q::dis:Type>, for_arg => $self->{for},
3923     forp_arg => $self->{forp});
3924     if ($self->{<Q::dis2pm:TypeNode>}) {
3925     $r = $self->{<Q::dis:actualType>}
3926     = $self->{<Q::dis:Type>}
3927     = $self->{<Q::dis2pm:TypeNode>}
3928     -><AG::ManakaiDISElement.qnameValueURI>;
3929     } else {
3930     my $pr = $self-><M::ManakaiDISPropertyAccessor
3931     .getPropertyResource>
3932     (<Q::DIS:dynamicParentResource>);
3933     if ($pr) {
3934     $r = $self->{<Q::dis:actualType>}
3935     = $pr-><AG::ManakaiDISResourceDefinition
3936     .disActualDataTypeResource>;
3937     $self->{<Q::dis2pm:actualTypeNode>}
3938     = $pr->{<Q::dis2pm:actualTypeNode>};
3939     } else { ## No parent
3940     __UNDEEP{
3941     __EXCEPTION{NO_DIS_TYPE_ERR::
3942     DIS:sourceNode => {$self->{src}},
3943     }__;
3944     }__;
3945     }
3946     }
3947     }
3948 wakaba 1.15 $r = $self->{db}-><M::ManakaiDISDatabase.getResource> ($r);
3949     $r-><AS::ManakaiDISResourceDefinition.isReferred>
3950     ($self->{<Q::dis2pm:actualTypeNode>});
3951 wakaba 1.8 }
3952     }__;
3953    
3954     @Attr:
3955     @@Name: disActualDataTypeNode
3956     @@enDesc:
3957     <Q::dis:actualType> node for this resource.
3958     @@Get:
3959     @@@Type: ManakaiDISElement
3960     @@@RaiseException:
3961     @@@@@:NO_DIS_TYPE_ERR
3962     @@@@enDesc:
3963     <Q::dis:actualType> attribute is not specified,
3964     and <Q::dis:Type> attribute, neigher.
3965     @@@PerlDef:
3966     __DEEP{
3967     $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeNode>;
3968     }__;
3969     $r = $self->{<Q::dis2pm:actualTypeNode>};
3970 wakaba 1.9
3971     @IntMethod:
3972     @@Operator:
3973     @@@@: <=>
3974     @@@ContentType:
3975     lang:Perl
3976     @@enDesc:
3977     Which is greater (i.e. the spaceship operator).
3978     A resource is less than another if it is loaded by
3979     <M::ManakaiDISDatabase.loadResource> before another is loaded.
3980     Order for non-loaded resource definitions are not defined.
3981     \
3982     {NOTE:: In the current implementation, non-loaded resources
3983     are less than any loaded resource and the order in
3984     non-loaded resources is unknown.
3985     \
3986     }
3987     @@Param:
3988     @@@Name: anotherResource
3989     @@@Type: ManakaiDISResourceDefinition
3990     @@@enDesc: Another resource to compare.
3991     @@Return:
3992     @@@Type:
3993     DOMMain:unsigned-long
3994     @@@PerlDef:
3995     if (UNIVERSAL::isa ($anotherResource,
3996     <ClassName::ManakaiDISResourceDefinition>)) {
3997     $r = $self->{seq} <=> $anotherResource->{seq};
3998     } else {
3999     $r = overload::Overloaded ($self) <=> $anotherResource;
4000     }
4001 wakaba 1.12
4002     @Attr:
4003     @@Name: plCodeFragment
4004     @@enDesc:
4005     Perl code definition fragment of this resource.
4006     @@Type: MPLCodeFragment
4007     @@Get:
4008     @@@enDesc:
4009     Perl code.
4010     @@@nullCase:
4011     @@@@enDesc:
4012     This node does not have Perl code definition.
4013     @@@RaiseException:
4014     @@@@@:NO_METHOD_RETURN_ERR
4015     @@@@enDesc:
4016     This resource is a <Q::DISLang:Method> but it does not
4017     have <Q::DISLang:MethodReturn> child-resource.
4018     @@@RaiseException:
4019     @@@@@:NO_ATTR_GET_ERR
4020     @@@@enDesc:
4021     This resource is a <Q::DISLang:Attribute> but it does not
4022     have <Q::DISLang:AttributeGet> child-resource.
4023     @@@RaiseException:
4024     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4025     @@@@enDesc:
4026     The media type of <Q::dis:Def> element is not supported.
4027     @@@PerlDef:
4028     __DEEP{
4029     if (exists $self->{<Q::plCodeFragment>}) {
4030     $r = $self->{<Q::plCodeFragment>};
4031     } elsif (not $self->{src}) {
4032     $r = $self->{<Q::plCodeFragment>} = null;
4033     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4034     (<Q::DISLang:MethodReturn>) or
4035     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4036     (<Q::DISLang:AttributeGet>) or
4037     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4038 wakaba 1.13 (<Q::DISLang:AttributeSet>) or
4039     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4040     (<Q::dis2pm:BlockCode>) or
4041     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
4042     (<Q::dis2pm:InlineCode>)) {
4043     $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4044 wakaba 1.12 my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4045     (<Q::dis:Def>, for_arg => $self->{for},
4046     forp_arg => $self->{forp});
4047     if ($def-><M::ManakaiDISElement.mediaTypeMatch> (<Q::lang:Perl>)) {
4048 wakaba 1.14 my $source_code = $def-><M::swcfg21:SWCFGNode
4049     ::swcfg21:ForLatest.value>;
4050 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
4051 wakaba 1.14 = $self-><M::ManakaiDISResourceDefinition
4052 wakaba 1.15 .plPreprocessPerlCode> ($source_code);
4053 wakaba 1.12 } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
4054     (<Q::lang:dis>)) {
4055     $r = $self->{<Q::plCodeFragment>}
4056 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
4057 wakaba 1.12 -><M::MPLImpl.createPerlUnparsedCode>
4058 wakaba 1.14 ($def-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>);
4059 wakaba 1.12 ## TODO: implement
4060     } else {
4061     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
4062     (for_arg => $self->{for},
4063     forp_arg => $self->{forp});
4064     __UNDEEP{
4065     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4066     DIS:uri => {$mt},
4067     DIS:sourceNode => {$def},
4068     }__;
4069     }__;
4070     } # media type
4071     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4072     (<Q::DISLang:Method>)) {
4073 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4074 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
4075     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
4076     unless ($ret) {
4077     __UNDEEP{
4078     __EXCEPTION{NO_METHOD_RETURN_ERR::
4079     DIS:errResource => {$self},
4080     DIS:sourceNode => {$self->{src}},
4081     }__;
4082     }__;
4083     }
4084     $r = $self->{<Q::plCodeFragment>}
4085 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
4086 wakaba 1.12 -><M::MPLImpl.createPerlSub>
4087     ($self-><AG::ManakaiDISResourceDefinition.plName>);
4088    
4089    
4090     ## TODO: Parameter, sub, ...
4091 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
4092 wakaba 1.12 ($ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
4093    
4094     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
4095     (<Q::DISLang:Attribute>)) {
4096 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
4097 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
4098     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
4099     unless ($get) {
4100     __UNDEEP{
4101     __EXCEPTION{NO_ATTR_GET_ERR::
4102     DIS:errResource => {$self},
4103     DIS:sourceNode => {$self->{src}},
4104     }__;
4105     }__;
4106     }
4107     $r = $self->{<Q::plCodeFragment>}
4108 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
4109 wakaba 1.12 -><M::MPLImpl.createPerlSub>
4110     ($self-><AG::ManakaiDISResourceDefinition.plName>);
4111    
4112    
4113     ## TODO: Parameter, sub, set, ...
4114 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
4115 wakaba 1.12 ($get-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
4116    
4117 wakaba 1.13 } else { ## Not supported
4118 wakaba 1.12 $r = $self->{<Q::plCodeFragment>} = null;
4119     } # rdf:type
4120     }__;
4121    
4122     @Attr:
4123     @@Name:plImplementation
4124     @@enDesc:
4125     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
4126     @@Type: MPLImpl
4127     @@Get:
4128     @@@enDesc:
4129     The Perl code implementation object.
4130     @@@nullCase:
4131     This resource has no source tree associated.
4132     @@@RaiseException:
4133     @@@@@:NO_PERL_CODE_IMPL_ERR
4134     @@@@enDesc:
4135     There is no implementation that implements
4136     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
4137     @@@PerlDef:
4138     if ($self->{src}) {
4139     __DEEP{
4140     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
4141     $self->{src})-><AG::SWCFGDoc.implementation>
4142     -><M::DOMMinImpl.getFeature>
4143     (<Q::Util:PerlCode> => '1.0');
4144     }__;
4145     unless (defined $r) {
4146     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
4147    
4148     }__;
4149     }
4150     }
4151    
4152     @Method:
4153     @@Name: getChildResourceByType
4154     @@enDesc:
4155     Gets a static child resource selected by its type.
4156     @@Param:
4157     @@@Name:typeURI
4158     @@@Type:ResourceURI
4159     @@@enDesc:
4160     A URI reference identifying a resource type.
4161     @@Return:
4162     @@@Type: ManakaiDISResourceDefinition
4163     @@@enDesc:
4164     The first (by document order) child resource whose
4165     type matches with <P::resType>.
4166     @@@nullCase:
4167     @@@@enDesc:
4168     There is no resource whose type is <P::resType>.
4169     @@@PerlDef:
4170     __DEEP{
4171     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4172     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4173     ($cr_uri);
4174     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
4175     $r = $cr;
4176     last;
4177     }
4178     }
4179     }__;
4180 wakaba 1.13
4181     @Method:
4182     @@Name: getChildResourceByNameAndType
4183     @@enDesc:
4184     Gets a static child resource selected by its local name and type.
4185     @@Param:
4186     @@@Name: localName
4187     @@@Type:
4188     DISCore:LocalName::ManakaiDOM:all
4189     @@@enDesc:
4190     A local name.
4191     @@Param:
4192     @@@Name:typeURI
4193     @@@Type:ResourceURI
4194     @@@enDesc:
4195     A URI reference identifying a resource type.
4196     @@Return:
4197     @@@Type: ManakaiDISResourceDefinition
4198     @@@enDesc:
4199     The first (by document order) child resource whose
4200     type matches for <P::localName> and <P::resType>.
4201     @@@nullCase:
4202     @@@@enDesc:
4203     There is no resource whose name is <P::localName> and
4204     whose type is <P::resType>.
4205     @@@PerlDef:
4206     __DEEP{
4207     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4208     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4209     ($cr_uri);
4210 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
4211 wakaba 1.13 if (defined $ln and $ln eq $localName and
4212     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
4213     $r = $cr;
4214     last;
4215     }
4216     }
4217     }__;
4218    
4219     @Method:
4220     @@Name: getConstResourceByName
4221     @@enDesc:
4222     Gets a constant value resource by its local name.
4223     @@Param:
4224     @@@Name:localName
4225     @@@Type:
4226     DISLang:String::ManakaiDOM:all
4227     @@@enDesc:
4228     Constant name.
4229     @@Return:
4230     @@@Type: ManakaiDISResourceDefinition
4231     @@@enDesc:
4232     The constant resource identified by <P::localName>.
4233     @@@nullCase:
4234     @@@@enDesc:
4235     There is no such constant resource.
4236     @@@PerlDef:
4237     __DEEP{
4238     my @constGroup;
4239     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4240     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4241     ($cr_uri);
4242 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
4243 wakaba 1.13 if ($ln and $ln eq $localName and
4244     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4245     (<Q::ManakaiDOM:Const>)) {
4246     $r = $cr;
4247     last;
4248     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4249     (<Q::ManakaiDOM:ConstGroup>)) {
4250     push @constGroup, $cr;
4251     }
4252     }
4253     unless ($r) {
4254     for my $cg (@constGroup) {
4255     $r = $cg-><M::ManakaiDISResourceDefinition
4256     .getChildResourceByNameAndType>
4257     ($localName, <Q::ManakaiDOM:Const>);
4258     last if $r;
4259     }
4260     }
4261     }__;
4262    
4263     @Method:
4264     @@Name: plPreprocessPerlCode
4265     @@enDesc:
4266     Preprocesses a Perl block-level code fragment.
4267     @@Param:
4268     @@@Name:codeArg
4269     @@@Type:
4270     lang:Perl::ManakaiDOM:all
4271     @@@enDesc:
4272     A Perl block-level code (statements and/or blocks).
4273 wakaba 1.15 @@NodeParam:
4274     @@NamedParam:
4275     @@@Name:methodResource
4276     @@@Type:ManakaiDISResourceDefinition
4277     @@@enDesc:
4278     The resource definition of the Perl method to which
4279     the <P::codeArg> belongs.
4280     @@@nullCase:
4281     @@@@enDesc:
4282     The <P::codeArg> does not belong to any method.
4283 wakaba 1.13 @@Return:
4284     @@@Type:
4285     lang:Perl::ManakaiDOM:all
4286     @@@enDesc:
4287     Preprocessed Perl code.
4288 wakaba 1.15 @@@BlockElementException:
4289     @@@InlineElementException:
4290 wakaba 1.13 @@@PerlDef:
4291 wakaba 1.15 unless ($self->{src}) {
4292     __EXCEPTION{NO_SOURCE_NODE_ERR::
4293     DIS:uri => {$self->{uri}},
4294     }__;
4295     }
4296     __DEEP{
4297     our $RegQNameChar;
4298     our $RegBlockContent;
4299     use re 'eval';
4300     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4301     .plImplementation>;
4302     $r = $plimpl-><M::MPLImpl.createPerlBlock>;
4303    
4304 wakaba 1.16 for my $source_code (split /\b(_ _(?:(?!_ _)$RegQNameChar)+
4305 wakaba 1.15 (?:\{$RegBlockContent\})?
4306 wakaba 1.16 _ _)\b/x, $codeArg) {
4307 wakaba 1.15 ## Block-level element
4308 wakaba 1.16 if ($source_code =~ /_\_\z/ and
4309     $source_code =~ s/^_\_((?:(?!_\_)$RegQNameChar)+)//) {
4310 wakaba 1.15 my $et = $self->{src}
4311     -><M::ManakaiDISElement.qnameToURI>
4312     ($1,
4313     node => $node,
4314     default_namespace_uri => <Q::disPerl:>);
4315     if ($source_code =~ s/^\{//) {
4316     $source_code =~ s/\}__\z//;
4317     } else {
4318     $source_code = '';
4319     }
4320    
4321     # if ($s =~ /\btry\b/) {
4322     # $s = q<use Message::Util::Error;>.$s;
4323     # }
4324     # ## ISSUE: __FILE__ & __LINE__ will break if multiline substition happens.
4325    
4326     if ($et eq <Q::disPerl:DEEP> or $et eq <Q::disPerl:UNDEEP>) {
4327     my $block = $r-><M::PLBlockCon.appendBlock>;
4328     $block-><M::PLBlockCon.appendStatement>
4329     ('local $Error::Depth = $Error::Depth '.
4330     ($et eq <Q::disPerl:DEEP> ? '+' : '-').
4331     ' 1');
4332     $block-><M::PLBlockCon.appendCodeFragment>
4333     ($self-><M::ManakaiDISResourceDefinition
4334     .plPreprocessPerlCode>
4335     ($source_code, node => $node,
4336     method_resource => $methodResource));
4337     } elsif ({
4338     <Q::disPerl:EXCEPTION> => 1,
4339     <Q::disPerl:WARNING> => 1,
4340     }->{$et}) {
4341     if ($source_code =~ s/^((?:(?!::).)+)(::\s*)?//s) {
4342     my ($cls, $const, $subtype)
4343     = @{$self->{db}-><M::ManakaiDISDatabase.xcrefToResource>
4344 wakaba 1.16 ($1, $self->{src},
4345     node => $node,
4346     for_arg => $self->{for})};
4347 wakaba 1.15 my $param = $self-><M::ManakaiDISResourceDefinition
4348     .plParsePreprocessParameter>
4349     ($source_code, node => $node);
4350     my $context_param
4351     = $self-><M::ManakaiDISResourceDefinition
4352     .plGetContextParameter>;
4353    
4354     $self-><M::ManakaiDISResourceDefinition
4355     .plAppendThrow>
4356     ($r, $cls, $const, $subtype,
4357     {%$param, %$context_param});
4358     } else {
4359     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR::
4360     DIS:sourceNode => {$node},
4361     DIS:sourceCode => {$source_code},
4362     DIS:elementType => {$et},
4363     }__}__;
4364     }
4365     } elsif ($et eq <Q::disPerl:CODE>) {
4366     my $code_name;
4367     $source_code =~ s/^\s+//;
4368     if ($source_code =~ s/^((?>(?!::).)+)//s) {
4369     $code_name = $1;
4370     } else {
4371     __UNDEEP{
4372     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
4373     DIS:sourceCode => {$source_code},
4374     DIS:sourceNode => {$node},
4375     DIS:elementType => {$et},
4376     }__;
4377     }__;
4378     }
4379     $source_code =~ s/^::\s*//;
4380     my $param = $self-><M::ManakaiDISResourceDefinition
4381     .plParsePreprocessParameter>
4382     ($source_code, node => $node);
4383     my $code_uri = $self->{src}-><M::ManakaiDISElement
4384     .tfqnamesToURI>
4385     ($code_name, null, $self->{for},
4386     node => $node);
4387     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
4388     ($code_uri);
4389     $code-><AS::ManakaiDISResourceDefinition.isReferred>
4390     ($node || $self->{src});
4391     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
4392     (<Q::dis2pm:BlockCode>)) {
4393     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4394     DIS:uri => {$code_uri},
4395     DIS:sourceNode => {$node},
4396     DIS:sourceCode => {$source_code},
4397     DIS:expectedType => {<Q::dis2pm:BlockCode>},
4398     }__;}__;
4399     }
4400     my $pc = $code-><AG::ManakaiDISResourceDefinition
4401     .plCodeFragment>->clone;
4402     unless (defined $pc) {
4403     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4404     DIS:sourceNode => {$node},
4405     DIS:sourceCode => {$source_code},
4406     DIS:uri => {$code_uri},
4407     }__}__;
4408     }
4409     for my $var (grep {/^\$/} keys %$param) {
4410     my $value;
4411     if ($param->{$var}->{type} eq 'variable') {
4412     $value = $plimpl-><M::MPLImpl.createPerlVariable>
4413     ('$', null, $param->{$var}->{value});
4414     } elsif ($param->{$var}->{type} eq 'code') {
4415     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
4416     ($param->{$var}->{value});
4417     } else {
4418     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
4419     ($param->{$var}->{value});
4420     }
4421     $pc-><M::MPLCodeFragment.replaceVariable>
4422     ($var => $value);
4423     }
4424 wakaba 1.16 $r-><M::PLBlockCon.appendCodeFragment> ($pc);
4425 wakaba 1.15 } elsif ($et eq <Q::ManakaiDOM:InputNormalize>) {
4426     unless ($methodResource) {
4427     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_METHOD_ERR::
4428     DIS:sourceNode => {$node},
4429     DIS:sourceCode => {$source_code},
4430     DIS:elementType => {$et},
4431     }__}__;
4432     }
4433     my $param = $methodResource
4434     -><M::ManakaiDISResourceDefinition
4435     .getChildResourceByNameAndType>
4436     ($source_code, <Q::DISLang:MethodParameter>);
4437     unless ($param) {
4438     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4439     DIS:sourceNode => {$node},
4440     DIS:sourceCode => {$source_code},
4441     DIS:elementType => {$et},
4442     DIS:localName => {$source_code},
4443     DIS:expectedType => {<Q::DISLang:MethodParameter>},
4444     }__}__;
4445     }
4446     my $norm = $param-><M::ManakaiDISResourceDefinition
4447     .plGetMethodInputNormalizer>;
4448     if ($norm) {
4449     my $norm_code = $norm-><AG::ManakaiDISResourceDefinition
4450     .plCodeFragment>->clone;
4451     $norm_code-><M::MPLCodeFragment.replaceVariable>
4452     ('$INPUT' => $param-><AG::ManakaiDISResourceDefinition
4453     .plVariableName>);
4454     $r-><M::PLBlockCon.appendCodeFragment> ($norm_code);
4455     }
4456     } elsif ($et eq <Q::disPerl:FOR>) {
4457     if ($source_code =~ s/^((?>(?!::).)*)::\s*//) {
4458     V: for (split /\s*\|\s*/, $1) {
4459     my $for_uri = $self->{src}
4460     -><M::ManakaiDISElement.qnameToURI>
4461     ($_, node => $node);
4462     if ($self-><M::ManakaiDISResourceDefinition
4463     .isForURI> ($for_uri)) {
4464     $r-><M::PLBlockCon.appendCodeFragment>
4465     ($self-><M::ManakaiDISResourceDefinition
4466     .plPreprocessPerlCode>
4467     ($source_code, node => $node,
4468     method_resource => $methodResource));
4469     last V;
4470     }
4471     } # V
4472     } else {
4473     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_FOR_ERR::
4474     DIS:sourceNode => {$node},
4475     DIS:sourceCode => {$source_code},
4476     DIS:elementType => {$et},
4477     }__}__;
4478     }
4479     } elsif ($et eq <Q::disPerl:ASSERT>) {
4480     my $assert_type;
4481     if ($source_code =~ s/^\s*($RegQNameChar+)\s*::\s*//o) {
4482     $assert_type = $self->{src}
4483     -><M::ManakaiDISElement.qnameToURI>
4484     ($1, node => $node);
4485     } else {
4486     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ASSERT_TYPE_ERR::
4487     DIS:sourceNode => {$node},
4488     DIS:sourceCode => {$source_code},
4489     DIS:elementType => {$et},
4490     }__}__;
4491     }
4492     # if output assertion then
4493     =pod
4494     my $assert_block = $r-><M::PLBlockCon.appendBlock>;
4495    
4496     my $param = $self-><M::ManakaiDISResourceDefinition
4497     .plParsePreprocessParameter>
4498     ($source_code, node => $node);
4499     my $context_param
4500     = $self-><M::ManakaiDISResourceDefinition
4501     .plGetContextParameter>;
4502    
4503     if ($assert_type eq <Q::DISPerl:isPositive>) {
4504    
4505     $pre = perl_statement
4506     perl_assign
4507     'my $asActual' =>
4508     '('.perl_code ($param->{actual}, %opt).')';
4509     $cond = '$asActual > 0';
4510     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = 'a positive value';
4511     $xparam->{ExpandedURI q<DOMMain:actualValue>}
4512     = perl_code_literal q<$asActual>;
4513     } elsif ($atype eq ExpandedURI q<DISPerl:invariant>) {
4514     $cond = '0';
4515     $xparam->{ExpandedURI q<DOMMain:expectedLabel>} = $param->{msg};
4516     $xparam->{ExpandedURI q<DOMMain:actualValue>} = '(invariant)';
4517     } else {
4518     valid_err (q[Assertion type <].$atype.q[> is not supported],
4519     node => $opt{node});
4520     }
4521    
4522     $r = $pre . perl_if
4523     $cond,
4524     undef,
4525    
4526    
4527     my $cls = $self->{db}-><M::ManakaiDISDatabase.getResource>
4528     (<Q::DOMException:CoreException>);
4529     my $const = $self->{db}-><M::ManakaiDISDatabase.getResource>
4530     (<Q::MDOMX:MDOM_DEBUG_BUG>);
4531     my $subtype = $self->{db}-><M::ManakaiDISDatabase.getResource>
4532     (<Q::DOMMain:ASSERTION_ERR>);
4533 wakaba 1.16 $_-><AS::ManakaiDISResourceDefinition.isReferred>
4534 wakaba 1.15 ($node || $self->{src}) for $cls, $const, $subtype;
4535     $self-><M::ManakaiDISResourceDefinition
4536     .plAppendThrow>
4537     ($assert_block, $cls, $const, $subtype,
4538     {%$param, %$context_param,
4539     <Q::DOMMain:assertionType> => {
4540     type => 'quoted', value => $assert_type,
4541     },
4542     <Q::DOMMain:traceText> => {
4543     type => 'code',
4544     value => q<(sprintf 'at %s line %s%s%s',
4545     __FILE__, __LINE__, "\n\t",
4546     Carp::longmess ())>,
4547     }});
4548    
4549     =cut
4550    
4551     } elsif ({
4552     <Q::disPerl:FILE> => 1,
4553     <Q::disPerl:LINE> => 1,
4554     <Q::disPerl:PACKAGE> => 1,
4555     }->{$et}) {
4556     $r-><M::PLAnyCon.appendAtom>
4557     ('__'.{
4558     <Q::disPerl:FILE> => 'FILE',
4559     <Q::disPerl:LINE> => 'LINE',
4560     <Q::disPerl:PACKAGE> => 'PACKAGE',
4561     }->{$et}.'__');
4562     if (length $source_code) {
4563     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR::
4564     DIS:sourceNode => {$node},
4565     DIS:sourceCode => {$source_code},
4566     DIS:elementType => {$et},
4567     }__}__;
4568     }
4569     } else {
4570     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4571     DIS:sourceNode => {$node},
4572     DIS:sourceCode => {$source_code},
4573     DIS:elementType => {$et},
4574     }__}__;
4575     }
4576     } else { ## Other than block-level element
4577     $r-><M::PLBlockCon.appendCodeFragment>
4578     ($self-><M::ManakaiDISResourceDefinition
4579 wakaba 1.16 .plPreprocessPerlStatement>
4580     ($source_code, contains_statements => true));
4581 wakaba 1.15 }
4582     } # for
4583     }__; # DEEP
4584    
4585    
4586     ## Checks \p character classes
4587     # while ($s =~ /\\p{([^{}]+)}/gs) {
4588     # my $name = $1;
4589     # $State->{ExpandedURI q<dis2pm:Package>}
4590     # ->{$State->{ExpandedURI q<dis2pm:currentPackage>}}
4591     # ->{ExpandedURI q<dis2pm:requiredCharClass>}
4592     # ->{$name} ||= $opt{node} || 1;
4593     # }
4594    
4595 wakaba 1.13
4596     @Method:
4597     @@Name: plPreprocessPerlStatement
4598     @@enDesc:
4599     Preprocesses a Perl inline code fragment
4600     (code fragment smaller than statement).
4601     @@Param:
4602     @@@Name:codeArg
4603     @@@Type:
4604     lang:Perl::ManakaiDOM:all
4605     @@@enDesc:
4606     A Perl code fragment.
4607     @@NodeParam:
4608 wakaba 1.16 @@NamedParam:
4609     @@@Name:containsStatements
4610     @@@Type:
4611     DOMMain:boolean::ManakaiDOM:all
4612     @@@enDesc:
4613     Whether one or more statements might be contained
4614     in <P::codeArg> or not.
4615 wakaba 1.13 @@Return:
4616 wakaba 1.16 @@@Type:MPLCodeFragment
4617 wakaba 1.13 @@@enDesc:
4618     Preprocessed Perl code.
4619 wakaba 1.16 @@@InCase:
4620     @@@@Type:
4621     PerlCode:ManakaiPerlBlock::ManakaiDOM:Perl
4622     @@@@enDesc:
4623     If <P::isInline> is <DOM::false>.
4624     @@@InCase:
4625     @@@@Type:
4626     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
4627     @@@@enDesc:
4628     If <P::isInline> is <DOM::true>.
4629 wakaba 1.13 @@@InlineElementException:
4630     @@@PerlDef:
4631     unless ($self->{src}) {
4632     __EXCEPTION{NO_SOURCE_NODE_ERR::
4633     DIS:uri => {$self->{uri}},
4634     }__;
4635     }
4636     __DEEP{
4637     our $RegQNameChar;
4638     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4639     .plImplementation>;
4640 wakaba 1.16 if ($containsStatements) {
4641     $r = $plimpl-><M::MPLImpl.createPerlBlockContainer>;
4642     } else {
4643     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
4644     }
4645     for my $source_code (split /(?<![\^\?qwr])(\x3C$RegQNameChar[^<>]+>
4646     )/ox, $codeArg) {
4647 wakaba 1.13 if ($source_code =~ s/^\x3C//) {
4648     $source_code =~ s/>$//;
4649     if ($source_code =~ /=$/) {
4650     ## TODO: Warning
4651     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
4652     # q{should "=" be used place of "=>"?};
4653     }
4654     if ($source_code =~ s/^(.+?):://) {
4655     my $et = $self->{src}
4656     -><M::ManakaiDISElement.qnameToURI>
4657     ($1,
4658     node => $node,
4659     default_namespace_uri => <Q::disPerl:>);
4660     if ($et eq <Q::disPerl:Q>) { ## QName constant
4661     $r-><M::PLAnyCon.appendStringLiteral>
4662     ($self->{src}
4663     -><M::ManakaiDISElement.qnameToURI>
4664     ($source_code, node => $node));
4665     } elsif ({
4666     <Q::disPerl:M> => 1,
4667     <Q::disPerl:ClassM> => 1,
4668     <Q::disPerl:AG> => 1,
4669     <Q::disPerl:AS> => 1,
4670     }->{$et}) { ## Method call
4671     my ($class_qname, $method_qname)
4672     = split /\s*\.\s*/, $source_code, 2;
4673     my $class_uri
4674     = $self->{src}
4675     -><M::ManakaiDISElement.tfqnamesToURI>
4676     ($class_qname,
4677     $self-><AG::ManakaiDISResourceDefinition
4678     .ownerClassURI>,
4679     $self->{for},
4680     node => $node);
4681     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4682     ($class_uri);
4683 wakaba 1.16 unless ($class-><AG::ManakaiDISResourceDefinition
4684     .isDefined>) {
4685     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4686     DIS:sourceNode => {$node},
4687     DIS:sourceCode => {$source_code},
4688     DIS:uri => {$class_uri},
4689     DIS:elementType => {$et},
4690     DIS:expectedType => {<Q::DISLang:AnyClass>},
4691     }__}__;
4692     }
4693 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
4694 wakaba 1.13 ($node || $self->{src});
4695     if ($et eq <Q::disPerl::ClassM> and
4696     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
4697     (<Q::ManakaiDOM:IF>)) {
4698     __UNDEEP{
4699     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
4700     DIS:uri => {$class_uri},
4701     DIS:elementType => {$et},
4702     DIS:sourceNode => {$node || $self->{src}},
4703     DIS:sourceCode => {$source_code},
4704 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:IF>},
4705 wakaba 1.13 }__;
4706     }__;
4707     }
4708     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
4709     (<Q::ManakaiDOM:IF>)) {
4710     $self-><AG::ManakaiDISResourceDefinition.definingModule>
4711     -><M::ManakaiDISModuleDefinition.plAddRequireModule>
4712     ($class-><AG::ManakaiDISResourceDefinition
4713     .definingModule>);
4714     }
4715 wakaba 1.14 my $method = $class-><M::ManakaiDISResourceDefinition
4716 wakaba 1.13 .getChildResourceByNameAndType>
4717     ($method_qname,
4718     {
4719     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
4720     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
4721     }->{$et} || <Q::DISLang:Method>);
4722     if (not $method or
4723     not $method-><AG::ManakaiDISResourceDefinition
4724     .isDefined>) {
4725     __UNDEEP{
4726     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4727     DIS:localName => {$method_qname},
4728     DIS:elementType => {$et},
4729     DIS:sourceNode => {$node || $self->{src}},
4730     DIS:sourceCode => {$source_code},
4731 wakaba 1.14 DIS:expectedType => {{
4732     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
4733     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
4734     }->{$et} || <Q::DISLang:Method>},
4735 wakaba 1.13 }__;
4736     }__;
4737     }
4738     my $class_name = '';
4739     if ($et eq <Q::disPerl:ClassM>) {
4740     $class_name = $class-><AG::ManakaiDISResourceDefinition
4741     .plFullyQualifiedName> . '->';
4742     }
4743     my $method_name = $method-><AG::ManakaiDISResourceDefinition
4744     .plName>;
4745     $r-><M::PLAnyCon.appendBare>
4746     ($class_name . $method_name);
4747     } elsif ({
4748     <Q::disPerl:Class> => 1,
4749     <Q::disPerl:ClassName> => 1,
4750     <Q::disPerl:IF> => 1,
4751     <Q::disPerl:IFName> => 1,
4752     }->{$et}) { ## Perl package name
4753     my $class_uri
4754     = $self->{src}
4755     -><M::ManakaiDISElement.tfqnamesToURI>
4756     ($source_code,
4757     $self-><AG::ManakaiDISResourceDefinition
4758     .ownerClassURI>,
4759     $self->{for},
4760     node => $node);
4761     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4762     ($class_uri);
4763 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
4764 wakaba 1.13 ($node || $self->{src});
4765 wakaba 1.14 my $pack = $class-><AG::ManakaiDISResourceDefinition
4766 wakaba 1.13 .plFullyQualifiedName>;
4767 wakaba 1.14 unless ($pack) {
4768     __UNDEEP{__EXCEPTION{NO_PERL_PACKAGE_NAME_ERR::
4769     DIS:sourceNode => {$node || $self->{src}},
4770     DIS:sourceCode => {$source_code},
4771     DIS:uri => {$class_uri},
4772     DIS:elementType => {$et},
4773     }__}__;
4774     }
4775 wakaba 1.13 if ({
4776     <Q::disPerl:ClassName> => 1,
4777     <Q::disPerl:IFName> => 1,
4778     }->{$et}) {
4779     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
4780     } else {
4781     $r-><M::PLAnyCon.appendBare> ($pack);
4782     }
4783     } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
4784     my $code_name;
4785     $source_code =~ s/^\s+//;
4786     if ($source_code =~ s/^((?>(?!::).)+)//s) {
4787     $code_name = $1;
4788     } else {
4789     __UNDEEP{
4790     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
4791     DIS:sourceCode => {$source_code},
4792     DIS:sourceNode => {$node || $self->{src}},
4793     }__;
4794     }__;
4795     }
4796     $source_code =~ s/^::\s*//;
4797     my $param = $self-><M::ManakaiDISResourceDefinition
4798     .plParsePreprocessParameter>
4799     ($source_code, node => $node);
4800     my $code_uri = $self->{src}-><M::ManakaiDISElement
4801     .tfqnamesToURI>
4802     ($code_name, null, $self->{for},
4803     node => $node);
4804     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
4805     ($code_uri);
4806 wakaba 1.14 $code-><AS::ManakaiDISResourceDefinition.isReferred>
4807 wakaba 1.13 ($node || $self->{src});
4808     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
4809     (<Q::dis2pm:InlineCode>)) {
4810     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4811     DIS:uri => {$code_uri},
4812     DIS:sourceNode => {$node || $self->{src}},
4813     DIS:sourceCode => {$source_code},
4814     DIS:expectedType => {<Q::dis2pm:InlineCode>},
4815     }__;}__;
4816     }
4817     my $pc = $code-><AG::ManakaiDISResourceDefinition
4818     .plCodeFragment>->clone;
4819     unless (defined $pc) {
4820     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4821     DIS:sourceNode => {$node || $self->{src}},
4822     DIS:sourceCode => {$source_code},
4823     DIS:uri => {$code_uri},
4824     }__}__;
4825     }
4826     for my $var (grep {/^\$/} keys %$param) {
4827     my $value;
4828     if ($param->{$var}->{type} eq 'variable') {
4829     $value = $plimpl-><M::MPLImpl.createPerlVariable>
4830     ('$', null, $param->{$var}->{value});
4831     } elsif ($param->{$var}->{type} eq 'code') {
4832     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
4833     ($param->{$var}->{value});
4834     } else {
4835     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
4836     ($param->{$var}->{value});
4837     }
4838     $pc-><M::MPLCodeFragment.replaceVariable>
4839     ($var => $value);
4840     }
4841 wakaba 1.16 $r-><M::PLInCon.appendCodeFragment> ($pc);
4842 wakaba 1.13 } elsif ($et eq <Q::disPerl:C>) {
4843     my ($class_qname, $const_name) = split /\./, $source_code, 2;
4844     my $class_uri
4845     = $self->{src}
4846     -><M::ManakaiDISElement.tfqnamesToURI>
4847     ($class_qname,
4848     $self-><AG::ManakaiDISResourceDefinition
4849     .ownerClassURI>,
4850     $self->{for},
4851     node => $node);
4852     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4853     ($class_uri);
4854 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
4855 wakaba 1.13 ($node || $self->{src});
4856     my $const = $class-><M::ManakaiDISResourceDefinition
4857     .getConstResourceByName> ($const_name);
4858     unless (defined $const) {
4859     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4860     DIS:sourceNode => {$node || $self->{src}},
4861     DIS:sourceCode => {$source_code},
4862     DIS:localName => {$const_name},
4863 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:Const>},
4864 wakaba 1.13 }__}__;
4865     }
4866 wakaba 1.14 my $pc = $const-><AG::ManakaiDISResourceDefinition
4867 wakaba 1.13 .plCodeFragment>->clone;
4868     unless (defined $pc) {
4869     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4870     DIS:sourceNode => {$node || $self->{src}},
4871     DIS:sourceCode => {$source_code},
4872     DIS:localName => {$const_name},
4873     }__}__;
4874     }
4875     $r-><M::PLInCon.appendCodeFragment> ($pc);
4876     } else {
4877     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4878     DIS:elementType => {$et},
4879     DIS:sourceNode => {$node || $self->{src}},
4880 wakaba 1.16 DIS:sourceCode => {$source_code},
4881 wakaba 1.13 }__}__;
4882     }
4883     } else {
4884     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
4885     DIS:sourceNode => {$node || $self->{src}},
4886     DIS:sourceCode => {$source_code},
4887 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:ConstGroup>},
4888 wakaba 1.13 }__}__;
4889     }
4890     } else {
4891 wakaba 1.16 for my $source_code (split /\b( t r u e |
4892     f a l s e |
4893     n u l l )\b/x, $source_code) {
4894     if ({
4895     'tr'.'ue' => true,
4896     'fal'.'se' => true,
4897     'nu'.'ll' => true,
4898     }->{$source_code}) {
4899     $r-><M::PLAnyCon.appendAtom> ({
4900     'tr'.'ue' => 1,
4901     'fal'.'se' => 0,
4902     'nu'.'ll' => 'undef',
4903     }->{$source_code});
4904     } else {
4905     $r-><M::PLInCon.appendCode> ($source_code);
4906     }
4907     }
4908     } # Inline instruction or not
4909 wakaba 1.13 } # for
4910     }__; # DEEP
4911    
4912     @Attr:
4913     @@Name: ownerClassURI
4914     @@enDesc:
4915     The URI reference of the class resource this resource
4916     belongs to.
4917     @@Type: ResourceURI
4918     @@Get:
4919     @@@enDesc:
4920     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
4921     If this resource is a class, then the URI reference
4922     of this resource is returned.
4923     @@@nullCase:
4924     @@@@enDesc:
4925     This resource does not belong to any class.
4926     @@@PerlDef:
4927     if (exists $self->{<Q::DIS:ownerClass>}) {
4928     $r = $self->{<Q::DIS:ownerClass>};
4929     } else {
4930     my $res = $self;
4931     __DEEP{
4932     {
4933     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
4934     (<Q::ManakaiDOM:Class>)) {
4935     $r = $res->{uri};
4936     } else {
4937     $res = $res-><M::ManakaiDISPropertyAccessor
4938     .getPropertyResource> (<Q::dis2pm:parentResource>);
4939     redo if $res;
4940     }
4941     }
4942     }__;
4943     $self->{<Q::DIS:ownerClass>} = $r;
4944     }
4945    
4946     @IntMethod:
4947     @@Name: plParsePreprocessParameter
4948     @@enDesc:
4949     Parses a parameter specification in preprocessing instruction
4950     and return it as a hash reference.
4951     \
4952     {NOTE:: The callee have to ensure that this resource has its
4953     <CODE::src> before the call to this method.
4954     \
4955     }
4956     @@Param:
4957     @@@Name: paramSpec
4958     @@@Type:
4959     DISLang:String::ManakaiDOM:all
4960     @@@enDesc:
4961     A parameter specification to parse.
4962     @@NodeParam:
4963     @@Return:
4964     @@@Type:
4965     Perl:hash::ManakaiDOM:all
4966     @@@enDesc:
4967     Hash containing parameters. Each hash value is also
4968     a hash reference, containing two keys <CODE::type>
4969     (its value is either <CODE::bare>, <CODE::quoted>,
4970     <CODE::code> or <CODE::variable>) and
4971     <CODE::value>.
4972     @@@RaiseException:
4973     @@@@@:BROKEN_PARAM_SPEC_ERR
4974     @@@@enDesc:
4975     The <P::paramSpec> is not well-formed.
4976     @@@PerlDef:
4977     BEGIN{
4978     our $RegQNameChar = qr/[^\s<>"'\\\[\]\{\},=\$\@%]/;
4979     use re 'eval';
4980     our $RegBlockContent;
4981     $RegBlockContent = qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{
4982     $RegBlockContent})\})*)/s;
4983     }
4984    
4985     our $RegQNameChar;
4986     our $RegBlockContent;
4987     $r = {};
4988     while ($paramSpec =~ s/^
4989     ## Parameter name
4990     (\$? $RegQNameChar+)\s*
4991    
4992     (?: =>? \s*
4993     ## ">" is now optional for inline element (">" is delimiter)
4994    
4995     ## Parameter value
4996     (
4997 wakaba 1.15 ## Variable or Bare string
4998     \ \$? $RegQNameChar+
4999 wakaba 1.13 |
5000     ## Quoted string
5001     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
5002     |
5003     ## Code
5004 wakaba 1.15 \ \{$RegBlockContent\}
5005 wakaba 1.13
5006     )
5007    
5008     \s*)?
5009    
5010     (?:,\s*|$)//ox) {
5011    
5012     my ($n, $v) = ($1, $2);
5013     if (defined $v) {
5014     if ($v =~ /^'/) {
5015     $v = {type => 'quoted',
5016     value => substr ($v, 1, length ($v) - 2)};
5017     } elsif ($v =~ /^\{/) {
5018     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
5019     } elsif ($v =~ /^\$/) {
5020 wakaba 1.16 $v = {type => 'variable', value => $v};
5021 wakaba 1.13 } else {
5022     $v = {type => 'bare', value => $v};
5023     }
5024     } else {
5025     $v = {type => 'boolean', value => true};
5026     }
5027    
5028     if ($n =~ /^\$/) {
5029     $r->{$n} = $v;
5030     } else {
5031     __DEEP{
5032     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
5033     ($n, node => $node || $self->{src})} = $v;
5034     }__;
5035     }
5036     } # while
5037    
5038     if (length $paramSpec) {
5039     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
5040     DIS:sourceCode => {$paramSpec},
5041     DIS:sourceNode => {$node || $self->{src}},
5042     }__;
5043     }
5044    
5045 wakaba 1.15 @IntMethod:
5046     @@Name: plGetContextParameter
5047     @@enDesc:
5048     Returns contextual parameters which describes the <QUOTE::location>
5049     of this resource.
5050     @@Return:
5051     @@@Type:
5052     Perl:hash::ManakaiDOM:all
5053     @@@enDesc:
5054     Hash of parameters as <M::.plParsePreprocessParameter> returns.
5055     @@@PerlDef:
5056     $r = {};
5057     __DEEP{
5058     if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5059     (<Q::DISLang:MethodReturn>)) {
5060     my $method = $self-><M::ManakaiDISPropertyAccessor
5061     .getPropertyResource> (<Q::dis2pm:parentResource>);
5062     $r->{<Q::MDOMX:method>}
5063     = {type => 'quoted',
5064     value => $method-><AG::ManakaiDISResourceDefinition.plName>};
5065     my $class = $method-><M::ManakaiDISPropertyAccessor
5066     .getPropertyResource> (<Q::dis2pm:parentResource>);
5067     $r->{<Q::MDOMX:class>}
5068     = {type => 'quoted',
5069     value => $class-><AG::ManakaiDISResourceDefinition
5070     .plFullyQualifiedName>};
5071     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5072     (<Q::DISLang:AttributeGet>)) {
5073     my $attr = $self-><M::ManakaiDISPropertyAccessor
5074     .getPropertyResource> (<Q::dis2pm:parentResource>);
5075     $r->{<Q::MDOMX:attr>}
5076     = {type => 'quoted',
5077     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
5078     my $class = $attr-><M::ManakaiDISPropertyAccessor
5079     .getPropertyResource> (<Q::dis2pm:parentResource>);
5080     $r->{<Q::MDOMX:class>}
5081     = {type => 'quoted',
5082     value => $class-><AG::ManakaiDISResourceDefinition
5083     .plFullyQualifiedName>};
5084     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'get'};
5085     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
5086     (<Q::DISLang:AttributeSet>)) {
5087     my $attr = $self-><M::ManakaiDISPropertyAccessor
5088     .getPropertyResource> (<Q::dis2pm:parentResource>);
5089     $r->{<Q::MDOMX:attr>}
5090     = {type => 'quoted',
5091     value => $attr-><AG::ManakaiDISResourceDefinition.plName>};
5092     my $class = $attr-><M::ManakaiDISPropertyAccessor
5093     .getPropertyResource> (<Q::dis2pm:parentResource>);
5094     $r->{<Q::MDOMX:class>}
5095     = {type => 'quoted',
5096     value => $class-><AG::ManakaiDISResourceDefinition
5097     .plFullyQualifiedName>};
5098     $r->{<Q::MDOMX:on>} = {type => 'quoted', value => 'set'};
5099     } else {
5100     $r->{<Q::MDOMX:resourceURI>} = {type => 'quoted',
5101     value => $self->{uri}};
5102     }
5103     }__;
5104    
5105     @Method:
5106     @@Name: plGetMethodInputNormalizer
5107     @@enDesc:
5108     Returns an input processor. This method assumes that
5109     this resource is a method parameter (<Q::DISLang:MethodParameter>).
5110     @@Return:
5111     @@@Type:ManakaiDISResourceDefinition
5112     @@@enDesc:
5113     A <Q::DISLang:InputProcessor> corresponding to
5114     the parameter defined by this resource.
5115     \
5116     {NOTE:: <Q::ManakaiDOM:inputNormalize> property is
5117     obsolete in favor of <Q::DISLang:InputProcessor>;
5118     this method does not support the former.
5119     \
5120     }
5121     @@@nullCase:
5122     @@@@enDesc:
5123     No input processor found.
5124     @@@PerlDef:
5125     my $type;
5126     try {
5127     $type = $self-><AG::ManakaiDISResourceDefinition
5128     .disActualDataTypeResource>;
5129 wakaba 1.16 #$type_node = $self->< AG::ManakaiDISResourceDefinition
5130 wakaba 1.15 # .disActualDataTypeNode>;
5131     } catch <Class::ManakaiDISException> with {
5132     my $err = shift;
5133     unless ($err->{<Q::MDOMX:subtype>} eq <Q::DIS:NO_DIS_TYPE_ERR>) {
5134     $err->throw;
5135     }
5136     };
5137     if ($type) {
5138     __DEEP{
5139     $r = $type-><M::ManakaiDISResourceDefinition.getChildResourceByType>
5140     (<Q::DISLang:InputProcessor>);
5141     }__;
5142     }
5143    
5144     @IntMethod:
5145     @@Name: plAppendThrow
5146     @@enDesc:
5147     Appends a <Perl::report> method call statement for exception reporting.
5148     @@Param:
5149     @@@Name: parentNode
5150     @@@enDesc:
5151     The parent Perl code node to which a new statement is appended.
5152     @@@Type: PLBlockCon
5153     @@Param:
5154     @@@Name: xclass
5155     @@@Type: ManakaiDISResourceDefinition
5156     @@@enDesc:
5157     An exception class.
5158     @@Param:
5159     @@@Name: xcode
5160     @@@Type: ManakaiDISResourceDefinition
5161     @@@enDesc:
5162     An exception code constant.
5163     @@Param:
5164     @@@Name: xsubtype
5165     @@@Type: ManakaiDISResourceDefinition
5166     @@@enDesc:
5167     An exception subtype.
5168     @@@nullCase:
5169     @@@@enDesc:
5170     No subtype.
5171     @@Param:
5172     @@@Name: xparam
5173     @@@Type:
5174     Perl:hash::ManakaiDOM:all
5175     @@@enDesc:
5176     A hash containing parameters passed to the <Perl:report> method.
5177     A hash key is to be a parameter name. Hash values
5178     should also be hashes. A hash value hash has two values:
5179     <CODE::type> and <CODE::value>. A <CODE::value>
5180     value is a parameter value. If <CODE::type> is
5181     <CODE::code>, then <CODE::value> is assumed as a Perl code fragment.
5182     Otherwise, <CODE::value> is quoted to be interpreted as a string as is.
5183     @@Return:
5184 wakaba 1.16 @@@RaiseException:
5185     @@@@@: RESOURCE_NOT_DEFINED_ERR
5186     @@@@enDesc:
5187     Either <P::xclass>, <P::xcode> or <P::xsubtype>
5188     is not defined.
5189 wakaba 1.15 @@@PerlDef:
5190     my $statement = $parentNode-><M::PLBlockCon.appendStatement>
5191     ('report '.
5192     $xclass-><AG::ManakaiDISResourceDefinition.plFullyQualifiedName>.
5193     ' -object => $self');
5194 wakaba 1.16 my $xclass_module = $xclass-><AG::ManakaiDISResourceDefinition
5195     .definingModule>;
5196     unless ($xclass-><AG::ManakaiDISResourceDefinition.isDefined> or
5197     not $xclass_module) {
5198     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
5199     DIS:sourceNode => {$self->{src}},
5200     DIS:uri => {$xclass->{uri}},
5201     DIS:localName => {$xclass->{localName}},
5202     DIS:expectedType => {<Q::DOMException:AnyExceptionClass>},
5203     }__;
5204     }
5205 wakaba 1.15 $self-><AG::ManakaiDISResourceDefinition.definingModule>
5206 wakaba 1.16 -><M::ManakaiDISModuleDefinition.plAddRequireModule> ($xclass_module);
5207 wakaba 1.15 $xparam->{-type} = {type => 'quoted',
5208     value => $xcode-><AG::ManakaiDISResourceDefinition
5209     .plName>};
5210     $xparam->{<Q::MDOMX:subtype>} = {type => 'quoted',
5211     value => $xsubtype->{nameURI}}
5212     if $xsubtype;
5213     for my $name (keys %$xparam) {
5214     my $pname = $name;
5215     $pname =~ s/(['\\])/\\$1/g;
5216     $pname = qq<'$pname'>;
5217     $statement-><M::PLInCon.appendCode>
5218     (', ' . $pname . ' => ');
5219     if ($xparam->{$name}->{type} eq 'code') {
5220     if (ref $xparam->{$name}->{value}) {
5221     $statement-><M::PLInCon.appendCodeFragment>
5222     ($xparam->{$name}->{value});
5223     } else {
5224 wakaba 1.16 $statement-><M::PLInCon.appendCodeFragment>
5225 wakaba 1.15 ($self-><M::ManakaiDISResourceDefinition
5226     .plPreprocessPerlStatement>
5227     ($xparam->{$name}->{value}));
5228     }
5229     } else { ## String as is
5230     $statement-><M::PLAnyCon.appendStringLiteral>
5231     ($xparam->{$name}->{value});
5232     }
5233     }
5234    
5235 wakaba 1.2 ##DISResourceDefinition
5236    
5237 wakaba 1.13 ElementTypeBinding:
5238 wakaba 1.15 @Name: BlockElementException
5239     @ElementType:
5240     ManakaiDOM:raises
5241     @ShadowContent:
5242     @@@: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
5243     @@Description:
5244     @@@lang:en
5245     @@@@:
5246     An exception type specification is required but not specified.
5247     @ShadowSibling:
5248     @@ManakaiDOM:raises:
5249     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
5250     @@@Description:
5251     @@@@lang:en
5252     @@@@@:
5253     A code qualified name is required but not specified.
5254     @@ManakaiDOM:raises:
5255     @@@@: RESOURCE_NOT_DEFINED_ERR
5256     @@@Description:
5257     @@@@lang:en
5258     @@@@@:
5259     A referred resource is not defined or has different type.
5260     @@ManakaiDOM:raises:
5261     @@@@: PERL_CODE_NOT_DEFINED_ERR
5262     @@@Description:
5263     @@@@lang:en
5264     @@@@@:
5265     A referred resource does not have its Perl definition.
5266     @@ManakaiDOM:raises:
5267     @@@@: PERL_PREPROCESS_NO_METHOD_ERR
5268     @@@Description:
5269     @@@@lang:en
5270     @@@@@:
5271     A preprocessing instruction which is allowed only in
5272     methods is embeded in a context which is not in any method.
5273     @@ManakaiDOM:raises:
5274     @@@@: PERL_PREPROCESS_NO_FOR_ERR
5275     @@@Description:
5276     @@@@lang:en
5277     @@@@@:
5278     A <QUOTE::for> qualified name is required but not specified.
5279     @@ManakaiDOM:raises:
5280     @@@@: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
5281     @@@Description:
5282     @@@@lang:en
5283     @@@@@:
5284     An assertion type qualified name is required but not specified.
5285     @@ManakaiDOM:raises:
5286     @@@@: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
5287     @@@Description:
5288     @@@@lang:en
5289     @@@@@:
5290     A preprocessing instruction block is specified
5291     but not allowed for this element type.
5292    
5293     ElementTypeBinding:
5294 wakaba 1.13 @Name: InlineElementException
5295     @ElementType:
5296     ManakaiDOM:raises
5297     @ShadowContent:
5298     @@@: NO_SOURCE_NODE_ERR
5299     @@Description:
5300     @@@lang:en
5301     @@@@:
5302     This resource definition does not have associated node
5303     in the source tree.
5304     @ShadowSibling:
5305     @@ManakaiDOM:raises:
5306     @@@@: INTERFACE_CLASS_METHOD_ERR
5307     @@@Description:
5308     @@@@lang:en
5309     @@@@@:
5310     An attempt is made to call a class (static) method
5311     via an interface, not class.
5312     @@ManakaiDOM:raises:
5313     @@@@: RESOURCE_NOT_DEFINED_ERR
5314     @@@Description:
5315     @@@@lang:en
5316     @@@@@:
5317     A package, method or attribute is not defined or not
5318     a resoure of that type.
5319     @@ManakaiDOM:raises:
5320     @@@@: NO_LOCAL_NAME_ERR
5321     @@@Description:
5322     @@@@lang:en
5323     @@@@@:
5324     A referred resource does not have its local name so
5325     that it is impossible to refer it by name.
5326     @@ManakaiDOM:raises:
5327     @@@@: RESERVED_PERL_METHOD_NAME_ERR
5328     @@@Description:
5329     @@@@lang:en
5330     @@@@@:
5331     A referred method has its name reserved for special-purpose.
5332     @@ManakaiDOM:raises:
5333     @@@@: BROKEN_PARAM_SPEC_ERR
5334     @@@Description:
5335     @@@@lang:en
5336     @@@@@:
5337     A parameter specification is not well-formed.
5338     @@ManakaiDOM:raises:
5339     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
5340 wakaba 1.14 @@@Description:
5341     @@@@lang:en
5342     @@@@@:
5343     A preprocessing instruction does not contain
5344     Perl code fragment name.
5345 wakaba 1.13 @@ManakaiDOM:raises:
5346     @@@@: PERL_CODE_NOT_DEFINED_ERR
5347 wakaba 1.14 @@@Description:
5348     @@@@lang:en
5349     @@@@@:
5350     The referred resource does not have its Perl definition.
5351 wakaba 1.13 @@ManakaiDOM:raises:
5352     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
5353 wakaba 1.14 @@@Description:
5354     @@@@lang:en
5355     @@@@@:
5356     A preprocessing instruction does not contain its element type name.
5357 wakaba 1.13 @@ManakaiDOM:raises:
5358     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
5359 wakaba 1.14 @@@Description:
5360     @@@@lang:en
5361     @@@@@:
5362     An unknown element type is encounted.
5363     @@ManakaiDOM:raises:
5364     @@@@: NO_PERL_PACKAGE_NAME_ERR
5365     @@@Description:
5366     @@@@lang:en
5367     @@@@@:
5368     No Perl package name is defined for a class or interface.
5369 wakaba 1.13
5370     PropDef:
5371     @QName: ownerClass
5372     @enDesc:
5373     The class to which this resource belongs.
5374     @Type: ResourceURI
5375     @rdfs:range:
5376     rdf:Resource
5377     @rdfs:domain:
5378     ManakaiDOM:Class
5379    
5380 wakaba 1.12 ResourceDef:
5381     @QName: DOMMinImpl
5382     @rdf:type:
5383     ManakaiDOM:IF
5384     @AliasFor:
5385     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
5386    
5387     ResourceDef:
5388     @QName: SWCFGNode
5389     @rdf:type:
5390     ManakaiDOM:IF
5391     @AliasFor:
5392     swcfg21:SWCFGNode::swcfg21:ForLatest
5393    
5394     ResourceDef:
5395     @QName: SWCFGDoc
5396     @rdf:type:
5397     ManakaiDOM:IF
5398     @AliasFor:
5399     swcfg21:SWCFGDocument::swcfg21:ForLatest
5400    
5401     ResourceDef:
5402     @QName: MPLImpl
5403     @rdf:type:
5404     ManakaiDOM:Class
5405     @AliasFor:
5406     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
5407    
5408     ResourceDef:
5409     @QName: MPLCodeFragment
5410     @rdf:type:
5411     ManakaiDOM:Class
5412     @AliasFor:
5413     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
5414    
5415     ResourceDef:
5416 wakaba 1.13 @QName: PLInCon
5417     @rdf:type:
5418     ManakaiDOM:Class
5419     @AliasFor:
5420     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
5421    
5422     ResourceDef:
5423 wakaba 1.15 @QName: PLBlockCon
5424     @rdf:type:
5425     ManakaiDOM:Class
5426     @AliasFor:
5427     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
5428    
5429     ResourceDef:
5430 wakaba 1.13 @QName: PLAnyCon
5431     @rdf:type:
5432     ManakaiDOM:Class
5433     @AliasFor:
5434     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
5435    
5436     ResourceDef:
5437     @QName: MPLSS
5438     @rdf:type:
5439     ManakaiDOM:Class
5440     @AliasFor:
5441     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
5442    
5443     ResourceDef:
5444 wakaba 1.12 @QName: MPLSub
5445     @rdf:type:
5446     ManakaiDOM:Class
5447     @AliasFor:
5448     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
5449    
5450     ResourceDef:
5451     @QName: MPLUnparsedCode
5452     @rdf:type:
5453     ManakaiDOM:Class
5454     @AliasFor:
5455     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
5456    
5457     PropDef:
5458     @QName: plCodeFragment
5459     @enDesc:
5460     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
5461    
5462     XParamDef:
5463     @QName: errResource
5464     @enDesc:
5465     A resource on which an error has occurred.
5466    
5467 wakaba 1.8 XParamDef:
5468     @QName: generatedName
5469     @enDesc:
5470     A generated name.
5471    
5472 wakaba 1.2 ClsDef:
5473     @ClsQName: ManakaiDISPropertyAccessor
5474 wakaba 1.3 @enDesc:
5475 wakaba 1.2 Accessor methods for resource or module properties.
5476    
5477     @Method:
5478 wakaba 1.8 @@Name: getPropertyBoolean
5479     @@enDesc:
5480     Gets boolean property value.
5481     @@PropNameParam:
5482     @@Param:
5483     @@@Name:default
5484     @@@Type:
5485     DOMMain:boolean::ManakaiDOM:all
5486     @@@enDesc:
5487     The default value that is returned if no explicit property
5488     value specification found for this resource.
5489     @@Return:
5490     @@@Type:
5491     DOMMain:boolean::ManakaiDOM:all
5492     @@@enDesc:
5493     The property value.
5494     @@@PerlDef:
5495     if (exists $self->{$propName}) {
5496     $r = defined $self->{$propName} ? $self->{$propName} : $default;
5497     } elsif ($self->{src}) {
5498     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5499     ($propName, for_arg => $self->{for},
5500     forp_arg => $self->{forp});
5501     $self->{$propName} = $r;
5502     $r = $default unless defined $r;
5503     } else {
5504     $r = $default;
5505     }
5506    
5507     @Method:
5508 wakaba 1.2 @@Name: getPropertyText
5509     @@enDesc:
5510     Gets property value text.
5511     @@PropNameParam:
5512     @@Param:
5513     @@@Name:default
5514     @@@Type:
5515 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
5516 wakaba 1.2 @@@enDesc:
5517     The default value that is returned if no explicit property
5518     value specification found for this resource.
5519     @@@nullCase:
5520     @@@@enDesc:
5521     No default value supplied; <DOM::null> is returned if
5522     no value specified.
5523     @@Return:
5524     @@@Type:
5525 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
5526 wakaba 1.2 @@@enDesc:
5527     The property value string.
5528     @@@nullCase:
5529     @@@@enDesc:
5530     No value nor default value has specified.
5531     @@@PerlDef:
5532     if (exists $self->{$propName}) {
5533     $r = defined $self->{$propName} ? $self->{$propName} : $default;
5534     } elsif ($self->{src}) {
5535     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5536     ($propName, for_arg => $self->{for},
5537     forp_arg => $self->{forp});
5538 wakaba 1.8 if ($r) {
5539     $r = $self->{$propName}
5540 wakaba 1.14 = $r-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
5541 wakaba 1.8 $r = $default unless defined $r;
5542     } else {
5543     $r = $default;
5544     $self->{$propName} = null;
5545     }
5546 wakaba 1.2 } else {
5547     $r = $default;
5548     }
5549    
5550     @Method:
5551     @@Name: getPropertyResource
5552     @@enDesc:
5553     Gets property value resource.
5554     @@PropNameParam:
5555 wakaba 1.10 @@NamedParam:
5556     @@@Name: defaultMediaType
5557     @@@Type: ResourceURI
5558     @@@enDesc:
5559     The URI reference of the default media type which is used
5560     when the property value is retrieved from the source tree
5561     and the source tree element does not have its <Q::dis:ContentType>
5562     attribute specified.
5563     @@@nullCase:
5564     @@@@enDesc:
5565     Defaulted to <Q::dis:TypeQName>.
5566 wakaba 1.2 @@Return:
5567     @@@Type: ManakaiDISResourceDefinition
5568     @@@enDesc:
5569     The property value resource.
5570     @@@nullCase:
5571     @@@@enDesc:
5572     No value has specified.
5573 wakaba 1.8 @@@UndeclaredPrefixException:
5574 wakaba 1.12 @@@RaiseException:
5575     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
5576     @@@@enDesc:
5577     The media type of the attribute node in the source tree
5578     corresponding to this resource is not supported.
5579 wakaba 1.2 @@@PerlDef:
5580     if (defined $self->{$propName}) {
5581 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
5582     ($self->{$propName});
5583 wakaba 1.8 } elsif ($self->{src}) {
5584     __DEEP{
5585     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
5586     ($propName, for_arg => $self->{for},
5587     forp_arg => $self->{forp});
5588     if ($r) {
5589 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
5590     unless defined $defaultMediaType;
5591     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
5592 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
5593     for_arg => $self->{for},
5594     forp_arg => $self->{forp})) {
5595 wakaba 1.10 $self->{$propName}
5596     = $r-><AG::ManakaiDISElement.qnameValueURI>;
5597     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
5598 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
5599     for_arg => $self->{for},
5600     forp_arg => $self->{forp})) {
5601 wakaba 1.10 $self->{$propName}
5602     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
5603     ($self->{src}-><AG::swcfg21:SWCFGNode
5604     ::swcfg21:ForLatest.nodeID>,
5605     $self->{for});
5606     } else {
5607     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
5608     (for_arg => $self->{for},
5609     forp_arg => $self->{forp});
5610     __UNDEEP{
5611     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
5612     DIS:uri => {$mt},
5613     DIS:sourceNode => {$r},
5614     }__;
5615     }__;
5616     }
5617 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
5618     ($self->{$propName});
5619 wakaba 1.14 $r-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
5620 wakaba 1.8 }
5621     }__;
5622 wakaba 1.2 }
5623    
5624     @Method:
5625 wakaba 1.10 @@Name: getPropertyResourceList
5626     @@enDesc:
5627     Gets property value resource list.
5628     @@PropNameParam:
5629     @@NamedParam:
5630     @@@Name: recursiveISA
5631     @@@Type:
5632     DOMMain:boolean
5633     @@@enDesc:
5634     Whether property resource values of <Q::dis:ISA> resources
5635     of this resource should also be included to the returned list or not.
5636     @@NamedParam:
5637     @@@Name: defaultMediaType
5638     @@@Type: ResourceURI
5639     @@@enDesc:
5640     The URI reference of the default media type which is used
5641     when the property value is retrieved from the source tree
5642     and the source tree element does not have its <Q::dis:ContentType>
5643     attribute specified.
5644     @@@nullCase:
5645     @@@@enDesc:
5646     Defaulted to <Q::dis:TypeQName>.
5647     @@Return:
5648     @@@Type: ResourceList
5649     @@@enDesc:
5650     An array reference of the property value resources.
5651     \
5652     {NOTE:: This list is <QUOTE::dead>.
5653     \
5654     }
5655     @@@UndeclaredPrefixException:
5656 wakaba 1.12 @@@RaiseException:
5657     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
5658     @@@@enDesc:
5659     The media type of the attribute node in the source tree
5660     corresponding to this resource is not supported.
5661 wakaba 1.10 @@@PerlDef:
5662     $r = [];
5663     if (defined $self->{$propName}) {
5664     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
5665     ? $self->{$propName} : []}) {
5666     push @$r,
5667     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
5668     }
5669     } elsif ($self->{src}) {
5670     __DEEP{
5671     $self->{$propName} = [];
5672     $defaultMediaType = <Q::dis:TypeQName>
5673     unless defined $defaultMediaType;
5674     for my $res_name_node
5675     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
5676     ($propName, for_arg => $self->{for},
5677     forp_arg => $self->{forp})}) {
5678     my $res_uri;
5679     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
5680 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
5681     for_arg => $self->{for},
5682     forp_arg => $self->{forp})) {
5683 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
5684     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
5685 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
5686     for_arg => $self->{for},
5687     forp_arg => $self->{forp})) {
5688 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
5689     ($self->{src}-><AG::swcfg21:SWCFGNode
5690     ::swcfg21:ForLatest.nodeID>,
5691     $self->{for});
5692     } else {
5693     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
5694     (for_arg => $self->{for},
5695     forp_arg => $self->{forp});
5696     __UNDEEP{
5697     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
5698     DIS:uri => {$mt},
5699     DIS:sourceNode => {$res_name_node},
5700     }__;
5701     }__;
5702     }
5703     push @{$self->{$propName}}, $res_uri;
5704     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
5705     ($res_uri);
5706     push @$r, $res;
5707 wakaba 1.14 $res-><AS::ManakaiDISResourceDefinition.isReferred>
5708 wakaba 1.10 ($res_name_node);
5709     }
5710     }__;
5711     }
5712     if ($recursiveISA) {
5713     __DEEP{
5714     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
5715     my @p_res = @$r;
5716     for my $p_res (@p_res) {
5717     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
5718     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
5719     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
5720     .getPropertyResourceList>
5721     (<Q::dis:ISA>, recursive_isa => true,
5722     ___recursive_isa_done => $opt{___recursive_isa_done},
5723     default_media_type => $defaultMediaType)};
5724     }
5725     }__;
5726     }
5727    
5728     @Method:
5729 wakaba 1.2 @@Name: addPropertyResourceList
5730     @@enDesc:
5731     Adds a resource to a resource-list property value.
5732     \
5733     {ISSUE:: Should an exception be thrown if the property is
5734     not of list?
5735     \
5736     }
5737 wakaba 1.10 \
5738     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
5739     an item clears the list --- i.e. the property values
5740     in the source tree will be ignored. Call
5741     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
5742     before adding to avoid this behavior.
5743     \
5744     }
5745 wakaba 1.2 @@PropNameParam:
5746     @@Param:
5747     @@@Name: res
5748     @@@Type: ManakaiDISResourceDefinition
5749     @@@enDesc:
5750     A resource to add.
5751     @@Return:
5752     @@@PerlDef:
5753     if (ref $self->{$propName} eq 'ARRAY') {
5754     push @{$self->{$propName}}, $res->{uri};
5755     } elsif (not defined $self->{$propName}) {
5756     $self->{$propName} = [$res->{uri}];
5757     }
5758    
5759 wakaba 1.3 ElementTypeBinding:
5760     @Name: PropNameParam
5761     @ElementType:
5762     dis:ResourceDef
5763     @ShadowContent:
5764     @@rdf:type:
5765     DISLang:MethodParameter
5766     @@Name: propName
5767     @@Type: ResourceURI
5768     @@Description:
5769     @@@lang:en
5770     @@@@:
5771     The name of the property.
5772    
5773 wakaba 1.2 ##DISPropertyAccessor
5774    
5775     PropDef:
5776     @QName:isAnon
5777     @Description:
5778     @@lang:en
5779     @@@:
5780     Whether the subject resource is anonymous or not.
5781     @Type:
5782     DOMMain:boolean
5783    
5784     PropDef:
5785     @QName:isDefined
5786     @Description:
5787     @@lang:en
5788     @@@:
5789     Whether the subject resource is defined or not.
5790    
5791     PropDef:
5792 wakaba 1.3 @QName:isReferred
5793 wakaba 1.2 @Description:
5794     @@lang:en
5795     @@@:
5796     Whether the subject resource is referred or not.
5797     @Type:
5798     DOMMain:any
5799    
5800     PropDef:
5801     @QName:definingModule
5802     @Description:
5803     @@lang:en
5804     @@@:
5805     The <QUOTE::dis> module in which the subject resource is defined.
5806     @rdfs:domain:
5807     DISCore:Module
5808 wakaba 1.1
5809     ## -- Datatypes
5810    
5811     URITypeDef:
5812 wakaba 1.3 @QName: AnyURI
5813     @Description:
5814     @@lang:en
5815     @@@:
5816     Any URI references.
5817    
5818     URITypeDef:
5819     @QName: FileURI
5820     @enDesc:
5821     URI references identifying file.
5822    
5823     URITypeDef:
5824 wakaba 1.1 @QName: ForURI
5825     @Description:
5826     @@lang:en
5827     @@@:
5828     <QUOTE::For> URI references.
5829    
5830     DataTypeDef:
5831     @QName: ForURIList
5832     @Description:
5833     @@lang:en
5834     @@@:
5835     References to the array containing <QUOTE::for> URI references.
5836    
5837     URITypeDef:
5838 wakaba 1.3 @QName: ResourceURI
5839     @Description:
5840     @@lang:en
5841     @@@:
5842     A URI reference for a <QUOTE::dis> resource.
5843    
5844     URITypeDef:
5845 wakaba 1.1 @QName: MediaTypeURI
5846     @Description:
5847     @@lang:en
5848     @@@:
5849     Media type URI references.
5850 wakaba 1.3 @rdfs:subClassOf: ResourceURI
5851    
5852     URITypeDef:
5853     @QName: ModuleURI
5854     @enDesc:
5855     URI references for <QUOET::dis> modules.
5856     @rdfs:subClassOf: ResourceURI
5857    
5858     URITypeDef:
5859     @QName: NameURI
5860     @enDesc:
5861     URI references identifying a resource.
5862     @rdfs:subClassOf: ResourceURI
5863 wakaba 1.10
5864     DataTypeDef:
5865     @QName: ResourceList
5866     @enDesc:
5867     References to array containing resource definition objects.
5868     @rdfs:subClassOf:
5869     Perl:ARRAY::ManakaiDOM:all
5870 wakaba 1.3
5871     ElementTypeBinding:
5872     @Name: DataTypeDef
5873     @ElementType:
5874     dis:ResourceDef
5875     @ShadowContent:
5876     @@rdf:type:
5877     ManakaiDOM:DataType
5878    
5879     ElementTypeBinding:
5880     @Name: URITypeDef
5881     @ElementType:
5882     dis:ResourceDef
5883     @ShadowContent:
5884     @@rdf:type:
5885     ManakaiDOM:DataType
5886     @@rdfs:subClassOf: AnyURI
5887 wakaba 1.1
5888     ## -- Exceptions
5889    
5890     XParamDef:
5891 wakaba 1.5 @QName: anotherSourceNode
5892     @enDesc:
5893     Another source node in which an error has occurred. In cases
5894     of <QUOTE::already defined> errors, it is the node that
5895     defines the resource first.
5896     @Type: ManakaiDISNode
5897 wakaba 1.3
5898 wakaba 1.12 ResourceDef:
5899     @QName: UNDECLARED_NS_PREFIX_ERR
5900     @For: ForLatest
5901     @AliasFor:
5902     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
5903    
5904 wakaba 1.3 ExceptionDef:
5905     @ClsQName: ManakaiDISException
5906     @enDesc:
5907     Exceptions for the <QUOTE::dis> operations.
5908 wakaba 1.4 @ClsISA:
5909     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
5910 wakaba 1.3 @XConstGroupDef:
5911     @@ClsQName: ManakaiDISExceptionCode
5912     @@enDesc:
5913     Exception codes for <Class::ManakaiDISException>.
5914     @@XConstDef:
5915 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
5916     @@@Value:3
5917     @@@enDesc:
5918     An attempt is made to break the hierarchy.
5919     @@@XSubTypeDef:
5920     @@@@QName: MERGE_ITSELF_ERR
5921     @@@@enDesc:
5922     An attempt is made to merge the resource to itself.
5923     @@@@XSourceNodeParam:
5924     @@@@XParam:
5925     @@@@@QName:uri
5926     @@@@@enDesc:
5927     The URI reference of the resource to merge.
5928     @@@@enMufDef:
5929     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
5930     );> to itself
5931     @@XConstDef:
5932 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
5933     @@@Value:9
5934     @@@enDesc:
5935     An attempt is made to do something the implementation does not support.
5936     @@@XSubTypeDef:
5937     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
5938     @@@@enDesc:
5939     The implementation does not support the media type.
5940     @@@@XParam:
5941     @@@@@QName: uri
5942     @@@@@enDesc:
5943     The URI reference of the media type that is not supported.
5944     @@@@XSourceNodeParam:
5945 wakaba 1.12 @@@@enMufDef:
5946     Media type <%p (name => {<Q::DIS:uri>});> is not supported
5947 wakaba 1.3 @@@XSubTypeDef:
5948 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
5949     @@@@enDesc:
5950     An unsupported type of element is encounted.
5951     @@@@XSourceNodeParam:
5952     @@@@XParam:
5953     @@@@@QName:elementType
5954     @@@@@enDesc:
5955     The element type URI reference of the element.
5956 wakaba 1.16 @@@@enMufDef:
5957     Element type "%p (name => {<Q::DIS:elementType>});" is not supported
5958 wakaba 1.13 @@@XSubTypeDef:
5959 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
5960 wakaba 1.3 @@@@enDesc:
5961 wakaba 1.12 There is no implementation that supports the
5962     <Feature::Util:PerlCode> feature, version
5963     <FeatureVer::1.0>.
5964 wakaba 1.3 @@XConstDef:
5965     @@@Name: INVALID_STATE_ERR
5966     @@@Value:11
5967     @@@enDesc:
5968     An attempt is made to use an object that is not (or no longer) usable.
5969     @@@XSubTypeDef:
5970     @@@@QName: NO_ASSOCIATED_DB_ERR
5971     @@@@enDesc:
5972     No <QUOTE::dis> database has been associated with this document.
5973 wakaba 1.4 @@XConstDef:
5974     @@@Name: INVALID_SOURCE_ERR
5975     @@@Value: 200
5976     @@@enDesc:
5977     The source input is well-formed but invalid.
5978     @@@XSubTypeDef:
5979     @@@@QName: NO_MODULE_QNAME_ERR
5980     @@@@enDesc:
5981     The <Q::dis:Module> element must have its <Q::dis:QName>
5982     attribute.
5983 wakaba 1.8 @@@@XSourceNodeParam:
5984     @@@XSubTypeDef:
5985     @@@@QName: NO_LOCAL_NAME_ERR
5986     @@@@enDesc:
5987     The resource does not have a local name.
5988     @@@@XSourceNodeParam:
5989 wakaba 1.4 @@@XSubTypeDef:
5990     @@@@QName: UNABLE_TO_GET_MODULE_ERR
5991     @@@@enDesc:
5992     The implementation is unable to get the module source.
5993     @@@@Def:
5994     @@@@@ContentType:
5995     lang:muf
5996     @@@@@lang:en
5997     @@@@@@:
5998     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
5999     @@@@XParam:
6000     @@@@@QName: uri
6001     @@@@@enDesc:
6002     The URI reference of the module.
6003     @@@@XParam:
6004     @@@@@QName: namespaceURI
6005     @@@@@enDesc:
6006     The namespace URI of the module name.
6007     @@@@XParam:
6008     @@@@@QName: localName
6009     @@@@@enDesc:
6010     The local name of the module name.
6011     @@@@XParam:
6012     @@@@@QName: for
6013     @@@@@enDesc:
6014     The <QUOTE::for> of the module.
6015 wakaba 1.5 @@@XSubTypeDef:
6016     @@@@QName: NO_FOR_QNAME_ERR
6017     @@@@enDesc:
6018     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
6019     @@@@XSourceNodeParam:
6020     @@@XSubTypeDef:
6021     @@@@QName: FOR_ALREADY_DEFINED_ERR
6022     @@@@enDesc:
6023     The <QUOTE::for> named as the same URI reference has
6024     already defined.
6025     @@@@XSourceNodeParam:
6026     @@@@XParam:
6027     @@@@@QName: anotherSourceNode
6028     @@@@@enDesc:
6029     The node that defines the <QUOTE::for> URI reference before.
6030 wakaba 1.7 @@@@XParam:
6031     @@@@@Name: uri
6032     @@@@@enDesc:
6033     The URI reference of the <QUOTE::for> attempted to define.
6034     @@@@enMufDef:
6035     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
6036 wakaba 1.5 @@@XSubTypeDef:
6037     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
6038     @@@@enDesc:
6039     The <QUOTE::dis> resource named as the same URI reference has
6040     already defined.
6041     @@@@XSourceNodeParam:
6042     @@@@XParam:
6043     @@@@@QName: anotherSourceNode
6044     @@@@@enDesc:
6045     The node that defines the <QUOTE::for> URI reference before.
6046 wakaba 1.7 @@@@XParam:
6047     @@@@@Name: uri
6048     @@@@@enDesc:
6049     The URI reference of the resource attempted to define.
6050     @@@@enMufDef:
6051     Resource <%p (name => {<Q::DIS:uri>});> is already defined
6052 wakaba 1.5 @@@XSubTypeDef:
6053     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
6054     @@@@enDesc:
6055     An element has occured where it is not allowed.
6056     @@@@enMufDef:
6057     Module <%p (name => {<Q::DIS:uri>});>:
6058     Element of type <%p (name => {<Q::DIS:elementType>});>
6059     is not allowed here
6060     @@@@XSourceNodeParam:
6061     @@@@XParam:
6062     @@@@@QName: elementType
6063     @@@@@enDesc:
6064     The expanded element type name of the element.
6065     @@@@XParam:
6066     @@@@@QName: uri
6067     @@@@@enDesc:
6068     The URI reference of the module.
6069 wakaba 1.7 @@@XSubTypeDef:
6070     @@@@QName: NO_REQUIRED_ATTR_ERR
6071     @@@@enDesc:
6072     A required attribute is not specified.
6073     @@@@XSourceNodeParam:
6074     @@@@XParam:
6075     @@@@@QName: elementType
6076     @@@@@enDesc:
6077     The expanded URI reference of the attribute name.
6078     @@@@enMufDef:
6079     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
6080 wakaba 1.8 @@@XSubTypeDef:
6081     @@@@QName: FOR_NOT_DEFINED_ERR
6082     @@@@enDesc:
6083     A <QUOTE::for> is referred but not defined.
6084     @@@@XSourceNodeParam:
6085     @@@@XParam:
6086     @@@@@QName: uri
6087     @@@@@enDesc:
6088     The URI reference of the <QUOTE::for> that is not defined.
6089     @@@@enMufDef:
6090     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
6091     @@@XSubTypeDef:
6092     @@@@QName: RESOURCE_NOT_DEFINED_ERR
6093     @@@@enDesc:
6094 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
6095     or the resource referred does not have the type expected.
6096 wakaba 1.8 @@@@XSourceNodeParam:
6097     @@@@XParam:
6098     @@@@@QName: uri
6099     @@@@@enDesc:
6100     The URI reference of the resource that is not defined.
6101 wakaba 1.13 @@@@XParam:
6102     @@@@@QName: elementType
6103     @@@@@enDesc:
6104     <QUOTE::dis> element type (either tree element type
6105     or preprocessing element type) of the element
6106     in which a reference to the undefined resource is contained.
6107     @@@@XParam:
6108     @@@@@QName: localName
6109     @@@@@enDesc:
6110     The local name of the undefined resource.
6111     @@@@XParam:
6112     @@@@QName: sourceCode
6113     @@@@enDesc:
6114     Source code fragment that referres this resource.
6115     @@@@XParam:
6116     @@@@@QName:expectedType
6117     @@@@@enDesc:
6118     Expected resource type.
6119 wakaba 1.8 @@@@enMufDef:
6120 wakaba 1.14 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": });
6121 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
6122     suffix => {>});%p (name => {<Q::DIS:localName>},
6123     prefix => { "}, suffix => {"}); is not defined or wrong type%p
6124     (name => {<Q::DIS:expectedType>}, prefix => { (<},
6125     suffix => {> is expected)});
6126     @@@XSubTypeDef:
6127     @@@@QName: NO_SOURCE_NODE_ERR
6128     @@@@enDesc:
6129     A resource does not have associated node in the source tree.
6130     @@@@XSourceNodeParam:
6131     @@@@XParam:
6132     @@@@@QName:uri
6133     @@@@@enDesc:
6134     The URI reference of the resource.
6135 wakaba 1.8 @@@XSubTypeDef:
6136     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
6137     @@@@enDesc:
6138     A reserved Perl method name is used.
6139     @@@@XParam:
6140     @@@@@QName:uri
6141     @@@@@enDesc:
6142     The URI reference of the method resource.
6143     @@@@XSourceNodeParam:
6144     @@@@XParam:
6145     @@@@@QName: generatedName
6146     @@@@@enDesc:
6147     A reserved method name.
6148     @@@XSubTypeDef:
6149     @@@@QName: NO_DIS_TYPE_ERR
6150     @@@@enDesc:
6151     <Q::dis:Type> attribute is not found.
6152     @@@@XSourceNodeParam:
6153 wakaba 1.12 @@@XSubTypeDef:
6154     @@@@QName: NO_METHOD_RETURN_ERR
6155     @@@@enDesc:
6156     A <Q::DISLang:Method> resource does not have any
6157     <Q::DISLang:MethodReturn> child.
6158     @@@@XSourceNodeParam:
6159     @@@XSubTypeDef:
6160     @@@@QName: NO_ATTR_GET_ERR
6161     @@@@enDesc:
6162     A <Q::DISLang:Attribute> resource does not have any
6163     <Q::DISLang:AttributeGet> child.
6164     @@@@XSourceNodeParam:
6165 wakaba 1.13 @@@XSubTypeDef:
6166     @@@@QName:INTERFACE_CLASS_METHOD_ERR
6167     @@@@enDesc:
6168     An attempt is made to call a static (class) method
6169     from an interface.
6170     @@@@XSourceNodeParam:
6171     @@@@XParam:
6172     @@@@@QName:uri
6173     @@@@@enDesc:
6174     The URI reference of the interface.
6175     @@@@XParam:
6176     @@@@@QName:sourceCode
6177     @@@@@enDesc:
6178     Source code fragment that calls a class method.
6179     @@@@XParam:
6180     @@@@@QName:elementType
6181     @@@@@enDesc:
6182     The element type URI reference of the element
6183     that calls a method.
6184     @@@XSubTypeDef:
6185     @@@@QName: BROKEN_PARAM_SPEC_ERR
6186     @@@@enDesc:
6187     A parameter specification is broken.
6188     @@@@XParam:
6189     @@@@@QName: sourceCode
6190     @@@@@enDesc:
6191     Source code fragment that contains the broken parameter
6192     specification.
6193     @@@@XSourceNodeParam:
6194 wakaba 1.15 @@@@enMufDef:
6195     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
6196     suffix => {": });Broken parameter specification
6197 wakaba 1.13 @@@XSubTypeDef:
6198     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
6199     @@@@enDesc:
6200     A preprocessing instruction does not have its element
6201     type.
6202     @@@@XSourceNodeParam:
6203     @@@@XParam:
6204     @@@@@QName:sourceCode
6205     @@@@@enDesc:
6206     Source code fragment.
6207 wakaba 1.16 @@@@enMufDef:
6208     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
6209     suffix => {": });Element type name is not specified
6210 wakaba 1.13 @@@XSubTypeDef:
6211 wakaba 1.15 @@@@QName: NO_PERL_PACKAGE_NAME_ERR
6212 wakaba 1.13 @@@@enDesc:
6213 wakaba 1.15 No Perl package name is defined for the resource referred.
6214 wakaba 1.13 @@@@XSourceNodeParam:
6215     @@@@XParam:
6216 wakaba 1.15 @@@@@QName:sourceCode
6217 wakaba 1.13 @@@@@enDesc:
6218     Source code fragment.
6219     @@@@XParam:
6220 wakaba 1.15 @@@@@QName:uri
6221     @@@@@enDesc:
6222     THe URI reference of the resource referred.
6223     @@@@XParam:
6224     @@@@@QName:elementType
6225     @@@@@enDesc:
6226     The element type of Perl preprocessing instruction
6227     in which the resource is referred.
6228     @@@@enMufDef:
6229     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
6230     package name is not defined
6231     @@@XSubTypeDef:
6232     @@@@QName: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
6233     @@@@enDesc:
6234     An exception type specification is required.
6235     @@@@XSourceNodeParam:
6236     @@@@XSourceCodeParam:
6237     @@@@XParam:
6238     @@@@@QName:elementType
6239     @@@@@enDesc:
6240     The element type of the preprocessing instruction.
6241     @@@XSubTypeDef:
6242     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
6243     @@@@enDesc:
6244     A code name specification is required.
6245     @@@@XSourceNodeParam:
6246     @@@@XSourceCodeParam:
6247     @@@@XParam:
6248 wakaba 1.13 @@@@@QName:elementType
6249     @@@@@enDesc:
6250 wakaba 1.15 The element type of the preprocessing instruction.
6251 wakaba 1.13 @@@XSubTypeDef:
6252     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
6253     @@@@enDesc:
6254 wakaba 1.15 The specified resource does not have its Perl definition.
6255 wakaba 1.13 @@@@XSourceNodeParam:
6256 wakaba 1.15 @@@@XSourceCodeParam:
6257 wakaba 1.13 @@@@XParam:
6258 wakaba 1.15 @@@@@QName:elementType
6259     @@@@@enDesc:
6260     The element type of the preprocessing instruction.
6261     @@@@XParam:
6262     @@@@@QName:uri
6263 wakaba 1.13 @@@@@enDesc:
6264 wakaba 1.15 The URI reference of the resource referred.
6265 wakaba 1.13 @@@@XParam:
6266     @@@@@QName:localName
6267     @@@@@enDesc:
6268     The local name of the resource referred.
6269 wakaba 1.15 @@@XSubTypeDef:
6270     @@@@QName: PERL_PREPROCESS_NO_METHOD_ERR
6271     @@@@enDesc:
6272     A preprocessing instruction which is only allowed in
6273     method definitions is used in a code which is not a method.
6274     @@@@XSourceNodeParam:
6275     @@@@XSourceCodeParam:
6276 wakaba 1.13 @@@@XParam:
6277 wakaba 1.15 @@@@@QName:elementType
6278 wakaba 1.13 @@@@@enDesc:
6279 wakaba 1.15 The element type of the preprocessing instruction.
6280 wakaba 1.14 @@@XSubTypeDef:
6281 wakaba 1.15 @@@@QName: PERL_PREPROCESS_NO_FOR_ERR
6282 wakaba 1.14 @@@@enDesc:
6283 wakaba 1.15 A <QUOTE::for> specification is required.
6284 wakaba 1.14 @@@@XSourceNodeParam:
6285 wakaba 1.15 @@@@XSourceCodeParam:
6286 wakaba 1.14 @@@@XParam:
6287 wakaba 1.15 @@@@@QName:elementType
6288 wakaba 1.14 @@@@@enDesc:
6289 wakaba 1.15 The element type of the preprocessing instruction.
6290     @@@XSubTypeDef:
6291     @@@@QName: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
6292     @@@@enDesc:
6293     An assertion type specification is required.
6294     @@@@XSourceNodeParam:
6295     @@@@XSourceCodeParam:
6296 wakaba 1.14 @@@@XParam:
6297 wakaba 1.15 @@@@@QName:elementType
6298 wakaba 1.14 @@@@@enDesc:
6299 wakaba 1.15 The element type of the preprocessing instruction.
6300     @@@XSubTypeDef:
6301     @@@@QName: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
6302     @@@@enDesc:
6303     A preprocessing instruction block occurred with
6304     element type which does not allow it.
6305     @@@@XSourceNodeParam:
6306     @@@@XSourceCodeParam:
6307 wakaba 1.14 @@@@XParam:
6308     @@@@@QName:elementType
6309     @@@@@enDesc:
6310 wakaba 1.15 The element type of the preprocessing instruction.
6311    
6312 wakaba 1.4 ##DISException
6313 wakaba 1.13
6314     XParamDef:
6315     @QName:expectedType
6316     @Type: ResourceURI
6317     @enDesc:
6318     Expected resource type URI reference.
6319    
6320     XParamDef:
6321     @QName: sourceCode
6322     @Type:
6323     DISLang:String::ManakaiDOM:all
6324     @enDesc:
6325     The source code fragment in which an error occurred.
6326 wakaba 1.5
6327     XParamDef:
6328     @QName: elementType
6329     @Type: ResourceURI
6330     @enDesc:
6331     The name of the element type.
6332    
6333     XParamDef:
6334     @QName: uri
6335     @Type: ResourceURI
6336     @enDesc:
6337     The name of the resource, composed from <Q::namespaceURI>,
6338     <Q::localName> and <Q::for>.
6339    
6340     XParamDef:
6341     @QName: localName
6342     @Type:
6343     DISCore:LocalName
6344     @enDesc:
6345     The local name of the resource, unique in <Q::namespaceURI> namespace.
6346    
6347     XParamDef:
6348     @QName: namespaceURI
6349     @Type: AnyURI
6350     @enDesc:
6351     The namespace URI reference of the resource name.
6352    
6353     XParamDef:
6354     @QName: for
6355     @Type: ForURI
6356     @enDesc:
6357     The <QUOTE::for> URI reference of the resource.
6358    
6359     ElementTypeBinding:
6360     @Name: XSourceNodeParam
6361     @ElementType:
6362     ManakaiDOM:exceptionOrWarningParameter
6363     @ShadowContent:
6364     @@QName: sourceNode
6365     @@Description:
6366     @@@lang:en
6367     @@@@:
6368     The node in which an error has occurred.
6369 wakaba 1.15
6370     ElementTypeBinding:
6371     @Name: XSourceCodeParam
6372     @ElementType:
6373     ManakaiDOM:exceptionOrWarningParameter
6374     @ShadowContent:
6375     @@QName: sourceCode
6376     @@Description:
6377     @@@lang:en
6378     @@@@:
6379     The source code in which an error has occurred.
6380 wakaba 1.4
6381     ClsDef:
6382     @ClsQName: ManakaiDISExceptionTarget
6383     @enDesc:
6384     Objects that is able to be the target of an exception.
6385     @IntMethod:
6386     @@Operator:
6387     @@@@:
6388     ManakaiDOM:MUErrorHandler
6389     @@@ContentType:
6390     dis:TypeQName
6391     @@Description:
6392     @@@lang:en
6393     @@@@:
6394     This method is a generic error handler; all manakai exceptions
6395     and warnings associated to an object are once reported to this method
6396     and then delivered to appropriate entities.
6397     \
6398     If the error is an exception (such as <X::DOMCore:DOMException> or
6399     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
6400     simply thrown. If the error is only a warning, it is reported
6401     via the <IF::DOMCore:DOMError> interface.
6402     \
6403     See <PerlModule::Message::Util::Error> documentation for more
6404     information on the error reporting mechanism.
6405     \
6406     {NOTE:: This kind of methods are named as <Perl::___report_error>
6407     in the convention of <PerlModule::Message::Util::Error>.
6408     \
6409     }
6410     @@Param:
6411     @@@Name:err
6412     @@@Type:
6413     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
6414     @@@Description:
6415     @@@@lang:en
6416     @@@@@:
6417     An exception object that describes what kind of error it is
6418     and how it should be recovered.
6419     \
6420     {NOTE:: Exception objects in manakai implementation
6421     inherit the class <PerlModule::Message::Util::Error>,
6422     that in turn inherits <PerlModule::Error>.
6423     \
6424     }
6425     @@Return:
6426     @@@PerlDef:
6427     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
6428     ::ManakaiDOM:Perl>)) {
6429     $err->throw;
6430     } else {
6431     \## TODO: Implement warning reporting
6432     warn $err->stringify;
6433     }
6434     ##DISExceptionTarget
6435    
6436     ForDef:
6437     @QName:
6438     DIS:ForIF
6439     ForDef:
6440     @QName:
6441     DIS:ForClass
6442    
6443     ElementTypeBinding:
6444     @Name: IFClsDef
6445     @ElementType:
6446     dis:ResourceDef
6447     @ShadowContent:
6448     @@rdf:type:
6449     @@@@:
6450     dis:MultipleResource
6451     @@@ForCheck: !ForClass !ForIF
6452     @@rdf:type:
6453     @@@@:
6454     ManakaiDOM:IF
6455     @@@ForCheck: ForIF
6456     @@rdf:type:
6457     @@@@:
6458     ManakaiDOM:Class
6459     @@@ForCheck: ForClass
6460     @@resourceFor: ForIF
6461     @@resourceFor:
6462     @@@@: ForClass
6463     @@@ForCheck: ForLatest
6464     @@DOMMain:implementFeature:
6465     @@@@:CoreFeature10
6466     @@@ForCheck: ForClass
6467     @@ForCheck:
6468     ManakaiDOM:Perl
6469 wakaba 1.3
6470     ElementTypeBinding:
6471     @Name: ClsDef
6472     @ElementType:
6473     dis:ResourceDef
6474     @ShadowContent:
6475     @@rdf:type:
6476     ManakaiDOM:Class
6477     @@AliasFor:
6478     @@@@:
6479 wakaba 1.11 ::DIS:ForLatest
6480 wakaba 1.3 @@@For:
6481 wakaba 1.11 !=DIS:ForLatest
6482 wakaba 1.3 @@ForCheck:
6483     ManakaiDOM:Perl
6484     @@DOMMain:implementFeature: CoreFeature10
6485    
6486     ElementTypeBinding:
6487     @Name: ExceptionDef
6488     @ElementType:
6489     dis:ResourceDef
6490     @ShadowContent:
6491     @@rdf:type:
6492     ManakaiDOM:ExceptionClass
6493     @@AliasFor:
6494     @@@@:
6495     ::ForLatest
6496     @@@For:
6497     !=ForLatest
6498     @@ForCheck:
6499     ManakaiDOM:Perl
6500     @@DOMMain:implementFeature: CoreFeature10
6501    
6502     ElementTypeBinding:
6503     @Name: ClsQName
6504     @ElementType:
6505     dis:QName
6506    
6507     ElementTypeBinding:
6508     @Name: ClsISA
6509     @ElementType:
6510     dis:ISA
6511    
6512     ElementTypeBinding:
6513     @Name: Method
6514     @ElementType:
6515     dis:ResourceDef
6516     @ShadowContent:
6517     @@rdf:type:
6518     DISLang:Method
6519    
6520     ElementTypeBinding:
6521     @Name: IntMethod
6522     @ElementType:
6523     dis:ResourceDef
6524     @ShadowContent:
6525     @@rdf:type:
6526     DISLang:Method
6527     @@ManakaiDOM:isForInternal:1
6528    
6529     ElementTypeBinding:
6530     @Name: Attr
6531     @ElementType:
6532     dis:ResourceDef
6533     @ShadowContent:
6534     @@rdf:type:
6535     DISLang:Attribute
6536    
6537     ElementTypeBinding:
6538     @Name: Return
6539     @ElementType:
6540     dis:ResourceDef
6541     @ShadowContent:
6542     @@rdf:type:
6543     DISLang:MethodReturn
6544    
6545     ElementTypeBinding:
6546     @Name: Get
6547     @ElementType:
6548     dis:ResourceDef
6549     @ShadowContent:
6550     @@rdf:type:
6551     DISLang:AttributeGet
6552    
6553     ElementTypeBinding:
6554     @Name: Set
6555     @ElementType:
6556     dis:ResourceDef
6557     @ShadowContent:
6558     @@rdf:type:
6559     DISLang:AttributeSet
6560    
6561     ElementTypeBinding:
6562     @Name: Param
6563     @ElementType:
6564     dis:ResourceDef
6565     @ShadowContent:
6566     @@rdf:type:
6567     DISLang:MethodParameter
6568    
6569     ElementTypeBinding:
6570     @Name: PerlDef
6571     @ElementType:
6572     dis:Def
6573     @ShadowContent:
6574     @@ContentType:
6575     lang:Perl
6576    
6577     ElementTypeBinding:
6578     @Name: disDef
6579     @ElementType:
6580     dis:Def
6581     @ShadowContent:
6582     @@ContentType:
6583     lang:dis
6584    
6585     ElementTypeBinding:
6586     @Name: InCase
6587     @ElementType:
6588     dis:ResourceDef
6589     @ShadowContent:
6590     @@rdf:type:
6591     ManakaiDOM:InCase
6592    
6593     ElementTypeBinding:
6594     @Name: nullCase
6595     @ElementType:
6596     dis:ResourceDef
6597     @ShadowContent:
6598     @@rdf:type:
6599     ManakaiDOM:InCase
6600     @@Value:
6601     @@@is-null:1
6602    
6603     ElementTypeBinding:
6604     @Name: TrueCase
6605     @ElementType:
6606     dis:ResourceDef
6607     @ShadowContent:
6608     @@rdf:type:
6609     ManakaiDOM:InCase
6610     @@Value:true
6611     @@Type:
6612     DOMMain:boolean
6613    
6614    
6615     ElementTypeBinding:
6616     @Name: FalseCase
6617     @ElementType:
6618     dis:ResourceDef
6619     @ShadowContent:
6620     @@rdf:type:
6621     ManakaiDOM:InCase
6622     @@Value:false
6623     @@Type:
6624     DOMMain:boolean
6625    
6626     ElementTypeBinding:
6627     @Name: enDesc
6628     @ElementType:
6629     dis:Description
6630     @ShadowContent:
6631     @@lang:en
6632    
6633     ElementTypeBinding:
6634     @Name: PropDef
6635     @ElementType:
6636     dis:ResourceDef
6637     @ShadowContent:
6638     @@rdf:type:
6639     rdf:Property
6640     @@AliasFor:
6641     @@@@:
6642     ::ManakaiDOM:all
6643     @@@For:
6644     !=ManakaiDOM:all
6645    
6646     ElementTypeBinding:
6647     @Name: MethodRedef
6648     @ElementType:
6649     dis:ResourceDef
6650     @ShadowContent:
6651     @@rdf:type:
6652     DISLang:Method
6653     @@ManakaiDOM:isRedefining:1
6654    
6655     ElementTypeBinding:
6656     @Name: NamedParam
6657     @ElementType:
6658     dis:ResourceDef
6659     @ShadowContent:
6660     @@rdf:type:
6661     DISLang:MethodParameter
6662     @@DISPerl:isNamedParameter:1
6663    
6664     ElementTypeBinding:
6665     @Name: NodeParam
6666     @ElementType:
6667     dis:ResourceDef
6668     @ShadowContent:
6669     @@rdf:type:
6670     DISLang:MethodParameter
6671     @@DISPerl:isNamedParameter:1
6672     @@Name: node
6673     @@Type: ManakaiDISNode
6674     @@Description:
6675     @@@lang:en
6676     @@@@:
6677     The node in which the name has occurred. It is intended
6678     to be reported when an exception had been raised.
6679     @@ResourceDef:
6680     @@@rdf:type:
6681     ManakaiDOM:InCase
6682     @@@Value:
6683     @@@@is-null:1
6684     @@@Description:
6685     @@@@lang:en
6686     @@@@@:
6687     The source of the name is not a node.
6688    
6689     ElementTypeBinding:
6690     @Name: ForParam
6691     @ElementType:
6692     dis:ResourceDef
6693     @ShadowContent:
6694     @@rdf:type:
6695     DISLang:MethodParameter
6696     @@DISPerl:isNamedParameter:1
6697     @@Name: forArg
6698     @@Type: ForURI
6699     @@Description:
6700     @@@lang:en
6701     @@@@:
6702     The <QUOTE::for> URI reference.
6703     @@ResourceDef:
6704     @@@rdf:type:
6705     ManakaiDOM:InCase
6706     @@@Value:
6707     @@@@is-null:1
6708     @@@Description:
6709     @@@@lang:en
6710     @@@@@:
6711     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
6712    
6713     ElementTypeBinding:
6714     @Name: ForpParam
6715     @ElementType:
6716     dis:ResourceDef
6717     @ShadowContent:
6718     @@rdf:type:
6719     DISLang:MethodParameter
6720     @@DISPerl:isNamedParameter:1
6721     @@Name: forpArg
6722     @@Type: ForURIList
6723     @@Description:
6724     @@@lang:en
6725     @@@@:
6726     An array reference containing additional <QUOTE::for>
6727     constraints (<QUOTE::For+> list).
6728     @@ResourceDef:
6729     @@@rdf:type:
6730     ManakaiDOM:InCase
6731     @@@Value:
6732     @@@@is-null:1
6733     @@@Description:
6734     @@@@lang:en
6735     @@@@@:
6736     Equivalent to the empty array reference.
6737    
6738     ElementTypeBinding:
6739     @Name: MediaTypeParam
6740     @ElementType:
6741     dis:ResourceDef
6742     @ShadowContent:
6743     @@rdf:type:
6744     DISLang:MethodParameter
6745     @@DISPerl:isNamedParameter:1
6746     @@Name: mediaType
6747     @@Type: MediaTypeURI
6748     @@Description:
6749     @@@lang:en
6750     @@@@:
6751     The URI reference identifying a media type.
6752     @@ResourceDef:
6753     @@@rdf:type:
6754     ManakaiDOM:InCase
6755     @@@Value:
6756     @@@@is-null:1
6757     @@@Description:
6758     @@@@lang:en
6759     @@@@@:
6760     No media type specified.
6761    
6762     ElementTypeBinding:
6763     @Name: MediaTypeDefaultParam
6764     @ElementType:
6765     dis:ResourceDef
6766     @ShadowContent:
6767     @@rdf:type:
6768     DISLang:MethodParameter
6769     @@DISPerl:isNamedParameter:1
6770     @@Name: defaultMediaType
6771     @@Type: MediaTypeURI
6772     @@Description:
6773     @@@lang:en
6774     @@@@:
6775     The default media type, i.e. the type used when no explicit
6776     specification is not found in the source tree.
6777     @@ResourceDef:
6778     @@@rdf:type:
6779     ManakaiDOM:InCase
6780     @@@Value:
6781     @@@@is-null:1
6782     @@@Description:
6783     @@@@lang:en
6784     @@@@@:
6785     Defaulted to <Q::DOMMain:any>.
6786    
6787     ElementTypeBinding:
6788     @Name: RaiseException
6789     @ElementType:
6790     ManakaiDOM:raises
6791    
6792     ElementTypeBinding:
6793     @Name: UndeclaredPrefixException
6794     @ElementType:
6795     ManakaiDOM:raises
6796     @ShadowContent:
6797     @@@: UNDECLARED_NS_PREFIX_ERR
6798     @@Description:
6799     @@@lang:en
6800     @@@@:
6801     The implementation has encounted an undeclared namespace prefix.
6802    
6803     ElementTypeBinding:
6804     @Name: NoDBException
6805     @ElementType:
6806     ManakaiDOM:raises
6807     @ShadowContent:
6808     @@@: NO_DB_ASSOCIATED_ERR
6809     @@Description:
6810     @@@lang:en
6811     @@@@:
6812     No <QUOTE::dis> database is associated to this document.
6813    
6814     ElementTypeBinding:
6815     @Name: XConstGroupDef
6816     @ElementType:
6817     dis:ResourceDef
6818     @ShadowContent:
6819     @@rdf:type:
6820     ManakaiDOM:ConstGroup
6821     @@Type:
6822     DOMMain:unsigned-short::ManakaiDOM:all
6823     @@rdfs:subClassOf:
6824     DOMMain:unsigned-short::ManakaiDOM:all
6825    
6826     ElementTypeBinding:
6827     @Name: XConstDef
6828     @ElementType:
6829     dis:ResourceDef
6830     @ShadowContent:
6831     @@rdf:type:
6832     ManakaiDOM:Const
6833    
6834     ElementTypeBinding:
6835     @Name: XSubTypeDef
6836     @ElementType:
6837     dis:ResourceDef
6838     @ShadowContent:
6839     @@rdf:type:
6840     ManakaiDOM:ExceptionOrWarningSubType
6841    
6842     ElementTypeBinding:
6843     @Name: XParam
6844     @ElementType:
6845     ManakaiDOM:exceptionOrWarningParameter
6846    
6847     ElementTypeBinding:
6848     @Name: XParamDef
6849     @ElementType:
6850     dis:ResourceDef
6851     @ShadowContent:
6852     @@rdf:type:
6853     DOMMain:XWParameter
6854 wakaba 1.12 @@For:
6855     =ManakaiDOM:all
6856 wakaba 1.3
6857     ElementTypeBinding:
6858     @Name: enMufDef
6859     @ElementType:
6860     dis:Def
6861     @ShadowContent:
6862     @@ContentType:
6863     lang:muf
6864     @@lang:en
6865    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24