/[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.13 - (hide annotations) (download)
Wed Mar 16 09:08:13 2005 UTC (20 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.12: +777 -8 lines
Perl inline preprocessing implemented (but not tested whether it does work or not)

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     This module provides an object model for <QUITE::dis> document format.
15    
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.13 $Date: 2005/03/06 11:12:42 $
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.9 my $fors = [split /\s+/, $ce-><AG::swcfg21:SWCFGNode
871     ::swcfg21:ForLatest.value>];
872     FCs: for my $f (@$fors) {
873 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
874     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
875 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
876     -><AG::ManakaiDISDocument.disDatabase>
877     -><M::ManakaiDISDatabase.getFor> ($uri);
878     $for-><AG::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     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
887 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
888     -><AG::ManakaiDISDocument.disDatabase>
889     -><M::ManakaiDISDatabase.getFor> ($uri);
890     $for-><AG::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     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
899 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
900     -><AG::ManakaiDISDocument.disDatabase>
901     -><M::ManakaiDISDatabase.getFor> ($uri);
902     $for-><AG::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.9 my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($f);
912     my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
913     -><AG::ManakaiDISDocument.disDatabase>
914     -><M::ManakaiDISDatabase.getFor> ($uri);
915     $for-><AG::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.9 my $fors = [split /\s+/, $ce-><AG::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     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
940 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
941     -><AG::ManakaiDISDocument.disDatabase>
942     -><M::ManakaiDISDatabase.getFor> ($uri);
943     $for-><AG::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     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
950 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
951     -><AG::ManakaiDISDocument.disDatabase>
952     -><M::ManakaiDISDatabase.getFor> ($uri);
953     $for-><AG::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     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
960 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
961     -><AG::ManakaiDISDocument.disDatabase>
962     -><M::ManakaiDISDatabase.getFor> ($uri);
963     $for-><AG::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.9 my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($f);
970     my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
971     -><AG::ManakaiDISDocument.disDatabase>
972     -><M::ManakaiDISDatabase.getFor> ($uri);
973     $for-><AG::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.9 my ($prefix, $lname) = split /:/, $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.9 my ($prefix, $lname) = split /:/, $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     my ($typeq, $forq) = split /\s*::\s*/, $tfqnames, 2;
1269     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     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1421     if (defined $v and not ref $v eq 'ARRAY') {
1422     $r = $self-><AG::ManakaiDISElement.qnameToURI> ($v, node => $self);
1423     } 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     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1446     if (defined $v and not ref $v eq 'ARRAY') {
1447     my ($n, $v) = split /:/, $v, 2;
1448     $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     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1472     if (defined $v and not ref $v eq 'ARRAY') {
1473     my ($p, $v) = split /:/, $v, 2;
1474     $r = $self-><AG::ManakaiDISElement.prefixToURI>
1475     (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     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1528 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1529     __DEEP{
1530 wakaba 1.6 $r = $self-><AG::ManakaiDISElement.tfqnamesToURI>
1531     ($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     my $et = $self-><M::swcfg21:SWCFGElement::swcfg21:ForLatest
1562     .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     $r = $df-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1698     } 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     unless ($mod-><M::ManakaiDISModuleDefinition.isDefined>) {
2086     ## -- 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     next unless $el-><M::swcfg21:SWCFGElement::swcfg21:ForLatest
2110     .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     my $mqn = $rm-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2147     .getAttributeNS> (<Q::dis:>, 'QName');
2148     if ($mqn) {
2149     my $mqv = $mqn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2150     .value>;
2151     my $mqp = $mqn-><AG::ManakaiDISElement.qnameToPair>
2152     ($mqv, node => $mqn);
2153     ($nuri, $ln) = @$mqp;
2154     } else {
2155     my $mn = $rm-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2156     .getAttributeNS> (<Q::dis:>, 'Name');
2157     if ($mn) {
2158     $nuri = $mod->{namespaceURI};
2159     $ln = $mn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2160     } else {
2161     $nuri = $mod->{namespaceURI};
2162     $ln = $mod->{localName};
2163     }
2164     }
2165     my $wfn = $rm-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2166     .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     my $et = $el-><M::swcfg21:SWCFGElement::swcfg21:ForLatest
2203     .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     unless ($dn and defined $dn-><AG::swcfg21:SWCFGNode
2226     ::swcfg21:ForLatest.value>) {
2227     __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     unless ($for-><M::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.7 $sfor-><M::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.5 if ($res-><M::ManakaiDISForDefinition.isDefined>) {
2372     __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.11 my $ln = $n_node-><AG::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.6 $res->{localName} = $n_node-><AG::swcfg21:SWCFGNode
2402     ::swcfg21:ForLatest.value>;
2403 wakaba 1.5 $res->{<Q::isAnon>} = true;
2404     } else { ## Root local name resource
2405 wakaba 1.7 my $ln = $n_node-><AG::swcfg21:SWCFGNode
2406     ::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.6 if ($res-><M::ManakaiDISForDefinition.isDefined>) {
2414     __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     $canon_res-><M::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     $type-><M::ManakaiDISResourceDefinition.isReferred> ($ce);
2485     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.7 my $for_uri = $pe-><M::ManakaiDISElement.qnameValueURI>;
2531     my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
2532     $for-><M::ManakaiDISForDefinition.isReferred> ($pe);
2533     $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.2 ##DISDatabase
2603    
2604 wakaba 1.8 PropDef:
2605 wakaba 1.9 @QName: resource
2606     @enDesc:
2607     Resources defined in a module.
2608     @rdfs:range: ManakaiDISResourceDefinition
2609     @rdfs:domain: ManakaiDISModuleDefinition
2610    
2611     PropDef:
2612 wakaba 1.8 @QName:
2613     dis2pm:parentResource
2614     @enDesc:
2615     Static parent resource. No parent for root resources.
2616    
2617     PropDef:
2618     @QName: dynamicParentResource
2619     @enDesc:
2620     Dynamic parent resource. No parent for root resources.
2621    
2622 wakaba 1.11 PropDef:
2623     @QName: childResource
2624     @enDesc:
2625     Static child resources.
2626    
2627     PropDef:
2628     @QName: dynamicChildResource
2629     @enDesc:
2630     Dynamic child resources.
2631    
2632 wakaba 1.5 ElementTypeBinding:
2633     @Name: ForDefDupException
2634     @ElementType:
2635     ManakaiDOM:raises
2636     @ShadowContent:
2637     @@@: FOR_ALREADY_DEFINED_ERR
2638     @@Description:
2639     @@@lang:en
2640     @@@@:
2641     The <QUOTE::for> is already defined elsewhere.
2642    
2643     ElementTypeBinding:
2644     @Name: ForDefNoQNameException
2645     @ElementType:
2646     ManakaiDOM:raises
2647     @ShadowContent:
2648     @@@: NO_FOR_QNAME_ERR
2649     @@Description:
2650     @@@lang:en
2651     @@@@:
2652     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
2653    
2654     ElementTypeBinding:
2655     @Name: ResDefDupException
2656     @ElementType:
2657     ManakaiDOM:raises
2658     @ShadowContent:
2659     @@@: RESOURCE_ALREADY_DEFINED_ERR
2660     @@Description:
2661     @@@lang:en
2662     @@@@:
2663     The <QUOTE::dis> resource is already defined elsewhere.
2664    
2665     ElementTypeBinding:
2666     @Name: ElementNotAllowedException
2667     @ElementType:
2668     ManakaiDOM:raises
2669     @ShadowContent:
2670     @@@: ELEMENT_NOT_ALLOWED_ERR
2671     @@Description:
2672     @@@lang:en
2673     @@@@:
2674     An element has found where it is not allowed.
2675    
2676 wakaba 1.4 IFClsDef:
2677     @QName:
2678     @@@: DISModuleResolver
2679     @@ForCheck: ForIF
2680     @QName:
2681     @@@: ManakaiDISModuleResolver
2682     @@ForCheck: ForClass
2683     @enDesc:
2684     Objects implementing <IF::DISModuleResolver> interface
2685     are used to convert module name into <QUOTE::dis> document object.
2686     \
2687     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
2688     as a method parameter where <IF::DISModuleResolver> is
2689     expected.
2690     \
2691     }
2692     @Method:
2693     @@Name: uriToDocument
2694     @@enDesc:
2695     Returns a <QUOTE::dis> document from module name information.
2696     @@Param:
2697     @@@Name: disDB
2698     @@@Type: ManakaiDISDatabase
2699     @@@enDesc:
2700     The <QUOTE::dis> database.
2701     @@Param:
2702     @@@Name: moduleURI
2703     @@@Type: ModuleURI
2704     @@@enDesc:
2705     The URI reference of the module.
2706     \
2707     {NOTE:: This parameter is redundant, since it can be
2708     composed from other three parameters.
2709     \
2710     }
2711     @@Param:
2712     @@@Name: moduleNamespaceURI
2713     @@@Type: AnyURI
2714     @@@enDesc:
2715     The namespace URI of the module name.
2716     @@Param:
2717     @@@Name: moduleLocalName
2718     @@@Type:
2719     DISCore:LocalName
2720     @@@enDesc:
2721     The local name of the module name.
2722     @@Param:
2723     @@@Name: moduleFor
2724     @@@Type: ForURI
2725     @@@enDesc:
2726     The <QUOTE::for> URI reference for which the module is defined.
2727     @@Return:
2728     @@@Type: ManakaiDISDocument
2729     @@@enDesc:
2730     The <QUOTE::dis> document. It don't have to be a newly created
2731     object.
2732     @@@nullCase:
2733     @@@@enDesc:
2734     The method is unable to resolve the reference.
2735     @@@PerlDef:
2736     $r = $self->(@_);
2737     @ManakaiDOM:inputNormalizer:
2738     @@ContentType:
2739     lang:Perl
2740     @@@:
2741     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
2742     if ref $INPUT eq 'CODE';
2743     @@ImplNote:
2744     @@@lang:en
2745     @@@@:
2746     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
2747     ##DISModuleResolver
2748    
2749 wakaba 1.3 PropDef:
2750     @QName: sourceFile
2751     @enDesc:
2752     Source <QUOTE::dis> documents.
2753     @rdfs:domain: ManakaiDISDatabase
2754     @rdfs:range: ManakaiDISDocument
2755    
2756 wakaba 1.2 ClsDef:
2757     @ClsQName: ManakaiDISModuleDefinition
2758     @enDesc:
2759     <QUOTE::dis> module definitions.
2760     @ClsISA: ManakaiDISPropertyAccessor
2761 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2762 wakaba 1.2
2763     @Attr:
2764     @@Name: uri
2765     @@Type: ModuleURI
2766     @@Description:
2767     @@@lang:en
2768     @@@@:
2769     The URI reference of this <QUOTE::dis> module.
2770     @@Get:
2771     @@@PerlDef:
2772     $r = $self->{uri};
2773    
2774     @Attr:
2775     @@Name: nameURI
2776     @@Type: NameURI
2777     @@enDesc:
2778     The URI reference of this module, without
2779     <QUOTE::for> identifier.
2780     @@Get:
2781 wakaba 1.3 @@@PerlDef:
2782 wakaba 1.4 $r = $self->{nameURI};
2783 wakaba 1.2
2784     @Attr:
2785     @@Name: localName
2786     @@enDesc:
2787     The local name of this module.
2788     @@Type:
2789 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
2790 wakaba 1.2 @@Get:
2791     @@@PerlDef:
2792     $r = $self->{localName};
2793    
2794     @Attr:
2795     @@Name: namespaceURI
2796     @@Type: AnyURI
2797     @@enDesc:
2798     The namespace URI of the name of this resource.
2799     @@Get:
2800     @@@PerlDef:
2801     $r = $self->{namespaceURI};
2802    
2803     @Attr:
2804     @@Name: forURI
2805     @@Type: ForURI
2806     @@enDesc:
2807     The <QUOTE::for> URI reference for which this module is defined.
2808     @@Get:
2809     @@@PerlDef:
2810     $r = $self->{for};
2811    
2812     @Attr:
2813     @@Name: isDefined
2814     @@Description:
2815     @@@lang:en
2816     @@@@:
2817     Whether this module is defined or not.
2818     @@Type:
2819     DOMMain:boolean
2820     @@Get:
2821     @@@PerlDef:
2822     $r = $self->{<Q::isDefined>};
2823 wakaba 1.8
2824     @Attr:
2825     @@Name: plFullyQualifiedName
2826     @@enDesc:
2827     The fully-qualified Perl class package name.
2828     @@Type:
2829     Perl:package-name::ManakaiDOM:all
2830     @@Get:
2831     @@@NoPerlModuleNameException:
2832     @@@PerlDef:
2833     __DEEP{
2834     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2835     ($self->{namespaceURI});
2836     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2837     __UNDEEP{
2838     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2839     DIS:uri => {$self->{namespaceURI}},
2840     DIS:sourceNode => {$self->{src}},
2841     }__;
2842     }__;
2843     }
2844     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2845     (<Q::dis:AppName>, for_arg => $self->{for},
2846 wakaba 1.10 media_type => <Q::lang:Perl>,
2847     default_media_type => <Q::lang:Perl>);
2848 wakaba 1.8 if ($an) {
2849     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2850     $r =~ s/::$//g;
2851     $r .= '::' . $self->{localName};
2852     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2853     (<Q::ManakaiDOM:moduleSuffix>,
2854     for_arg => $self->{for},
2855     media_type => <Q::lang:Perl>,
2856     default_media_type => <Q::lang:Perl>);
2857     if ($sf) {
2858     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2859     }
2860     } else {
2861 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
2862 wakaba 1.8 }
2863     }__;
2864    
2865     @Attr:
2866     @@Name: plInterfaceName
2867     @@enDesc:
2868     The fully-qualified Perl interface package name.
2869     @@Type:
2870     Perl:package-name::ManakaiDOM:all
2871     @@Get:
2872     @@@NoPerlModuleNameException:
2873     @@@PerlDef:
2874     __DEEP{
2875     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2876     ($self->{namespaceURI});
2877     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2878     __UNDEEP{
2879     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2880     DIS:uri => {$self->{namespaceURI}},
2881     DIS:sourceNode => {$self->{src}},
2882     }__;
2883     }__;
2884     }
2885     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2886     (<Q::dis:AppName>, for_arg => $self->{for},
2887     forp_arg => [<Q::ManakaiDOM:ForIF>],
2888 wakaba 1.10 media_type => <Q::lang:Perl>,
2889     default_media_type => <Q::lang:Perl>);
2890 wakaba 1.8 if ($an) {
2891     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2892     $r =~ s/::$//g;
2893     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2894     (<Q::ManakaiDOM:moduleSuffix>,
2895     for_arg => $self->{for},
2896     forp_arg => [<Q::ManakaiDOM:ForIF>],
2897     media_type => <Q::lang:Perl>,
2898     default_media_type => <Q::lang:Perl>);
2899     if ($sf) {
2900     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2901     }
2902     } else {
2903     $r = $self-><M::ManakaiDISModuleDefinition.plFullyQualifiedName>;
2904     }
2905     }__;
2906 wakaba 1.13
2907     @Method:
2908     @@Name: plAddRequireModule
2909     @@enDesc:
2910     Adds a <QUOTE::dis> module into the list of modules that
2911     defines a Perl module file referred by Perl module file
2912     defined by this module.
2913     @@Param:
2914     @@@Name: moduleArg
2915     @@@Type: ManakaiDISModuleDefinition
2916     @@@enDesc:
2917     A module definition.
2918     @@Return:
2919     @@@RaiseException:
2920     @@@@@: RESOURCE_NOT_DEFINED_ERR
2921     @@@@enDesc:
2922     The module group to which <P::moduleArg> belongs
2923     is not defined.
2924     @@@PerlDef:
2925     __DEEP{
2926     my $pack = $moduleArg-><AG::ManakaiDISModuleDefinition
2927     .plFullyQualifiedName>;
2928     $self->{<Q::DIS:plRequireModule>}->{$pack} = true;
2929     }__;
2930 wakaba 1.2 ##DISModuleDefinition
2931    
2932 wakaba 1.13 PropDef:
2933     @QName: plRequireModule
2934     @enDesc:
2935     A list of Perl package name that this resource is referring.
2936    
2937 wakaba 1.8 ElementTypeBinding:
2938     @Name: NoPerlModuleNameException
2939     @ElementType:
2940     ManakaiDOM:raises
2941     @ShadowContent:
2942     @@@: RESOURCE_NOT_DEFINED_ERR
2943     @@Description:
2944     @@@lang:en
2945     @@@@:
2946     The module group corresponding to the namespace URI
2947     of this module is not defined.
2948    
2949 wakaba 1.2 ClsDef:
2950     @ClsQName: ManakaiDISForDefinition
2951     @Description:
2952     @@lang:en
2953     @@@:
2954     <QUOTE::dis> <QUOTE::for> definitions.
2955 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2956 wakaba 1.2
2957     @Attr:
2958     @@Name: uri
2959     @@Type: ForURI
2960     @@Description:
2961     @@@lang:en
2962     @@@@:
2963     The URI reference of this <QUOTE::for>.
2964     @@Get:
2965     @@@PerlDef:
2966     $r = $self->{uri};
2967 wakaba 1.10
2968     @IntMethod:
2969     @@Operator:
2970     @@@@:eq
2971     @@@ContentType:
2972     lang:Perl
2973     @@enDesc:
2974     Whether two <QUOTE::for> definitions are equal or not.
2975     Two <QUOTE::for> definitions are equal iff one's URI reference
2976     is one of another's URI reference.
2977     \
2978     {NOTE:: Aliases for <QUOTE::for> is not allowed.
2979     \
2980     }
2981     @@ImplNote:
2982     @@@lang:en
2983     @@@@:
2984     In the current implementation, two are equal iff two are
2985     equal as reference.
2986     @@Param:
2987     @@@Name: anotherFor
2988     @@@Type: ManakaiDISForDefinition
2989     @@@enDesc:
2990     Another <QUOTE::for> definition to compare.
2991     @@Return:
2992     @@@Type:
2993     DOMMain:boolean
2994     @@@enDesc:
2995     Whether two resources are equal or not.
2996     @@@PerlDef:
2997     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
2998     $r = $self->{uri} eq $anotherFor->{uri};
2999     } else {
3000     $r = false;
3001     }
3002 wakaba 1.2
3003     @Method:
3004     @@Name: isaURI
3005     @@Description:
3006     @@@lang:en
3007     @@@@:
3008     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
3009     @@Param:
3010     @@@Name: superURI
3011     @@@Type: ForURI
3012     @@@Description:
3013     @@@@lang:en
3014     @@@@@:
3015     Another <QUOTE::for> URI reference to test.
3016     @@Return:
3017     @@@Type:
3018     DOMMain:boolean
3019     @@@TrueCase:
3020     @@@@enDesc:
3021     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
3022     @@@FalseCase:
3023     @@@@enDesc:
3024     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
3025     @@@PerlDef:
3026     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
3027    
3028     @Attr:
3029     @@Name: isDefined
3030     @@Description:
3031     @@@lang:en
3032     @@@@:
3033     Whether this <QUOTE::for> is already defined or not.
3034     @@Type:
3035     DOMMain:boolean
3036     @@Get:
3037     @@@TrueCase:
3038     This <QUOTE::for> is already defined.
3039     @@@FalseCase:
3040     This <QUOTE::for> is not defined.
3041     @@@PerlDef:
3042     $r = $self->{<Q::isDefined>};
3043    
3044     @Attr:
3045     @@Name: isReferred
3046     @@Description:
3047     @@@lang:en
3048     @@@@:
3049     Whether this <QUOTE::for> is referred somewhere or not.
3050 wakaba 1.9 @@Type: ManakaiDISElement
3051 wakaba 1.2 @@Get:
3052     @@@InCase:
3053     @@@@Type:ManakaiDISElement
3054     @@@@enDesc:
3055     This <QUOTE::for> is referred by the element.
3056     @@@nullCase:
3057     This <QUOTE::for> is not referred.
3058     @@@PerlDef:
3059     $r = $self->{<Q::isReferred>};
3060     @@Set:
3061     @@@InCase:
3062     @@@@Type:ManakaiDISElement
3063     @@@@enDesc:
3064     This <QUOTE::for> is referred by the element.
3065     @@@PerlDef:
3066 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3067 wakaba 1.2
3068     @Attr:
3069     @@Name: definingModule
3070     @@Description:
3071     @@@lang:en
3072     @@@@:
3073     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
3074     @@Type: ManakaiDISModuleDefinition
3075     @@Get:
3076     @@@Description:
3077     @@@@lang:en
3078     @@@@@:
3079     The module object.
3080 wakaba 1.3 @@@nullCase:
3081 wakaba 1.2 @@@@Description:
3082     @@@@@lang:en
3083     @@@@@@:
3084     This <QUOTE::for> is not associated to any module.
3085     @@@PerlDef:
3086     $r = $self->{db}
3087     -><M::ManakaiDISDatabase.getResource>
3088     ($self->{<Q::definingModule>})
3089     if defined $self->{<Q::definingModule>};
3090 wakaba 1.5
3091 wakaba 1.2 @Method:
3092 wakaba 1.5 @@Name: addISA
3093 wakaba 1.2 @@enDesc:
3094 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3095     <QUOTE::for>.
3096 wakaba 1.2 @@Param:
3097 wakaba 1.5 @@@Name: superFor
3098     @@@Type: ManakaiDISForDefinition
3099     @@@enDesc:
3100     A <QUOTE::for> definition object.
3101 wakaba 1.2 @@Return:
3102     @@@PerlDef:
3103 wakaba 1.5 my @from = ($self->{uri},
3104     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3105     my @to = ($superFor->{uri},
3106     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3107 wakaba 1.7 __DEEP{
3108     for my $from (@from) {
3109     for my $to (@to) {
3110     $self->{db}-><M::ManakaiDISDatabase.getFor>
3111     ($from)->{isa}->{$to} = true;
3112     $self->{db}-><M::ManakaiDISDatabase.getFor>
3113     ($to)->{revISA}->{$from} = true;
3114     }
3115 wakaba 1.5 }
3116 wakaba 1.7 }__;
3117 wakaba 1.5
3118 wakaba 1.2 ##DISForDefinition
3119    
3120     ClsDef:
3121     @ClsQName: ManakaiDISResourceDefinition
3122     @enDesc:
3123     <QUOTE::dis> resource definitions.
3124     @ClsISA: ManakaiDISPropertyAccessor
3125 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3126 wakaba 1.2
3127     @Attr:
3128     @@Name: uri
3129     @@Type: ResourceURI
3130     @@Description:
3131     @@@lang:en
3132     @@@@:
3133     The URI reference of this <QUOTE::dis> resource.
3134     @@Get:
3135     @@@PerlDef:
3136     $r = $self->{uri};
3137    
3138     @Attr:
3139     @@Name: nameURI
3140     @@Type: NameURI
3141     @@enDesc:
3142     The URI reference of this <QUOTE::dis> resource, without
3143     <QUOTE::for> identifier.
3144     @@Get:
3145     @@@nullCase:
3146     @@@@enDesc:
3147     This resource does not have its name URI reference.
3148 wakaba 1.3 @@@PerlDef:
3149 wakaba 1.4 $r = $self->{nameURI};
3150 wakaba 1.2
3151     @Attr:
3152     @@Name: localName
3153     @@enDesc:
3154     The local name of this resource.
3155     @@Type:
3156 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3157 wakaba 1.2 @@Get:
3158     @@@nullCase:
3159     @@@@enDesc:
3160     This resource does not have its local name.
3161     @@@PerlDef:
3162     $r = $self->{localName};
3163    
3164     @Attr:
3165     @@Name: namespaceURI
3166     @@Type: AnyURI
3167     @@enDesc:
3168     The namespace URI of the name of this resource.
3169     @@Get:
3170     @@@nullCase:
3171     The name of this resource does not have its namespace
3172     or this resource does not have its name.
3173     @@@PerlDef:
3174     $r = $self->{namespaceURI};
3175    
3176     @Attr:
3177     @@Name: isAnonymous
3178     @@enDesc:
3179     Whether this <QUOTE::dis> resource has name or not.
3180     @@Type:
3181     DOMMain:boolean
3182     @@Get:
3183     @@@TrueCase:
3184     This resource does not have any global unique name.
3185     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
3186     @@@FalseCase:
3187     This resource does have its formal name.
3188     <A::ManakaiDISResourceDefinition.uri> is a URI reference
3189     generated from the name and the <QUOTE::for> URI reference
3190     of this resource.
3191     @@@PerlDef:
3192     $r = $self->{<Q::isAnon>};
3193    
3194     @Attr:
3195     @@Name: forURI
3196     @@enDesc:
3197     The <QUOTE::for> URI reference for which this resource is defined.
3198     @@Type:ForURI
3199     @@Get:
3200     @@@PerlDef:
3201     $r = $self->{for};
3202    
3203     @Attr:
3204     @@Name: forpURI
3205     @@enDesc:
3206     The <QUOTE::for+> URI references for which this resource is defined.
3207     @@Type: ForURIList
3208     @@Get:
3209 wakaba 1.3 @@@PerlDef:
3210 wakaba 1.2 $r = $self->{forp};
3211    
3212     @Method:
3213 wakaba 1.7 @@Name: isSubsetOfURI
3214 wakaba 1.2 @@Description:
3215     @@@lang:en
3216     @@@@:
3217     Whether this resource is a subset of another resource or not.
3218     @@Param:
3219     @@@Name: superURI
3220     @@@Type: ResourceURI
3221     @@@Description:
3222     @@@@lang:en
3223     @@@@@:
3224     Another resource URI reference to test.
3225     @@Return:
3226     @@@Type:
3227     DOMMain:boolean
3228     @@@TrueCase:
3229     @@@@enDesc:
3230     <P::superURI> is a super-resource of this resource.
3231     @@@FalseCase:
3232     @@@@enDesc:
3233     <P::superURI> is not a super-resource of this resource.
3234     @@@PerlDef:
3235 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
3236 wakaba 1.2
3237 wakaba 1.7 @Method:
3238     @@Name: addSuperResource
3239     @@enDesc:
3240     Adds a <QUOTE::dis> resource to the list of super-resource
3241     of this <QUOTE::dis> resource.
3242     @@Param:
3243     @@@Name: superRes
3244     @@@Type: ManakaiDISResourceDefinition
3245     @@@enDesc:
3246     A <QUOTE::dis> resource definition object.
3247     @@Return:
3248     @@@PerlDef:
3249     my @from = ($self->{uri},
3250     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
3251     my @to = ($superRes->{uri},
3252     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
3253     __DEEP{
3254     for my $from (@from) {
3255     for my $to (@to) {
3256     $self->{db}-><M::ManakaiDISDatabase.getResource>
3257     ($from)->{subOf}->{$to} = true;
3258     $self->{db}-><M::ManakaiDISDatabase.getResource>
3259     ($to)->{supOf}->{$from} = true;
3260     }
3261     }
3262     }__;
3263    
3264 wakaba 1.2 @Attr:
3265     @@Name: isDefined
3266     @@Description:
3267     @@@lang:en
3268     @@@@:
3269     Whether this resource is already defined or not.
3270     @@Type:
3271     DOMMain:boolean
3272     @@Get:
3273     @@@TrueCase:
3274     This resource is already defined.
3275     @@@FalseCase:
3276     This resource is not defined.
3277     @@@PerlDef:
3278     $r = $self->{<Q::isDefined>};
3279    
3280     @Attr:
3281     @@Name: isReferred
3282     @@Description:
3283     @@@lang:en
3284     @@@@:
3285     Whether this resource is referred or not.
3286 wakaba 1.7 @@Type: ManakaiDISElement
3287 wakaba 1.2 @@Get:
3288 wakaba 1.7 @@@enDesc:
3289 wakaba 1.9 An element that referres this resource.
3290 wakaba 1.2 @@@nullCase:
3291     This resource is not referred.
3292     @@@PerlDef:
3293     $r = $self->{<Q::isReferred>};
3294     @@Set:
3295 wakaba 1.7 @@@enDesc:
3296 wakaba 1.9 An element that referres this resource.
3297 wakaba 1.2 @@@PerlDef:
3298 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3299 wakaba 1.2
3300     @Attr:
3301     @@Name: definingModule
3302     @@Description:
3303     @@@lang:en
3304     @@@@:
3305     The <QUOTE::dis> module in which this resource is defined.
3306 wakaba 1.8 \
3307     {NOTE:: Method name should have been <CODE::ownerModule> or some.
3308     \
3309     }
3310 wakaba 1.2 @@Type: ManakaiDISModuleDefinition
3311     @@Get:
3312     @@@Description:
3313     @@@@lang:en
3314     @@@@@:
3315     The module object.
3316 wakaba 1.3 @@@nullCase:
3317 wakaba 1.2 @@@@Description:
3318     @@@@@lang:en
3319     @@@@@@:
3320     This resource is not associated to any module.
3321     @@@PerlDef:
3322     $r = $self->{db}
3323     -><M::ManakaiDISDatabase.getModule>
3324     ($self->{<Q::definingModule>})
3325     if defined $self->{<Q::definingModule>};
3326     @@Set:
3327     @@@Description:
3328     @@@@lang:en
3329     @@@@@:
3330     The module object to which the <QUOTE::defining module> is set.
3331     @@@PerlDef:
3332     $self->{<Q::defininingModule>}
3333     = $given-><AG::ManakaiDISModuleDefinition.uri>;
3334    
3335 wakaba 1.6 @Method:
3336     @@Name: mergeAsAlias
3337     @@enDesc:
3338     Merges another resource definition as an alias of this resource.
3339     @@Param:
3340     @@@Name: aliasResource
3341     @@@Type: ManakaiDISResourceDefinition
3342     @@@enDesc:
3343     A resource to merge.
3344     \
3345     {NOTE:: After merging all references to <P::aliasResource>
3346     should be discarded.
3347     \
3348     }
3349 wakaba 1.11 @@NodeParam:
3350 wakaba 1.6 @@Return:
3351 wakaba 1.11 @@@RaiseException:
3352     @@@@@:MERGE_ITSELF_ERR
3353     @@@@@@enDesc:
3354     An attempt is made to merge this resource itself.
3355     @@@PerlDef:
3356     if ($self eq $aliasResource) {
3357     __EXCEPTION{MERGE_ITSELF_ERR::
3358     DIS:uri => {$self->{uri}},
3359     DIS:sourceNode => {$node},
3360     }__;
3361     }
3362 wakaba 1.6 for my $uri ($aliasResource->{uri},
3363     grep {$aliasResource->{aliasURI}->{$_}}
3364     keys %{$aliasResource->{aliasURI}}) {
3365     $self->{aliasURI}->{$uri} = true;
3366     $self->{db}->{resDef}->{$uri} = $self;
3367     $self->{subOf}->{$uri} = true;
3368     $self->{supOf}->{$uri} = true;
3369     }
3370     for my $uri (grep {$aliasResource->{subOf}->{$_}}
3371     keys %{$aliasResource->{subOf}}) {
3372     $self->{subOf}->{$uri} = true;
3373     }
3374     for my $uri (grep {$aliasResource->{supOf}->{$_}}
3375     keys %{$aliasResource->{supOf}}) {
3376     $self->{supOf}->{$uri} = true;
3377     }
3378     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
3379     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
3380     __DEEP{
3381     for my $from (@from) {
3382     for my $to (@to) {
3383     $self->{db}-><M::ManakaiDISDatabase.getResource>
3384     ($from)->{subOf}->{$to} = true;
3385     $self->{db}-><M::ManakaiDISDatabase.getResource>
3386     ($to)->{supOf}->{$from} = true;
3387     }
3388     }
3389     }__;
3390 wakaba 1.7
3391     @Method:
3392     @@Name: isTypeURI
3393     @@enDesc:
3394     Tests whether this resource is of a type or not.
3395     @@Param:
3396     @@@Name: typeURI
3397     @@@Type: ResourceURI
3398     @@@enDesc:
3399     A type URI reference to test.
3400     @@Return:
3401     @@@Type:
3402     DOMMain:boolean
3403     @@@TrueCase:
3404     @@@@enDesc:
3405     This is a <P::typeURI> resource.
3406     @@@FalseCase:
3407     @@@@enDesc:
3408     This is not a <P::typeURI> resource.
3409     @@@PerlDef:
3410 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
3411     $r = $self->{<Q::rdf:type>}->{$typeURI};
3412     } else {
3413     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
3414     keys %{$self->{<Q::rdf:type>}}) {
3415     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
3416     ($t_type_uri);
3417     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3418     ($typeURI)) {
3419     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
3420     last;
3421     }
3422 wakaba 1.7 }
3423     }
3424 wakaba 1.8
3425     @Attr:
3426     @@Name: plName
3427     @@enDesc:
3428     The Perl name of this resource.
3429     @@Get:
3430     @@@Type:
3431     DISLang:String
3432     @@@enDesc:
3433     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
3434     \
3435     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
3436     <CHAR::COLON> prefix).
3437     \
3438     - <Q::DISLang:Attribute>::: Method name.
3439     \
3440     - <Q::DISLang:Method>::: Method name.
3441     @@@nullCase:
3442     @@@@enDesc:
3443     Either the type of this resource is not listed above
3444     or this Perl constructure is anonymous.
3445     @@@RaiseException:
3446     @@@@@: NO_LOCAL_NAME_ERR
3447     @@@@enDesc:
3448     The type of this resource is either
3449     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
3450     the local name of this resource is not defined.
3451     @@@RaiseException:
3452     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
3453     @@@@enDesc:
3454     The Perl method name constructed from the source
3455     result in a reserved name.
3456     @@@PerlDef:
3457     __DEEP{
3458     if (exists $self->{<Q::dis2pm:name>}) {
3459     $r = $self->{<Q::dis2pm:name>};
3460     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3461     (<Q::ManakaiDOM:Const>) or
3462     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3463     (<Q::ManakaiDOM:ConstGroup>)) {
3464     $r = $self->{localName};
3465     unless (defined $r) {
3466     __UNDEEP{
3467     __EXCEPTION{NO_LOCAL_NAME_ERR::
3468     DIS:sourceNode => {$self->{src}},
3469     }__;
3470     }__;
3471     }
3472     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3473     (<Q::DISLang:Method>) or
3474     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3475     (<Q::DISLang:Attribute>)) {
3476     if (defined $self->{localName}) {
3477     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
3478     ($self->{localName});
3479     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
3480     (<Q::ManakaiDOM:isForInternal>, false)) {
3481     $r = '_' . $r;
3482     }
3483     if ({
3484     import => 1,
3485     unimport => 1,
3486     isa => 1,
3487     can => 1,
3488     new => 1,
3489     as_string => 1,
3490     stringify => 1,
3491     clone => 1,
3492     }->{$r} or $r =~ /^___/) {
3493     __UNDEEP{
3494     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
3495     DIS:uri => {$self->{uri}},
3496     DIS:soruceNode => {$self->{src}},
3497     DIS:generatedName => {$r},
3498     }__;
3499     }__;
3500 wakaba 1.11 }
3501     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
3502 wakaba 1.8 .plMethodOperator>) {
3503     $r = {
3504     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
3505     <Q::DISPerl:AsStringMethod> => 'as_string',
3506     <Q::DISPerl:AsNewMethod> => 'new',
3507     <Q::DISPerl:AsCloneMethod> => 'clone',
3508     }->{$op_uri};
3509     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
3510     } else {
3511     $r = null;
3512     }
3513     } else {
3514     $r = null;
3515     }
3516     $self->{<Q::dis2pm:name>} = $r;
3517     }__;
3518    
3519     @Attr:
3520     @@Name: plFullyQualifiedName
3521     @@enDesc:
3522     The fully-qualified Perl name of this resource.
3523     @@Type:
3524     DISLang:String::ManakaiDOM:all
3525     @@Get:
3526     @@@enDesc:
3527     Fully-qualified name.
3528     \
3529     - <Q::ManakaiDOM:Class>::: Class package name.
3530     \
3531     - <Q::ManakaiDOM:IF>::: Interface package name.
3532     \
3533     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
3534     type symbol such as <CODE::$>).
3535     @@@nullCase:
3536     @@@@enDesc:
3537     Otherwise.
3538     @@@NoPerlModuleNameException:
3539     @@@RaiseException:
3540     @@@@@: NO_LOCAL_NAME_ERR
3541     @@@@enDesc:
3542     The local name of this resource is not defined.
3543     @@@PerlDef:
3544     __DEEP{
3545     if (exists $self->{<Q::dis2pm:name>}) {
3546     $r = $self->{<Q::dis2pm:name>};
3547     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3548     (<Q::ManakaiDOM:Class>) or
3549     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3550     (<Q::ManakaiDOM:IF>) or
3551     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3552     (<Q::DISPerl:ScalarVariable>)) {
3553     my $an_node = $self->{src}-><AG::ManakaiDISElement.disGetAttribute>
3554     (<Q::dis:AppName>, for_arg => $self->{for},
3555     forp_arg => $self->{forp},
3556     media_type => <Q::lang:Perl>);
3557     if ($an_node) {
3558     ## NOTE: "lang:Perl" is fully-qualified name by definition
3559     $r = $an_node-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3560     } else {
3561 wakaba 1.10 unless (defined $self->{localName}) {
3562     __UNDEEP{
3563     __EXCEPTION{NO_LOCAL_NAME_ERR::
3564     DIS:sourceNode => {$self->{src}},
3565     }__;
3566     }__;
3567     }
3568 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3569     (<Q::ManakaiDOM:IF>)) {
3570     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3571     -><M::ManakaiDISModuleDefinition.plInterfaceName>
3572     . '::' . $self->{localName};
3573     } else {
3574     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3575     -><M::ManakaiDISModuleDefinition.plFullyQualifiedName>
3576     . '::' . $self->{localName};
3577     }
3578     }
3579     } else {
3580     $r = null;
3581     }
3582     $self->{<Q::dis2pm:name>} = $r;
3583     }__;
3584    
3585     @Attr:
3586     @@Name: plMethodOperator
3587     @@enDesc:
3588     The operator to overload by this method.
3589     @@Type:
3590     DISLang:String::ManakaiDOM:all
3591     @@Get:
3592     @@@enDesc:
3593     The operator, either Perl <CODE::use operator> operator name
3594     of manakai operator URI reference.
3595     @@@nullCase:
3596     @@@@enDesc:
3597     Either this resource does not define a Perl method or
3598     this method does not overload any operator.
3599     @@@UndeclaredPrefixException:
3600     @@@RaiseException:
3601     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
3602     @@@@enDesc:
3603     Media type of the <Q::dis:Operator> node is not supported.
3604     @@@PerlDef:
3605     __DEEP{
3606     if (exists $self->{<Q::dis:Operator>}) {
3607     $r = $self->{<Q::dis:Operator>};
3608     } else {
3609     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3610     (<Q::dis:Operator>, for_arg => $self->{for},
3611     forp_arg => $self->{forp});
3612     if ($op_node) {
3613     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3614 wakaba 1.12 (<Q::lang:Perl>, for_arg => $self->{for},
3615     for_arg => $self->{forp})) {
3616 wakaba 1.8 $r = $op_node-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3617     } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3618 wakaba 1.12 (<Q::dis:TypeQName>, for_arg => $self->{for},
3619     for_arg => $self->{forp})) {
3620 wakaba 1.8 $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
3621     } else {
3622 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
3623     (for_arg => $self->{for},
3624     forp_arg => $self->{forp});
3625 wakaba 1.8 __UNDEEP{
3626     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3627     DIS:uri => {$ct_uri},
3628 wakaba 1.10 DIS:sourceNode => {$op_node},
3629 wakaba 1.8 }__;
3630     }__;
3631     }
3632     } else {
3633     $r = null;
3634     }
3635     $self->{<Q::dis:Operator>} = $r;
3636     }
3637     }__;
3638    
3639     @Attr:
3640     @@Name: disDataTypeResource
3641     @@enDesc:
3642     <Q::dis:Type> attribute value of this resource.
3643     @@Type: ManakaiDISResourceDefinition
3644     @@Get:
3645     @@@RaiseException:
3646     @@@@@:NO_DIS_TYPE_ERR
3647     @@@@enDesc:
3648     <Q::dis:Type> attribute is not specified.
3649     @@@PerlDef:
3650     __DEEP{
3651     if (defined $self->{<Q::dis:Type>}) {
3652     $r = $self->{<Q::dis:Type>};
3653     } else {
3654     $self->{<Q::dis2pm:TypeNode>}
3655     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3656     (<Q::dis:Type>, for_arg => $self->{for},
3657     forp_arg => $self->{forp});
3658     if ($self->{<Q::dis2pm:TypeNode>}) {
3659     $r = $self->{<Q::dis:Type>}
3660     = $self->{<Q::dis2pm:TypeNode>}
3661     -><AG::ManakaiDISElement.qnameValueURI>;
3662     } else {
3663     my $pr = $self-><M::ManakaiDISPropertyAccessor
3664     .getPropertyResource>
3665     (<Q::DIS:dynamicParentResource>);
3666     if ($pr) {
3667     $r = $pr-><AG::ManakaiDISResourceDefinition
3668     .disDataTypeResource>;
3669     $self->{<Q::dis2pm:TypeNode>}
3670     = $pr->{<Q::dis2pm:TypeNode>};
3671     } else { ## No parent
3672     __UNDEEP{
3673     __EXCEPTION{NO_DIS_TYPE_ERR::
3674     DIS:sourceNode => {$self->{src}},
3675     }__;
3676     }__;
3677     }
3678     }
3679     }
3680     }__;
3681    
3682     @Attr:
3683     @@Name: disDataTypeNode
3684     @@enDesc:
3685     <Q::dis:Type> node for this resource.
3686     @@Get:
3687     @@@Type: ManakaiDISElement
3688     @@@RaiseException:
3689     @@@@@:NO_DIS_TYPE_ERR
3690     @@@@enDesc:
3691     <Q::dis:Type> attribute is not specified.
3692     @@@PerlDef:
3693     __DEEP{
3694     $self-><AG::ManakaiDISResourceDefinition.disDataTypeNode>;
3695     }__;
3696     $r = $self->{<Q::dis2pm:TypeNode>};
3697    
3698     @Attr:
3699     @@Name: disActualDataTypeResource
3700     @@enDesc:
3701     <Q::dis:actualType> attribute value of this resource.
3702     @@Type: ManakaiDISResourceDefinition
3703     @@Get:
3704     @@@RaiseException:
3705     @@@@@:NO_DIS_TYPE_ERR
3706     @@@@enDesc:
3707     <Q::dis:actualType> attribute is not specified,
3708     and <Q::dis:Type> attribute, neigher.
3709     @@@PerlDef:
3710     __DEEP{
3711     if (defined $self->{<Q::dis:actualType>}) {
3712     $r = $self->{<Q::dis:actualType>};
3713     } else {
3714     $self->{<Q::dis2pm:actualTypeNode>}
3715     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3716     (<Q::dis:actualType>, for_arg => $self->{for},
3717     forp_arg => $self->{forp});
3718     if ($self->{<Q::dis2pm:actualTypeNode>}) {
3719     $r = $self->{<Q::dis:actualType>}
3720     = $self->{<Q::dis2pm:actualTypeNode>}
3721     -><AG::ManakaiDISElement.qnameValueURI>;
3722     } elsif (defined $self->{<Q::dis:Type>}) {
3723     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
3724     $self->{<Q::dis2pm:actualTypeNode>}
3725     = $self->{<Q::dis2pm:TypeNode>};
3726     } else {
3727     $self->{<Q::dis2pm:actualTypeNode>}
3728     = $self->{<Q::dis2pm:TypeNode>}
3729     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3730     (<Q::dis:Type>, for_arg => $self->{for},
3731     forp_arg => $self->{forp});
3732     if ($self->{<Q::dis2pm:TypeNode>}) {
3733     $r = $self->{<Q::dis:actualType>}
3734     = $self->{<Q::dis:Type>}
3735     = $self->{<Q::dis2pm:TypeNode>}
3736     -><AG::ManakaiDISElement.qnameValueURI>;
3737     } else {
3738     my $pr = $self-><M::ManakaiDISPropertyAccessor
3739     .getPropertyResource>
3740     (<Q::DIS:dynamicParentResource>);
3741     if ($pr) {
3742     $r = $self->{<Q::dis:actualType>}
3743     = $pr-><AG::ManakaiDISResourceDefinition
3744     .disActualDataTypeResource>;
3745     $self->{<Q::dis2pm:actualTypeNode>}
3746     = $pr->{<Q::dis2pm:actualTypeNode>};
3747     } else { ## No parent
3748     __UNDEEP{
3749     __EXCEPTION{NO_DIS_TYPE_ERR::
3750     DIS:sourceNode => {$self->{src}},
3751     }__;
3752     }__;
3753     }
3754     }
3755     }
3756     }
3757     }__;
3758    
3759     @Attr:
3760     @@Name: disActualDataTypeNode
3761     @@enDesc:
3762     <Q::dis:actualType> node for this resource.
3763     @@Get:
3764     @@@Type: ManakaiDISElement
3765     @@@RaiseException:
3766     @@@@@:NO_DIS_TYPE_ERR
3767     @@@@enDesc:
3768     <Q::dis:actualType> attribute is not specified,
3769     and <Q::dis:Type> attribute, neigher.
3770     @@@PerlDef:
3771     __DEEP{
3772     $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeNode>;
3773     }__;
3774     $r = $self->{<Q::dis2pm:actualTypeNode>};
3775 wakaba 1.9
3776     @IntMethod:
3777     @@Operator:
3778     @@@@: <=>
3779     @@@ContentType:
3780     lang:Perl
3781     @@enDesc:
3782     Which is greater (i.e. the spaceship operator).
3783     A resource is less than another if it is loaded by
3784     <M::ManakaiDISDatabase.loadResource> before another is loaded.
3785     Order for non-loaded resource definitions are not defined.
3786     \
3787     {NOTE:: In the current implementation, non-loaded resources
3788     are less than any loaded resource and the order in
3789     non-loaded resources is unknown.
3790     \
3791     }
3792     @@Param:
3793     @@@Name: anotherResource
3794     @@@Type: ManakaiDISResourceDefinition
3795     @@@enDesc: Another resource to compare.
3796     @@Return:
3797     @@@Type:
3798     DOMMain:unsigned-long
3799     @@@PerlDef:
3800     if (UNIVERSAL::isa ($anotherResource,
3801     <ClassName::ManakaiDISResourceDefinition>)) {
3802     $r = $self->{seq} <=> $anotherResource->{seq};
3803     } else {
3804     $r = overload::Overloaded ($self) <=> $anotherResource;
3805     }
3806 wakaba 1.12
3807     @Attr:
3808     @@Name: plCodeFragment
3809     @@enDesc:
3810     Perl code definition fragment of this resource.
3811     @@Type: MPLCodeFragment
3812     @@Get:
3813     @@@enDesc:
3814     Perl code.
3815     @@@nullCase:
3816     @@@@enDesc:
3817     This node does not have Perl code definition.
3818     @@@RaiseException:
3819     @@@@@:NO_METHOD_RETURN_ERR
3820     @@@@enDesc:
3821     This resource is a <Q::DISLang:Method> but it does not
3822     have <Q::DISLang:MethodReturn> child-resource.
3823     @@@RaiseException:
3824     @@@@@:NO_ATTR_GET_ERR
3825     @@@@enDesc:
3826     This resource is a <Q::DISLang:Attribute> but it does not
3827     have <Q::DISLang:AttributeGet> child-resource.
3828     @@@RaiseException:
3829     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
3830     @@@@enDesc:
3831     The media type of <Q::dis:Def> element is not supported.
3832     @@@PerlDef:
3833     __DEEP{
3834     if (exists $self->{<Q::plCodeFragment>}) {
3835     $r = $self->{<Q::plCodeFragment>};
3836     } elsif (not $self->{src}) {
3837     $r = $self->{<Q::plCodeFragment>} = null;
3838     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3839     (<Q::DISLang:MethodReturn>) or
3840     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3841     (<Q::DISLang:AttributeGet>) or
3842     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3843 wakaba 1.13 (<Q::DISLang:AttributeSet>) or
3844     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3845     (<Q::dis2pm:BlockCode>) or
3846     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3847     (<Q::dis2pm:InlineCode>)) {
3848     $self->{<Q::plCodeFragment>} = null; ## To avoid loop
3849 wakaba 1.12 my $def = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3850     (<Q::dis:Def>, for_arg => $self->{for},
3851     forp_arg => $self->{forp});
3852     if ($def-><M::ManakaiDISElement.mediaTypeMatch> (<Q::lang:Perl>)) {
3853     $r = $self->{<Q::plCodeFragment>}
3854     = $self-><M::ManakaiDISResourceDefinition.plImplementation>
3855     -><M::MPLImpl.createPerlUnparsedCode>
3856     ($def-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>);
3857     $r-><AS::MPLUnparsedCode.sourceFile>
3858     ($self->{src}-><M::swcfg21:SWCFGNode
3859     ::swcfg21:ForLatest.nodePath>
3860     (key => [qw/Name QName type Type/]));
3861     $r-><AS::MPLUnparsedCode.sourceLine> (1);
3862     } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
3863     (<Q::lang:dis>)) {
3864     $r = $self->{<Q::plCodeFragment>}
3865     = $self-><M::ManakaiDISResourceDefinition.plImplementation>
3866     -><M::MPLImpl.createPerlUnparsedCode>
3867     ($def-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>);
3868     ## TODO: implement
3869     } else {
3870     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
3871     (for_arg => $self->{for},
3872     forp_arg => $self->{forp});
3873     __UNDEEP{
3874     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3875     DIS:uri => {$mt},
3876     DIS:sourceNode => {$def},
3877     }__;
3878     }__;
3879     } # media type
3880     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3881     (<Q::DISLang:Method>)) {
3882 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
3883 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
3884     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
3885     unless ($ret) {
3886     __UNDEEP{
3887     __EXCEPTION{NO_METHOD_RETURN_ERR::
3888     DIS:errResource => {$self},
3889     DIS:sourceNode => {$self->{src}},
3890     }__;
3891     }__;
3892     }
3893     $r = $self->{<Q::plCodeFragment>}
3894     = $self-><M::ManakaiDISResourceDefinition.plImplementation>
3895     -><M::MPLImpl.createPerlSub>
3896     ($self-><AG::ManakaiDISResourceDefinition.plName>);
3897    
3898    
3899     ## TODO: Parameter, sub, ...
3900 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
3901 wakaba 1.12 ($ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
3902    
3903     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3904     (<Q::DISLang:Attribute>)) {
3905 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
3906 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
3907     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
3908     unless ($get) {
3909     __UNDEEP{
3910     __EXCEPTION{NO_ATTR_GET_ERR::
3911     DIS:errResource => {$self},
3912     DIS:sourceNode => {$self->{src}},
3913     }__;
3914     }__;
3915     }
3916     $r = $self->{<Q::plCodeFragment>}
3917     = $self-><M::ManakaiDISResourceDefinition.plImplementation>
3918     -><M::MPLImpl.createPerlSub>
3919     ($self-><AG::ManakaiDISResourceDefinition.plName>);
3920    
3921    
3922     ## TODO: Parameter, sub, set, ...
3923 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
3924 wakaba 1.12 ($get-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
3925    
3926 wakaba 1.13 } else { ## Not supported
3927 wakaba 1.12 $r = $self->{<Q::plCodeFragment>} = null;
3928     } # rdf:type
3929     }__;
3930    
3931     @Attr:
3932     @@Name:plImplementation
3933     @@enDesc:
3934     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
3935     @@Type: MPLImpl
3936     @@Get:
3937     @@@enDesc:
3938     The Perl code implementation object.
3939     @@@nullCase:
3940     This resource has no source tree associated.
3941     @@@RaiseException:
3942     @@@@@:NO_PERL_CODE_IMPL_ERR
3943     @@@@enDesc:
3944     There is no implementation that implements
3945     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
3946     @@@PerlDef:
3947     if ($self->{src}) {
3948     __DEEP{
3949     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
3950     $self->{src})-><AG::SWCFGDoc.implementation>
3951     -><M::DOMMinImpl.getFeature>
3952     (<Q::Util:PerlCode> => '1.0');
3953     }__;
3954     unless (defined $r) {
3955     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
3956    
3957     }__;
3958     }
3959     }
3960    
3961     @Method:
3962     @@Name: getChildResourceByType
3963     @@enDesc:
3964     Gets a static child resource selected by its type.
3965     @@Param:
3966     @@@Name:typeURI
3967     @@@Type:ResourceURI
3968     @@@enDesc:
3969     A URI reference identifying a resource type.
3970     @@Return:
3971     @@@Type: ManakaiDISResourceDefinition
3972     @@@enDesc:
3973     The first (by document order) child resource whose
3974     type matches with <P::resType>.
3975     @@@nullCase:
3976     @@@@enDesc:
3977     There is no resource whose type is <P::resType>.
3978     @@@PerlDef:
3979     __DEEP{
3980     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
3981     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
3982     ($cr_uri);
3983     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
3984     $r = $cr;
3985     last;
3986     }
3987     }
3988     }__;
3989 wakaba 1.13
3990     @Method:
3991     @@Name: getChildResourceByNameAndType
3992     @@enDesc:
3993     Gets a static child resource selected by its local name and type.
3994     @@Param:
3995     @@@Name: localName
3996     @@@Type:
3997     DISCore:LocalName::ManakaiDOM:all
3998     @@@enDesc:
3999     A local name.
4000     @@Param:
4001     @@@Name:typeURI
4002     @@@Type:ResourceURI
4003     @@@enDesc:
4004     A URI reference identifying a resource type.
4005     @@Return:
4006     @@@Type: ManakaiDISResourceDefinition
4007     @@@enDesc:
4008     The first (by document order) child resource whose
4009     type matches for <P::localName> and <P::resType>.
4010     @@@nullCase:
4011     @@@@enDesc:
4012     There is no resource whose name is <P::localName> and
4013     whose type is <P::resType>.
4014     @@@PerlDef:
4015     __DEEP{
4016     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4017     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4018     ($cr_uri);
4019     my $ln = $cr-><M::ManakaiDISResourceDefinition.localName>;
4020     if (defined $ln and $ln eq $localName and
4021     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
4022     $r = $cr;
4023     last;
4024     }
4025     }
4026     }__;
4027    
4028     @Method:
4029     @@Name: getConstResourceByName
4030     @@enDesc:
4031     Gets a constant value resource by its local name.
4032     @@Param:
4033     @@@Name:localName
4034     @@@Type:
4035     DISLang:String::ManakaiDOM:all
4036     @@@enDesc:
4037     Constant name.
4038     @@Return:
4039     @@@Type: ManakaiDISResourceDefinition
4040     @@@enDesc:
4041     The constant resource identified by <P::localName>.
4042     @@@nullCase:
4043     @@@@enDesc:
4044     There is no such constant resource.
4045     @@@PerlDef:
4046     __DEEP{
4047     my @constGroup;
4048     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4049     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4050     ($cr_uri);
4051     my $ln = $cr-><M::ManakaiDISResourceDefinition.localName>;
4052     if ($ln and $ln eq $localName and
4053     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4054     (<Q::ManakaiDOM:Const>)) {
4055     $r = $cr;
4056     last;
4057     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4058     (<Q::ManakaiDOM:ConstGroup>)) {
4059     push @constGroup, $cr;
4060     }
4061     }
4062     unless ($r) {
4063     for my $cg (@constGroup) {
4064     $r = $cg-><M::ManakaiDISResourceDefinition
4065     .getChildResourceByNameAndType>
4066     ($localName, <Q::ManakaiDOM:Const>);
4067     last if $r;
4068     }
4069     }
4070     }__;
4071    
4072     @Method:
4073     @@Name: plPreprocessPerlCode
4074     @@enDesc:
4075     Preprocesses a Perl block-level code fragment.
4076     @@Param:
4077     @@@Name:codeArg
4078     @@@Type:
4079     lang:Perl::ManakaiDOM:all
4080     @@@enDesc:
4081     A Perl block-level code (statements and/or blocks).
4082     @@Return:
4083     @@@Type:
4084     lang:Perl::ManakaiDOM:all
4085     @@@enDesc:
4086     Preprocessed Perl code.
4087     @@@PerlDef:
4088     \##
4089    
4090     @Method:
4091     @@Name: plPreprocessPerlStatement
4092     @@enDesc:
4093     Preprocesses a Perl inline code fragment
4094     (code fragment smaller than statement).
4095     @@Param:
4096     @@@Name:codeArg
4097     @@@Type:
4098     lang:Perl::ManakaiDOM:all
4099     @@@enDesc:
4100     A Perl code fragment.
4101     @@NodeParam:
4102     @@Return:
4103     @@@Type:
4104     lang:Perl::ManakaiDOM:all
4105     @@@enDesc:
4106     Preprocessed Perl code.
4107     @@@InlineElementException:
4108     @@@PerlDef:
4109     unless ($self->{src}) {
4110     __EXCEPTION{NO_SOURCE_NODE_ERR::
4111     DIS:uri => {$self->{uri}},
4112     }__;
4113     }
4114     __DEEP{
4115     our $RegQNameChar;
4116     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4117     .plImplementation>;
4118     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
4119     for my $source_code (split /(?<![?^qwr])(\x3C$RegQNameChar[^<>]+> |
4120     \b(?:null|true|false)\b)/x, $codeArg) {
4121     if ($source_code =~ s/^\x3C//) {
4122     $source_code =~ s/>$//;
4123     if ($source_code =~ /=$/) {
4124     ## TODO: Warning
4125     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
4126     # q{should "=" be used place of "=>"?};
4127     }
4128     if ($source_code =~ s/^(.+?):://) {
4129     my $et = $self->{src}
4130     -><M::ManakaiDISElement.qnameToURI>
4131     ($1,
4132     node => $node,
4133     default_namespace_uri => <Q::disPerl:>);
4134     if ($et eq <Q::disPerl:Q>) { ## QName constant
4135     $r-><M::PLAnyCon.appendStringLiteral>
4136     ($self->{src}
4137     -><M::ManakaiDISElement.qnameToURI>
4138     ($source_code, node => $node));
4139     } elsif ({
4140     <Q::disPerl:M> => 1,
4141     <Q::disPerl:ClassM> => 1,
4142     <Q::disPerl:AG> => 1,
4143     <Q::disPerl:AS> => 1,
4144     }->{$et}) { ## Method call
4145     my ($class_qname, $method_qname)
4146     = split /\s*\.\s*/, $source_code, 2;
4147     my $class_uri
4148     = $self->{src}
4149     -><M::ManakaiDISElement.tfqnamesToURI>
4150     ($class_qname,
4151     $self-><AG::ManakaiDISResourceDefinition
4152     .ownerClassURI>,
4153     $self->{for},
4154     node => $node);
4155     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4156     ($class_uri);
4157     $class-><M::ManakaiDISResourceDefinition.isReferred>
4158     ($node || $self->{src});
4159     if ($et eq <Q::disPerl::ClassM> and
4160     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
4161     (<Q::ManakaiDOM:IF>)) {
4162     __UNDEEP{
4163     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
4164     DIS:uri => {$class_uri},
4165     DIS:elementType => {$et},
4166     DIS:sourceNode => {$node || $self->{src}},
4167     DIS:sourceCode => {$source_code},
4168     }__;
4169     }__;
4170     }
4171     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
4172     (<Q::ManakaiDOM:IF>)) {
4173     $self-><AG::ManakaiDISResourceDefinition.definingModule>
4174     -><M::ManakaiDISModuleDefinition.plAddRequireModule>
4175     ($class-><AG::ManakaiDISResourceDefinition
4176     .definingModule>);
4177     }
4178     my $method = $self-><M::ManakaiDISResourceDefinition
4179     .getChildResourceByNameAndType>
4180     ($method_qname,
4181     {
4182     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
4183     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
4184     }->{$et} || <Q::DISLang:Method>);
4185     if (not $method or
4186     not $method-><AG::ManakaiDISResourceDefinition
4187     .isDefined>) {
4188     __UNDEEP{
4189     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4190     DIS:localName => {$method_qname},
4191     DIS:elementType => {$et},
4192     DIS:sourceNode => {$node || $self->{src}},
4193     DIS:sourceCode => {$source_code},
4194     }__;
4195     }__;
4196     }
4197     my $class_name = '';
4198     if ($et eq <Q::disPerl:ClassM>) {
4199     $class_name = $class-><AG::ManakaiDISResourceDefinition
4200     .plFullyQualifiedName> . '->';
4201     }
4202     my $method_name = $method-><AG::ManakaiDISResourceDefinition
4203     .plName>;
4204     $r-><M::PLAnyCon.appendBare>
4205     ($class_name . $method_name);
4206     } elsif ({
4207     <Q::disPerl:Class> => 1,
4208     <Q::disPerl:ClassName> => 1,
4209     <Q::disPerl:IF> => 1,
4210     <Q::disPerl:IFName> => 1,
4211     }->{$et}) { ## Perl package name
4212     my $class_uri
4213     = $self->{src}
4214     -><M::ManakaiDISElement.tfqnamesToURI>
4215     ($source_code,
4216     $self-><AG::ManakaiDISResourceDefinition
4217     .ownerClassURI>,
4218     $self->{for},
4219     node => $node);
4220     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4221     ($class_uri);
4222     $class-><M::ManakaiDISResourceDefinition.isReferred>
4223     ($node || $self->{src});
4224     my $pack = $class-><M::ManakaiDISResourceDefinition
4225     .plFullyQualifiedName>;
4226     if ({
4227     <Q::disPerl:ClassName> => 1,
4228     <Q::disPerl:IFName> => 1,
4229     }->{$et}) {
4230     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
4231     } else {
4232     $r-><M::PLAnyCon.appendBare> ($pack);
4233     }
4234     } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
4235     my $code_name;
4236     $source_code =~ s/^\s+//;
4237     if ($source_code =~ s/^((?>(?!::).)+)//s) {
4238     $code_name = $1;
4239     $code_name =~ tr/|/:/;
4240     } else {
4241     __UNDEEP{
4242     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
4243     DIS:sourceCode => {$source_code},
4244     DIS:sourceNode => {$node || $self->{src}},
4245     }__;
4246     }__;
4247     }
4248     $source_code =~ s/^::\s*//;
4249     my $param = $self-><M::ManakaiDISResourceDefinition
4250     .plParsePreprocessParameter>
4251     ($source_code, node => $node);
4252     my $code_uri = $self->{src}-><M::ManakaiDISElement
4253     .tfqnamesToURI>
4254     ($code_name, null, $self->{for},
4255     node => $node);
4256     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
4257     ($code_uri);
4258     $code-><M::ManakaiDISResourceDefinition.isReferred>
4259     ($node || $self->{src});
4260     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
4261     (<Q::dis2pm:InlineCode>)) {
4262     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4263     DIS:uri => {$code_uri},
4264     DIS:sourceNode => {$node || $self->{src}},
4265     DIS:sourceCode => {$source_code},
4266     DIS:expectedType => {<Q::dis2pm:InlineCode>},
4267     }__;}__;
4268     }
4269     my $pc = $code-><AG::ManakaiDISResourceDefinition
4270     .plCodeFragment>->clone;
4271     unless (defined $pc) {
4272     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4273     DIS:sourceNode => {$node || $self->{src}},
4274     DIS:sourceCode => {$source_code},
4275     DIS:uri => {$code_uri},
4276     }__}__;
4277     }
4278     for my $var (grep {/^\$/} keys %$param) {
4279     my $value;
4280     if ($param->{$var}->{type} eq 'variable') {
4281     $value = $plimpl-><M::MPLImpl.createPerlVariable>
4282     ('$', null, $param->{$var}->{value});
4283     } elsif ($param->{$var}->{type} eq 'code') {
4284     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
4285     ($param->{$var}->{value});
4286     } else {
4287     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
4288     ($param->{$var}->{value});
4289     }
4290     $pc-><M::MPLCodeFragment.replaceVariable>
4291     ($var => $value);
4292     }
4293     $r-><M::PLInCon.appendCode> ($pc);
4294     } elsif ($et eq <Q::disPerl:C>) {
4295     my ($class_qname, $const_name) = split /\./, $source_code, 2;
4296     my $class_uri
4297     = $self->{src}
4298     -><M::ManakaiDISElement.tfqnamesToURI>
4299     ($class_qname,
4300     $self-><AG::ManakaiDISResourceDefinition
4301     .ownerClassURI>,
4302     $self->{for},
4303     node => $node);
4304     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4305     ($class_uri);
4306     $class-><M::ManakaiDISResourceDefinition.isReferred>
4307     ($node || $self->{src});
4308     my $const = $class-><M::ManakaiDISResourceDefinition
4309     .getConstResourceByName> ($const_name);
4310     unless (defined $const) {
4311     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4312     DIS:sourceNode => {$node || $self->{src}},
4313     DIS:sourceCode => {$source_code},
4314     DIS:localName => {$const_name},
4315     }__}__;
4316     }
4317     my $pc = $const-><M::ManakaiDISResourceDefinition
4318     .plCodeFragment>->clone;
4319     unless (defined $pc) {
4320     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4321     DIS:sourceNode => {$node || $self->{src}},
4322     DIS:sourceCode => {$source_code},
4323     DIS:localName => {$const_name},
4324     }__}__;
4325     }
4326     $r-><M::PLInCon.appendCodeFragment> ($pc);
4327     } else {
4328     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4329     DIS:elementType => {$et},
4330     DIS:sourceNode => {$node || $self->{src}},
4331     }__}__;
4332     }
4333     } else {
4334     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
4335     DIS:sourceNode => {$node || $self->{src}},
4336     DIS:sourceCode => {$source_code},
4337     }__}__;
4338     }
4339     } elsif ({
4340     'tr'.'ue' => true,
4341     'fal'.'se' => true,
4342     'nu'.'ll' => true,
4343     }->{$source_code}) {
4344     $r-><M::PLAnyCon.appendAtom> ({
4345     'tr'.'ue' => 1,
4346     'fal'.'se' => 0,
4347     'nu'.'ll' => 'undef',
4348     }->{$source_code});
4349     } else {
4350     $r-><M::PLInCon.appendCode> ($source_code);
4351     }
4352     } # for
4353     }__; # DEEP
4354    
4355     @Attr:
4356     @@Name: ownerClassURI
4357     @@enDesc:
4358     The URI reference of the class resource this resource
4359     belongs to.
4360     @@Type: ResourceURI
4361     @@Get:
4362     @@@enDesc:
4363     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
4364     If this resource is a class, then the URI reference
4365     of this resource is returned.
4366     @@@nullCase:
4367     @@@@enDesc:
4368     This resource does not belong to any class.
4369     @@@PerlDef:
4370     if (exists $self->{<Q::DIS:ownerClass>}) {
4371     $r = $self->{<Q::DIS:ownerClass>};
4372     } else {
4373     my $res = $self;
4374     __DEEP{
4375     {
4376     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
4377     (<Q::ManakaiDOM:Class>)) {
4378     $r = $res->{uri};
4379     } else {
4380     $res = $res-><M::ManakaiDISPropertyAccessor
4381     .getPropertyResource> (<Q::dis2pm:parentResource>);
4382     redo if $res;
4383     }
4384     }
4385     }__;
4386     $self->{<Q::DIS:ownerClass>} = $r;
4387     }
4388    
4389     @IntMethod:
4390     @@Name: plParsePreprocessParameter
4391     @@enDesc:
4392     Parses a parameter specification in preprocessing instruction
4393     and return it as a hash reference.
4394     \
4395     {NOTE:: The callee have to ensure that this resource has its
4396     <CODE::src> before the call to this method.
4397     \
4398     }
4399     @@Param:
4400     @@@Name: paramSpec
4401     @@@Type:
4402     DISLang:String::ManakaiDOM:all
4403     @@@enDesc:
4404     A parameter specification to parse.
4405     @@NodeParam:
4406     @@Return:
4407     @@@Type:
4408     Perl:hash::ManakaiDOM:all
4409     @@@enDesc:
4410     Hash containing parameters. Each hash value is also
4411     a hash reference, containing two keys <CODE::type>
4412     (its value is either <CODE::bare>, <CODE::quoted>,
4413     <CODE::code> or <CODE::variable>) and
4414     <CODE::value>.
4415     @@@RaiseException:
4416     @@@@@:BROKEN_PARAM_SPEC_ERR
4417     @@@@enDesc:
4418     The <P::paramSpec> is not well-formed.
4419     @@@PerlDef:
4420     BEGIN{
4421     our $RegQNameChar = qr/[^\s<>"'\\\[\]\{\},=\$\@%]/;
4422     use re 'eval';
4423     our $RegBlockContent;
4424     $RegBlockContent = qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{
4425     $RegBlockContent})\})*)/s;
4426     }
4427    
4428     our $RegQNameChar;
4429     our $RegBlockContent;
4430     $r = {};
4431     while ($paramSpec =~ s/^
4432     ## Parameter name
4433     (\$? $RegQNameChar+)\s*
4434    
4435     (?: =>? \s*
4436     ## ">" is now optional for inline element (">" is delimiter)
4437    
4438     ## Parameter value
4439     (
4440     ## Bare string
4441     $RegQNameChar+
4442     |
4443     ## Quoted string
4444     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
4445     |
4446     ## Code
4447     \{$RegBlockContent\}
4448    
4449     )
4450    
4451     \s*)?
4452    
4453     (?:,\s*|$)//ox) {
4454    
4455     my ($n, $v) = ($1, $2);
4456     if (defined $v) {
4457     if ($v =~ /^'/) {
4458     $v = {type => 'quoted',
4459     value => substr ($v, 1, length ($v) - 2)};
4460     } elsif ($v =~ /^\{/) {
4461     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
4462     } elsif ($v =~ /^\$/) {
4463     $v => {type => 'variable', value => $v};
4464     } else {
4465     $v = {type => 'bare', value => $v};
4466     }
4467     } else {
4468     $v = {type => 'boolean', value => true};
4469     }
4470    
4471     if ($n =~ /^\$/) {
4472     $r->{$n} = $v;
4473     } else {
4474     __DEEP{
4475     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
4476     ($n, node => $node || $self->{src})} = $v;
4477     }__;
4478     }
4479     } # while
4480    
4481     if (length $paramSpec) {
4482     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
4483     DIS:sourceCode => {$paramSpec},
4484     DIS:sourceNode => {$node || $self->{src}},
4485     }__;
4486     }
4487    
4488 wakaba 1.2 ##DISResourceDefinition
4489    
4490 wakaba 1.13 ElementTypeBinding:
4491     @Name: InlineElementException
4492     @ElementType:
4493     ManakaiDOM:raises
4494     @ShadowContent:
4495     @@@: NO_SOURCE_NODE_ERR
4496     @@Description:
4497     @@@lang:en
4498     @@@@:
4499     This resource definition does not have associated node
4500     in the source tree.
4501     @ShadowSibling:
4502     @@ManakaiDOM:raises:
4503     @@@@: INTERFACE_CLASS_METHOD_ERR
4504     @@@Description:
4505     @@@@lang:en
4506     @@@@@:
4507     An attempt is made to call a class (static) method
4508     via an interface, not class.
4509     @@ManakaiDOM:raises:
4510     @@@@: RESOURCE_NOT_DEFINED_ERR
4511     @@@Description:
4512     @@@@lang:en
4513     @@@@@:
4514     A package, method or attribute is not defined or not
4515     a resoure of that type.
4516     @@ManakaiDOM:raises:
4517     @@@@: NO_LOCAL_NAME_ERR
4518     @@@Description:
4519     @@@@lang:en
4520     @@@@@:
4521     A referred resource does not have its local name so
4522     that it is impossible to refer it by name.
4523     @@ManakaiDOM:raises:
4524     @@@@: RESERVED_PERL_METHOD_NAME_ERR
4525     @@@Description:
4526     @@@@lang:en
4527     @@@@@:
4528     A referred method has its name reserved for special-purpose.
4529     @@ManakaiDOM:raises:
4530     @@@@: BROKEN_PARAM_SPEC_ERR
4531     @@@Description:
4532     @@@@lang:en
4533     @@@@@:
4534     A parameter specification is not well-formed.
4535     @@ManakaiDOM:raises:
4536     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
4537     @@@enDesc:
4538     A preprocessing instruction does not contain
4539     Perl code fragment name.
4540     @@ManakaiDOM:raises:
4541     @@@@: PERL_CODE_NOT_DEFINED_ERR
4542     @@@enDesc:
4543     The referred resource does not have its Perl definition.
4544     @@ManakaiDOM:raises:
4545     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
4546     @@@enDesc:
4547     A preprocessing instruction does not contain its element type name.
4548     @@ManakaiDOM:raises:
4549     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
4550     @@@enDesc:
4551     An unknown element type is encounted.
4552    
4553     PropDef:
4554     @QName: ownerClass
4555     @enDesc:
4556     The class to which this resource belongs.
4557     @Type: ResourceURI
4558     @rdfs:range:
4559     rdf:Resource
4560     @rdfs:domain:
4561     ManakaiDOM:Class
4562    
4563 wakaba 1.12 ResourceDef:
4564     @QName: DOMMinImpl
4565     @rdf:type:
4566     ManakaiDOM:IF
4567     @AliasFor:
4568     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
4569    
4570     ResourceDef:
4571     @QName: SWCFGNode
4572     @rdf:type:
4573     ManakaiDOM:IF
4574     @AliasFor:
4575     swcfg21:SWCFGNode::swcfg21:ForLatest
4576    
4577     ResourceDef:
4578     @QName: SWCFGDoc
4579     @rdf:type:
4580     ManakaiDOM:IF
4581     @AliasFor:
4582     swcfg21:SWCFGDocument::swcfg21:ForLatest
4583    
4584     ResourceDef:
4585     @QName: MPLImpl
4586     @rdf:type:
4587     ManakaiDOM:Class
4588     @AliasFor:
4589     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
4590    
4591     ResourceDef:
4592     @QName: MPLCodeFragment
4593     @rdf:type:
4594     ManakaiDOM:Class
4595     @AliasFor:
4596     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
4597    
4598     ResourceDef:
4599 wakaba 1.13 @QName: PLInCon
4600     @rdf:type:
4601     ManakaiDOM:Class
4602     @AliasFor:
4603     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
4604    
4605     ResourceDef:
4606     @QName: PLAnyCon
4607     @rdf:type:
4608     ManakaiDOM:Class
4609     @AliasFor:
4610     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
4611    
4612     ResourceDef:
4613     @QName: MPLSS
4614     @rdf:type:
4615     ManakaiDOM:Class
4616     @AliasFor:
4617     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
4618    
4619     ResourceDef:
4620 wakaba 1.12 @QName: MPLSub
4621     @rdf:type:
4622     ManakaiDOM:Class
4623     @AliasFor:
4624     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
4625    
4626     ResourceDef:
4627     @QName: MPLUnparsedCode
4628     @rdf:type:
4629     ManakaiDOM:Class
4630     @AliasFor:
4631     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
4632    
4633     PropDef:
4634     @QName: plCodeFragment
4635     @enDesc:
4636     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
4637    
4638     XParamDef:
4639     @QName: errResource
4640     @enDesc:
4641     A resource on which an error has occurred.
4642    
4643 wakaba 1.8 XParamDef:
4644     @QName: generatedName
4645     @enDesc:
4646     A generated name.
4647    
4648 wakaba 1.2 ClsDef:
4649     @ClsQName: ManakaiDISPropertyAccessor
4650 wakaba 1.3 @enDesc:
4651 wakaba 1.2 Accessor methods for resource or module properties.
4652    
4653     @Method:
4654 wakaba 1.8 @@Name: getPropertyBoolean
4655     @@enDesc:
4656     Gets boolean property value.
4657     @@PropNameParam:
4658     @@Param:
4659     @@@Name:default
4660     @@@Type:
4661     DOMMain:boolean::ManakaiDOM:all
4662     @@@enDesc:
4663     The default value that is returned if no explicit property
4664     value specification found for this resource.
4665     @@Return:
4666     @@@Type:
4667     DOMMain:boolean::ManakaiDOM:all
4668     @@@enDesc:
4669     The property value.
4670     @@@PerlDef:
4671     if (exists $self->{$propName}) {
4672     $r = defined $self->{$propName} ? $self->{$propName} : $default;
4673     } elsif ($self->{src}) {
4674     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4675     ($propName, for_arg => $self->{for},
4676     forp_arg => $self->{forp});
4677     $self->{$propName} = $r;
4678     $r = $default unless defined $r;
4679     } else {
4680     $r = $default;
4681     }
4682    
4683     @Method:
4684 wakaba 1.2 @@Name: getPropertyText
4685     @@enDesc:
4686     Gets property value text.
4687     @@PropNameParam:
4688     @@Param:
4689     @@@Name:default
4690     @@@Type:
4691 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
4692 wakaba 1.2 @@@enDesc:
4693     The default value that is returned if no explicit property
4694     value specification found for this resource.
4695     @@@nullCase:
4696     @@@@enDesc:
4697     No default value supplied; <DOM::null> is returned if
4698     no value specified.
4699     @@Return:
4700     @@@Type:
4701 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
4702 wakaba 1.2 @@@enDesc:
4703     The property value string.
4704     @@@nullCase:
4705     @@@@enDesc:
4706     No value nor default value has specified.
4707     @@@PerlDef:
4708     if (exists $self->{$propName}) {
4709     $r = defined $self->{$propName} ? $self->{$propName} : $default;
4710     } elsif ($self->{src}) {
4711     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4712     ($propName, for_arg => $self->{for},
4713     forp_arg => $self->{forp});
4714 wakaba 1.8 if ($r) {
4715     $r = $self->{$propName}
4716     = $r-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
4717     $r = $default unless defined $r;
4718     } else {
4719     $r = $default;
4720     $self->{$propName} = null;
4721     }
4722 wakaba 1.2 } else {
4723     $r = $default;
4724     }
4725    
4726     @Method:
4727     @@Name: getPropertyResource
4728     @@enDesc:
4729     Gets property value resource.
4730     @@PropNameParam:
4731 wakaba 1.10 @@NamedParam:
4732     @@@Name: defaultMediaType
4733     @@@Type: ResourceURI
4734     @@@enDesc:
4735     The URI reference of the default media type which is used
4736     when the property value is retrieved from the source tree
4737     and the source tree element does not have its <Q::dis:ContentType>
4738     attribute specified.
4739     @@@nullCase:
4740     @@@@enDesc:
4741     Defaulted to <Q::dis:TypeQName>.
4742 wakaba 1.2 @@Return:
4743     @@@Type: ManakaiDISResourceDefinition
4744     @@@enDesc:
4745     The property value resource.
4746     @@@nullCase:
4747     @@@@enDesc:
4748     No value has specified.
4749 wakaba 1.8 @@@UndeclaredPrefixException:
4750 wakaba 1.12 @@@RaiseException:
4751     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4752     @@@@enDesc:
4753     The media type of the attribute node in the source tree
4754     corresponding to this resource is not supported.
4755 wakaba 1.2 @@@PerlDef:
4756     if (defined $self->{$propName}) {
4757 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4758     ($self->{$propName});
4759 wakaba 1.8 } elsif ($self->{src}) {
4760     __DEEP{
4761     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4762     ($propName, for_arg => $self->{for},
4763     forp_arg => $self->{forp});
4764     if ($r) {
4765 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
4766     unless defined $defaultMediaType;
4767     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
4768 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
4769     for_arg => $self->{for},
4770     forp_arg => $self->{forp})) {
4771 wakaba 1.10 $self->{$propName}
4772     = $r-><AG::ManakaiDISElement.qnameValueURI>;
4773     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
4774 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
4775     for_arg => $self->{for},
4776     forp_arg => $self->{forp})) {
4777 wakaba 1.10 $self->{$propName}
4778     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
4779     ($self->{src}-><AG::swcfg21:SWCFGNode
4780     ::swcfg21:ForLatest.nodeID>,
4781     $self->{for});
4782     } else {
4783     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
4784     (for_arg => $self->{for},
4785     forp_arg => $self->{forp});
4786     __UNDEEP{
4787     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4788     DIS:uri => {$mt},
4789     DIS:sourceNode => {$r},
4790     }__;
4791     }__;
4792     }
4793 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4794     ($self->{$propName});
4795     $r-><M::ManakaiDISResourceDefinition.isReferred> ($self->{src});
4796 wakaba 1.8 }
4797     }__;
4798 wakaba 1.2 }
4799    
4800     @Method:
4801 wakaba 1.10 @@Name: getPropertyResourceList
4802     @@enDesc:
4803     Gets property value resource list.
4804     @@PropNameParam:
4805     @@NamedParam:
4806     @@@Name: recursiveISA
4807     @@@Type:
4808     DOMMain:boolean
4809     @@@enDesc:
4810     Whether property resource values of <Q::dis:ISA> resources
4811     of this resource should also be included to the returned list or not.
4812     @@NamedParam:
4813     @@@Name: defaultMediaType
4814     @@@Type: ResourceURI
4815     @@@enDesc:
4816     The URI reference of the default media type which is used
4817     when the property value is retrieved from the source tree
4818     and the source tree element does not have its <Q::dis:ContentType>
4819     attribute specified.
4820     @@@nullCase:
4821     @@@@enDesc:
4822     Defaulted to <Q::dis:TypeQName>.
4823     @@Return:
4824     @@@Type: ResourceList
4825     @@@enDesc:
4826     An array reference of the property value resources.
4827     \
4828     {NOTE:: This list is <QUOTE::dead>.
4829     \
4830     }
4831     @@@UndeclaredPrefixException:
4832 wakaba 1.12 @@@RaiseException:
4833     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4834     @@@@enDesc:
4835     The media type of the attribute node in the source tree
4836     corresponding to this resource is not supported.
4837 wakaba 1.10 @@@PerlDef:
4838     $r = [];
4839     if (defined $self->{$propName}) {
4840     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
4841     ? $self->{$propName} : []}) {
4842     push @$r,
4843     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
4844     }
4845     } elsif ($self->{src}) {
4846     __DEEP{
4847     $self->{$propName} = [];
4848     $defaultMediaType = <Q::dis:TypeQName>
4849     unless defined $defaultMediaType;
4850     for my $res_name_node
4851     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
4852     ($propName, for_arg => $self->{for},
4853     forp_arg => $self->{forp})}) {
4854     my $res_uri;
4855     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
4856 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
4857     for_arg => $self->{for},
4858     forp_arg => $self->{forp})) {
4859 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
4860     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
4861 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
4862     for_arg => $self->{for},
4863     forp_arg => $self->{forp})) {
4864 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
4865     ($self->{src}-><AG::swcfg21:SWCFGNode
4866     ::swcfg21:ForLatest.nodeID>,
4867     $self->{for});
4868     } else {
4869     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
4870     (for_arg => $self->{for},
4871     forp_arg => $self->{forp});
4872     __UNDEEP{
4873     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4874     DIS:uri => {$mt},
4875     DIS:sourceNode => {$res_name_node},
4876     }__;
4877     }__;
4878     }
4879     push @{$self->{$propName}}, $res_uri;
4880     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
4881     ($res_uri);
4882     push @$r, $res;
4883     $res-><M::ManakaiDISResourceDefinition.isReferred>
4884     ($res_name_node);
4885     }
4886     }__;
4887     }
4888     if ($recursiveISA) {
4889     __DEEP{
4890     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
4891     my @p_res = @$r;
4892     for my $p_res (@p_res) {
4893     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
4894     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
4895     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
4896     .getPropertyResourceList>
4897     (<Q::dis:ISA>, recursive_isa => true,
4898     ___recursive_isa_done => $opt{___recursive_isa_done},
4899     default_media_type => $defaultMediaType)};
4900     }
4901     }__;
4902     }
4903    
4904     @Method:
4905 wakaba 1.2 @@Name: addPropertyResourceList
4906     @@enDesc:
4907     Adds a resource to a resource-list property value.
4908     \
4909     {ISSUE:: Should an exception be thrown if the property is
4910     not of list?
4911     \
4912     }
4913 wakaba 1.10 \
4914     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
4915     an item clears the list --- i.e. the property values
4916     in the source tree will be ignored. Call
4917     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
4918     before adding to avoid this behavior.
4919     \
4920     }
4921 wakaba 1.2 @@PropNameParam:
4922     @@Param:
4923     @@@Name: res
4924     @@@Type: ManakaiDISResourceDefinition
4925     @@@enDesc:
4926     A resource to add.
4927     @@Return:
4928     @@@PerlDef:
4929     if (ref $self->{$propName} eq 'ARRAY') {
4930     push @{$self->{$propName}}, $res->{uri};
4931     } elsif (not defined $self->{$propName}) {
4932     $self->{$propName} = [$res->{uri}];
4933     }
4934    
4935 wakaba 1.3 ElementTypeBinding:
4936     @Name: PropNameParam
4937     @ElementType:
4938     dis:ResourceDef
4939     @ShadowContent:
4940     @@rdf:type:
4941     DISLang:MethodParameter
4942     @@Name: propName
4943     @@Type: ResourceURI
4944     @@Description:
4945     @@@lang:en
4946     @@@@:
4947     The name of the property.
4948    
4949 wakaba 1.2 ##DISPropertyAccessor
4950    
4951     PropDef:
4952     @QName:isAnon
4953     @Description:
4954     @@lang:en
4955     @@@:
4956     Whether the subject resource is anonymous or not.
4957     @Type:
4958     DOMMain:boolean
4959    
4960     PropDef:
4961     @QName:isDefined
4962     @Description:
4963     @@lang:en
4964     @@@:
4965     Whether the subject resource is defined or not.
4966    
4967     PropDef:
4968 wakaba 1.3 @QName:isReferred
4969 wakaba 1.2 @Description:
4970     @@lang:en
4971     @@@:
4972     Whether the subject resource is referred or not.
4973     @Type:
4974     DOMMain:any
4975    
4976     PropDef:
4977     @QName:definingModule
4978     @Description:
4979     @@lang:en
4980     @@@:
4981     The <QUOTE::dis> module in which the subject resource is defined.
4982     @rdfs:domain:
4983     DISCore:Module
4984 wakaba 1.1
4985     ## -- Datatypes
4986    
4987     URITypeDef:
4988 wakaba 1.3 @QName: AnyURI
4989     @Description:
4990     @@lang:en
4991     @@@:
4992     Any URI references.
4993    
4994     URITypeDef:
4995     @QName: FileURI
4996     @enDesc:
4997     URI references identifying file.
4998    
4999     URITypeDef:
5000 wakaba 1.1 @QName: ForURI
5001     @Description:
5002     @@lang:en
5003     @@@:
5004     <QUOTE::For> URI references.
5005    
5006     DataTypeDef:
5007     @QName: ForURIList
5008     @Description:
5009     @@lang:en
5010     @@@:
5011     References to the array containing <QUOTE::for> URI references.
5012    
5013     URITypeDef:
5014 wakaba 1.3 @QName: ResourceURI
5015     @Description:
5016     @@lang:en
5017     @@@:
5018     A URI reference for a <QUOTE::dis> resource.
5019    
5020     URITypeDef:
5021 wakaba 1.1 @QName: MediaTypeURI
5022     @Description:
5023     @@lang:en
5024     @@@:
5025     Media type URI references.
5026 wakaba 1.3 @rdfs:subClassOf: ResourceURI
5027    
5028     URITypeDef:
5029     @QName: ModuleURI
5030     @enDesc:
5031     URI references for <QUOET::dis> modules.
5032     @rdfs:subClassOf: ResourceURI
5033    
5034     URITypeDef:
5035     @QName: NameURI
5036     @enDesc:
5037     URI references identifying a resource.
5038     @rdfs:subClassOf: ResourceURI
5039 wakaba 1.10
5040     DataTypeDef:
5041     @QName: ResourceList
5042     @enDesc:
5043     References to array containing resource definition objects.
5044     @rdfs:subClassOf:
5045     Perl:ARRAY::ManakaiDOM:all
5046 wakaba 1.3
5047     ElementTypeBinding:
5048     @Name: DataTypeDef
5049     @ElementType:
5050     dis:ResourceDef
5051     @ShadowContent:
5052     @@rdf:type:
5053     ManakaiDOM:DataType
5054    
5055     ElementTypeBinding:
5056     @Name: URITypeDef
5057     @ElementType:
5058     dis:ResourceDef
5059     @ShadowContent:
5060     @@rdf:type:
5061     ManakaiDOM:DataType
5062     @@rdfs:subClassOf: AnyURI
5063 wakaba 1.1
5064     ## -- Exceptions
5065    
5066     XParamDef:
5067 wakaba 1.5 @QName: anotherSourceNode
5068     @enDesc:
5069     Another source node in which an error has occurred. In cases
5070     of <QUOTE::already defined> errors, it is the node that
5071     defines the resource first.
5072     @Type: ManakaiDISNode
5073 wakaba 1.3
5074 wakaba 1.12 ResourceDef:
5075     @QName: UNDECLARED_NS_PREFIX_ERR
5076     @For: ForLatest
5077     @AliasFor:
5078     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
5079    
5080 wakaba 1.3 ExceptionDef:
5081     @ClsQName: ManakaiDISException
5082     @enDesc:
5083     Exceptions for the <QUOTE::dis> operations.
5084 wakaba 1.4 @ClsISA:
5085     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
5086 wakaba 1.3 @XConstGroupDef:
5087     @@ClsQName: ManakaiDISExceptionCode
5088     @@enDesc:
5089     Exception codes for <Class::ManakaiDISException>.
5090     @@XConstDef:
5091 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
5092     @@@Value:3
5093     @@@enDesc:
5094     An attempt is made to break the hierarchy.
5095     @@@XSubTypeDef:
5096     @@@@QName: MERGE_ITSELF_ERR
5097     @@@@enDesc:
5098     An attempt is made to merge the resource to itself.
5099     @@@@XSourceNodeParam:
5100     @@@@XParam:
5101     @@@@@QName:uri
5102     @@@@@enDesc:
5103     The URI reference of the resource to merge.
5104     @@@@enMufDef:
5105     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
5106     );> to itself
5107     @@XConstDef:
5108 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
5109     @@@Value:9
5110     @@@enDesc:
5111     An attempt is made to do something the implementation does not support.
5112     @@@XSubTypeDef:
5113     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
5114     @@@@enDesc:
5115     The implementation does not support the media type.
5116     @@@@XParam:
5117     @@@@@QName: uri
5118     @@@@@enDesc:
5119     The URI reference of the media type that is not supported.
5120     @@@@XSourceNodeParam:
5121 wakaba 1.12 @@@@enMufDef:
5122     Media type <%p (name => {<Q::DIS:uri>});> is not supported
5123 wakaba 1.3 @@@XSubTypeDef:
5124 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
5125     @@@@enDesc:
5126     An unsupported type of element is encounted.
5127     @@@@XSourceNodeParam:
5128     @@@@XParam:
5129     @@@@@QName:elementType
5130     @@@@@enDesc:
5131     The element type URI reference of the element.
5132     @@@XSubTypeDef:
5133 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
5134 wakaba 1.3 @@@@enDesc:
5135 wakaba 1.12 There is no implementation that supports the
5136     <Feature::Util:PerlCode> feature, version
5137     <FeatureVer::1.0>.
5138 wakaba 1.3 @@XConstDef:
5139     @@@Name: INVALID_STATE_ERR
5140     @@@Value:11
5141     @@@enDesc:
5142     An attempt is made to use an object that is not (or no longer) usable.
5143     @@@XSubTypeDef:
5144     @@@@QName: NO_ASSOCIATED_DB_ERR
5145     @@@@enDesc:
5146     No <QUOTE::dis> database has been associated with this document.
5147 wakaba 1.4 @@XConstDef:
5148     @@@Name: INVALID_SOURCE_ERR
5149     @@@Value: 200
5150     @@@enDesc:
5151     The source input is well-formed but invalid.
5152     @@@XSubTypeDef:
5153     @@@@QName: NO_MODULE_QNAME_ERR
5154     @@@@enDesc:
5155     The <Q::dis:Module> element must have its <Q::dis:QName>
5156     attribute.
5157 wakaba 1.8 @@@@XSourceNodeParam:
5158     @@@XSubTypeDef:
5159     @@@@QName: NO_LOCAL_NAME_ERR
5160     @@@@enDesc:
5161     The resource does not have a local name.
5162     @@@@XSourceNodeParam:
5163 wakaba 1.4 @@@XSubTypeDef:
5164     @@@@QName: UNABLE_TO_GET_MODULE_ERR
5165     @@@@enDesc:
5166     The implementation is unable to get the module source.
5167     @@@@Def:
5168     @@@@@ContentType:
5169     lang:muf
5170     @@@@@lang:en
5171     @@@@@@:
5172     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
5173     @@@@XParam:
5174     @@@@@QName: uri
5175     @@@@@enDesc:
5176     The URI reference of the module.
5177     @@@@XParam:
5178     @@@@@QName: namespaceURI
5179     @@@@@enDesc:
5180     The namespace URI of the module name.
5181     @@@@XParam:
5182     @@@@@QName: localName
5183     @@@@@enDesc:
5184     The local name of the module name.
5185     @@@@XParam:
5186     @@@@@QName: for
5187     @@@@@enDesc:
5188     The <QUOTE::for> of the module.
5189 wakaba 1.5 @@@XSubTypeDef:
5190     @@@@QName: NO_FOR_QNAME_ERR
5191     @@@@enDesc:
5192     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
5193     @@@@XSourceNodeParam:
5194     @@@XSubTypeDef:
5195     @@@@QName: FOR_ALREADY_DEFINED_ERR
5196     @@@@enDesc:
5197     The <QUOTE::for> named as the same URI reference has
5198     already defined.
5199     @@@@XSourceNodeParam:
5200     @@@@XParam:
5201     @@@@@QName: anotherSourceNode
5202     @@@@@enDesc:
5203     The node that defines the <QUOTE::for> URI reference before.
5204 wakaba 1.7 @@@@XParam:
5205     @@@@@Name: uri
5206     @@@@@enDesc:
5207     The URI reference of the <QUOTE::for> attempted to define.
5208     @@@@enMufDef:
5209     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
5210 wakaba 1.5 @@@XSubTypeDef:
5211     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
5212     @@@@enDesc:
5213     The <QUOTE::dis> resource named as the same URI reference has
5214     already defined.
5215     @@@@XSourceNodeParam:
5216     @@@@XParam:
5217     @@@@@QName: anotherSourceNode
5218     @@@@@enDesc:
5219     The node that defines the <QUOTE::for> URI reference before.
5220 wakaba 1.7 @@@@XParam:
5221     @@@@@Name: uri
5222     @@@@@enDesc:
5223     The URI reference of the resource attempted to define.
5224     @@@@enMufDef:
5225     Resource <%p (name => {<Q::DIS:uri>});> is already defined
5226 wakaba 1.5 @@@XSubTypeDef:
5227     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
5228     @@@@enDesc:
5229     An element has occured where it is not allowed.
5230     @@@@enMufDef:
5231     Module <%p (name => {<Q::DIS:uri>});>:
5232     Element of type <%p (name => {<Q::DIS:elementType>});>
5233     is not allowed here
5234     @@@@XSourceNodeParam:
5235     @@@@XParam:
5236     @@@@@QName: elementType
5237     @@@@@enDesc:
5238     The expanded element type name of the element.
5239     @@@@XParam:
5240     @@@@@QName: uri
5241     @@@@@enDesc:
5242     The URI reference of the module.
5243 wakaba 1.7 @@@XSubTypeDef:
5244     @@@@QName: NO_REQUIRED_ATTR_ERR
5245     @@@@enDesc:
5246     A required attribute is not specified.
5247     @@@@XSourceNodeParam:
5248     @@@@XParam:
5249     @@@@@QName: elementType
5250     @@@@@enDesc:
5251     The expanded URI reference of the attribute name.
5252     @@@@enMufDef:
5253     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
5254 wakaba 1.8 @@@XSubTypeDef:
5255     @@@@QName: FOR_NOT_DEFINED_ERR
5256     @@@@enDesc:
5257     A <QUOTE::for> is referred but not defined.
5258     @@@@XSourceNodeParam:
5259     @@@@XParam:
5260     @@@@@QName: uri
5261     @@@@@enDesc:
5262     The URI reference of the <QUOTE::for> that is not defined.
5263     @@@@enMufDef:
5264     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
5265     @@@XSubTypeDef:
5266     @@@@QName: RESOURCE_NOT_DEFINED_ERR
5267     @@@@enDesc:
5268 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
5269     or the resource referred does not have the type expected.
5270 wakaba 1.8 @@@@XSourceNodeParam:
5271     @@@@XParam:
5272     @@@@@QName: uri
5273     @@@@@enDesc:
5274     The URI reference of the resource that is not defined.
5275 wakaba 1.13 @@@@XParam:
5276     @@@@@QName: elementType
5277     @@@@@enDesc:
5278     <QUOTE::dis> element type (either tree element type
5279     or preprocessing element type) of the element
5280     in which a reference to the undefined resource is contained.
5281     @@@@XParam:
5282     @@@@@QName: localName
5283     @@@@@enDesc:
5284     The local name of the undefined resource.
5285     @@@@XParam:
5286     @@@@QName: sourceCode
5287     @@@@enDesc:
5288     Source code fragment that referres this resource.
5289     @@@@XParam:
5290     @@@@@QName:expectedType
5291     @@@@@enDesc:
5292     Expected resource type.
5293 wakaba 1.8 @@@@enMufDef:
5294 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
5295     suffix => {>});%p (name => {<Q::DIS:localName>},
5296     prefix => { "}, suffix => {"}); is not defined or wrong type%p
5297     (name => {<Q::DIS:expectedType>}, prefix => { (<},
5298     suffix => {> is expected)});
5299     @@@XSubTypeDef:
5300     @@@@QName: NO_SOURCE_NODE_ERR
5301     @@@@enDesc:
5302     A resource does not have associated node in the source tree.
5303     @@@@XSourceNodeParam:
5304     @@@@XParam:
5305     @@@@@QName:uri
5306     @@@@@enDesc:
5307     The URI reference of the resource.
5308 wakaba 1.8 @@@XSubTypeDef:
5309     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
5310     @@@@enDesc:
5311     A reserved Perl method name is used.
5312     @@@@XParam:
5313     @@@@@QName:uri
5314     @@@@@enDesc:
5315     The URI reference of the method resource.
5316     @@@@XSourceNodeParam:
5317     @@@@XParam:
5318     @@@@@QName: generatedName
5319     @@@@@enDesc:
5320     A reserved method name.
5321     @@@XSubTypeDef:
5322     @@@@QName: NO_DIS_TYPE_ERR
5323     @@@@enDesc:
5324     <Q::dis:Type> attribute is not found.
5325     @@@@XSourceNodeParam:
5326 wakaba 1.12 @@@XSubTypeDef:
5327     @@@@QName: NO_METHOD_RETURN_ERR
5328     @@@@enDesc:
5329     A <Q::DISLang:Method> resource does not have any
5330     <Q::DISLang:MethodReturn> child.
5331     @@@@XSourceNodeParam:
5332     @@@XSubTypeDef:
5333     @@@@QName: NO_ATTR_GET_ERR
5334     @@@@enDesc:
5335     A <Q::DISLang:Attribute> resource does not have any
5336     <Q::DISLang:AttributeGet> child.
5337     @@@@XSourceNodeParam:
5338 wakaba 1.13 @@@XSubTypeDef:
5339     @@@@QName:INTERFACE_CLASS_METHOD_ERR
5340     @@@@enDesc:
5341     An attempt is made to call a static (class) method
5342     from an interface.
5343     @@@@XSourceNodeParam:
5344     @@@@XParam:
5345     @@@@@QName:uri
5346     @@@@@enDesc:
5347     The URI reference of the interface.
5348     @@@@XParam:
5349     @@@@@QName:sourceCode
5350     @@@@@enDesc:
5351     Source code fragment that calls a class method.
5352     @@@@XParam:
5353     @@@@@QName:elementType
5354     @@@@@enDesc:
5355     The element type URI reference of the element
5356     that calls a method.
5357     @@@XSubTypeDef:
5358     @@@@QName: BROKEN_PARAM_SPEC_ERR
5359     @@@@enDesc:
5360     A parameter specification is broken.
5361     @@@@XParam:
5362     @@@@@QName: sourceCode
5363     @@@@@enDesc:
5364     Source code fragment that contains the broken parameter
5365     specification.
5366     @@@@XSourceNodeParam:
5367     @@@XSubTypeDef:
5368     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
5369     @@@@enDesc:
5370     A preprocessing instruction does not have its element
5371     type.
5372     @@@@XSourceNodeParam:
5373     @@@@XParam:
5374     @@@@@QName:sourceCode
5375     @@@@@enDesc:
5376     Source code fragment.
5377     @@@XSubTypeDef:
5378     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
5379     @@@@enDesc:
5380     A preprocessing instruction requires Perl code
5381     fragment name but it is not specified.
5382     @@@@XSourceNodeParam:
5383     @@@@XParam:
5384     @@@@@QName: sourceCode
5385     @@@@@enDesc:
5386     Source code fragment.
5387     @@@@XParam:
5388     @@@@@QName:elementType
5389     @@@@@enDesc:
5390     The type of the element in which code name should have
5391     been specified.
5392     @@@XSubTypeDef:
5393     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
5394     @@@@enDesc:
5395     A resource does not have its Perl definition.
5396     @@@@XSourceNodeParam:
5397     @@@@XParam:
5398     @@@@@QName:sourceCode
5399     @@@@@enDesc:
5400     Source code fragment.
5401     @@@@XParam:
5402     @@@@@QName:localName
5403     @@@@@enDesc:
5404     The local name of the resource referred.
5405     @@@@XParam:
5406     @@@@@QName:uri
5407     @@@@@enDesc:
5408     The URI reference of the resource referred.
5409 wakaba 1.4 ##DISException
5410 wakaba 1.13
5411     XParamDef:
5412     @QName:expectedType
5413     @Type: ResourceURI
5414     @enDesc:
5415     Expected resource type URI reference.
5416    
5417     XParamDef:
5418     @QName: sourceCode
5419     @Type:
5420     DISLang:String::ManakaiDOM:all
5421     @enDesc:
5422     The source code fragment in which an error occurred.
5423 wakaba 1.5
5424     XParamDef:
5425     @QName: elementType
5426     @Type: ResourceURI
5427     @enDesc:
5428     The name of the element type.
5429    
5430     XParamDef:
5431     @QName: uri
5432     @Type: ResourceURI
5433     @enDesc:
5434     The name of the resource, composed from <Q::namespaceURI>,
5435     <Q::localName> and <Q::for>.
5436    
5437     XParamDef:
5438     @QName: localName
5439     @Type:
5440     DISCore:LocalName
5441     @enDesc:
5442     The local name of the resource, unique in <Q::namespaceURI> namespace.
5443    
5444     XParamDef:
5445     @QName: namespaceURI
5446     @Type: AnyURI
5447     @enDesc:
5448     The namespace URI reference of the resource name.
5449    
5450     XParamDef:
5451     @QName: for
5452     @Type: ForURI
5453     @enDesc:
5454     The <QUOTE::for> URI reference of the resource.
5455    
5456     ElementTypeBinding:
5457     @Name: XSourceNodeParam
5458     @ElementType:
5459     ManakaiDOM:exceptionOrWarningParameter
5460     @ShadowContent:
5461     @@QName: sourceNode
5462     @@Description:
5463     @@@lang:en
5464     @@@@:
5465     The node in which an error has occurred.
5466 wakaba 1.4
5467     ClsDef:
5468     @ClsQName: ManakaiDISExceptionTarget
5469     @enDesc:
5470     Objects that is able to be the target of an exception.
5471     @IntMethod:
5472     @@Operator:
5473     @@@@:
5474     ManakaiDOM:MUErrorHandler
5475     @@@ContentType:
5476     dis:TypeQName
5477     @@Description:
5478     @@@lang:en
5479     @@@@:
5480     This method is a generic error handler; all manakai exceptions
5481     and warnings associated to an object are once reported to this method
5482     and then delivered to appropriate entities.
5483     \
5484     If the error is an exception (such as <X::DOMCore:DOMException> or
5485     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
5486     simply thrown. If the error is only a warning, it is reported
5487     via the <IF::DOMCore:DOMError> interface.
5488     \
5489     See <PerlModule::Message::Util::Error> documentation for more
5490     information on the error reporting mechanism.
5491     \
5492     {NOTE:: This kind of methods are named as <Perl::___report_error>
5493     in the convention of <PerlModule::Message::Util::Error>.
5494     \
5495     }
5496     @@Param:
5497     @@@Name:err
5498     @@@Type:
5499     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
5500     @@@Description:
5501     @@@@lang:en
5502     @@@@@:
5503     An exception object that describes what kind of error it is
5504     and how it should be recovered.
5505     \
5506     {NOTE:: Exception objects in manakai implementation
5507     inherit the class <PerlModule::Message::Util::Error>,
5508     that in turn inherits <PerlModule::Error>.
5509     \
5510     }
5511     @@Return:
5512     @@@PerlDef:
5513     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
5514     ::ManakaiDOM:Perl>)) {
5515     $err->throw;
5516     } else {
5517     \## TODO: Implement warning reporting
5518     warn $err->stringify;
5519     }
5520     ##DISExceptionTarget
5521    
5522     ForDef:
5523     @QName:
5524     DIS:ForIF
5525     ForDef:
5526     @QName:
5527     DIS:ForClass
5528    
5529     ElementTypeBinding:
5530     @Name: IFClsDef
5531     @ElementType:
5532     dis:ResourceDef
5533     @ShadowContent:
5534     @@rdf:type:
5535     @@@@:
5536     dis:MultipleResource
5537     @@@ForCheck: !ForClass !ForIF
5538     @@rdf:type:
5539     @@@@:
5540     ManakaiDOM:IF
5541     @@@ForCheck: ForIF
5542     @@rdf:type:
5543     @@@@:
5544     ManakaiDOM:Class
5545     @@@ForCheck: ForClass
5546     @@resourceFor: ForIF
5547     @@resourceFor:
5548     @@@@: ForClass
5549     @@@ForCheck: ForLatest
5550     @@DOMMain:implementFeature:
5551     @@@@:CoreFeature10
5552     @@@ForCheck: ForClass
5553     @@ForCheck:
5554     ManakaiDOM:Perl
5555 wakaba 1.3
5556     ElementTypeBinding:
5557     @Name: ClsDef
5558     @ElementType:
5559     dis:ResourceDef
5560     @ShadowContent:
5561     @@rdf:type:
5562     ManakaiDOM:Class
5563     @@AliasFor:
5564     @@@@:
5565 wakaba 1.11 ::DIS:ForLatest
5566 wakaba 1.3 @@@For:
5567 wakaba 1.11 !=DIS:ForLatest
5568 wakaba 1.3 @@ForCheck:
5569     ManakaiDOM:Perl
5570     @@DOMMain:implementFeature: CoreFeature10
5571    
5572     ElementTypeBinding:
5573     @Name: ExceptionDef
5574     @ElementType:
5575     dis:ResourceDef
5576     @ShadowContent:
5577     @@rdf:type:
5578     ManakaiDOM:ExceptionClass
5579     @@AliasFor:
5580     @@@@:
5581     ::ForLatest
5582     @@@For:
5583     !=ForLatest
5584     @@ForCheck:
5585     ManakaiDOM:Perl
5586     @@DOMMain:implementFeature: CoreFeature10
5587    
5588     ElementTypeBinding:
5589     @Name: ClsQName
5590     @ElementType:
5591     dis:QName
5592    
5593     ElementTypeBinding:
5594     @Name: ClsISA
5595     @ElementType:
5596     dis:ISA
5597    
5598     ElementTypeBinding:
5599     @Name: Method
5600     @ElementType:
5601     dis:ResourceDef
5602     @ShadowContent:
5603     @@rdf:type:
5604     DISLang:Method
5605    
5606     ElementTypeBinding:
5607     @Name: IntMethod
5608     @ElementType:
5609     dis:ResourceDef
5610     @ShadowContent:
5611     @@rdf:type:
5612     DISLang:Method
5613     @@ManakaiDOM:isForInternal:1
5614    
5615     ElementTypeBinding:
5616     @Name: Attr
5617     @ElementType:
5618     dis:ResourceDef
5619     @ShadowContent:
5620     @@rdf:type:
5621     DISLang:Attribute
5622    
5623     ElementTypeBinding:
5624     @Name: Return
5625     @ElementType:
5626     dis:ResourceDef
5627     @ShadowContent:
5628     @@rdf:type:
5629     DISLang:MethodReturn
5630    
5631     ElementTypeBinding:
5632     @Name: Get
5633     @ElementType:
5634     dis:ResourceDef
5635     @ShadowContent:
5636     @@rdf:type:
5637     DISLang:AttributeGet
5638    
5639     ElementTypeBinding:
5640     @Name: Set
5641     @ElementType:
5642     dis:ResourceDef
5643     @ShadowContent:
5644     @@rdf:type:
5645     DISLang:AttributeSet
5646    
5647     ElementTypeBinding:
5648     @Name: Param
5649     @ElementType:
5650     dis:ResourceDef
5651     @ShadowContent:
5652     @@rdf:type:
5653     DISLang:MethodParameter
5654    
5655     ElementTypeBinding:
5656     @Name: PerlDef
5657     @ElementType:
5658     dis:Def
5659     @ShadowContent:
5660     @@ContentType:
5661     lang:Perl
5662    
5663     ElementTypeBinding:
5664     @Name: disDef
5665     @ElementType:
5666     dis:Def
5667     @ShadowContent:
5668     @@ContentType:
5669     lang:dis
5670    
5671     ElementTypeBinding:
5672     @Name: InCase
5673     @ElementType:
5674     dis:ResourceDef
5675     @ShadowContent:
5676     @@rdf:type:
5677     ManakaiDOM:InCase
5678    
5679     ElementTypeBinding:
5680     @Name: nullCase
5681     @ElementType:
5682     dis:ResourceDef
5683     @ShadowContent:
5684     @@rdf:type:
5685     ManakaiDOM:InCase
5686     @@Value:
5687     @@@is-null:1
5688    
5689     ElementTypeBinding:
5690     @Name: TrueCase
5691     @ElementType:
5692     dis:ResourceDef
5693     @ShadowContent:
5694     @@rdf:type:
5695     ManakaiDOM:InCase
5696     @@Value:true
5697     @@Type:
5698     DOMMain:boolean
5699    
5700    
5701     ElementTypeBinding:
5702     @Name: FalseCase
5703     @ElementType:
5704     dis:ResourceDef
5705     @ShadowContent:
5706     @@rdf:type:
5707     ManakaiDOM:InCase
5708     @@Value:false
5709     @@Type:
5710     DOMMain:boolean
5711    
5712     ElementTypeBinding:
5713     @Name: enDesc
5714     @ElementType:
5715     dis:Description
5716     @ShadowContent:
5717     @@lang:en
5718    
5719     ElementTypeBinding:
5720     @Name: PropDef
5721     @ElementType:
5722     dis:ResourceDef
5723     @ShadowContent:
5724     @@rdf:type:
5725     rdf:Property
5726     @@AliasFor:
5727     @@@@:
5728     ::ManakaiDOM:all
5729     @@@For:
5730     !=ManakaiDOM:all
5731    
5732     ElementTypeBinding:
5733     @Name: MethodRedef
5734     @ElementType:
5735     dis:ResourceDef
5736     @ShadowContent:
5737     @@rdf:type:
5738     DISLang:Method
5739     @@ManakaiDOM:isRedefining:1
5740    
5741     ElementTypeBinding:
5742     @Name: NamedParam
5743     @ElementType:
5744     dis:ResourceDef
5745     @ShadowContent:
5746     @@rdf:type:
5747     DISLang:MethodParameter
5748     @@DISPerl:isNamedParameter:1
5749    
5750     ElementTypeBinding:
5751     @Name: NodeParam
5752     @ElementType:
5753     dis:ResourceDef
5754     @ShadowContent:
5755     @@rdf:type:
5756     DISLang:MethodParameter
5757     @@DISPerl:isNamedParameter:1
5758     @@Name: node
5759     @@Type: ManakaiDISNode
5760     @@Description:
5761     @@@lang:en
5762     @@@@:
5763     The node in which the name has occurred. It is intended
5764     to be reported when an exception had been raised.
5765     @@ResourceDef:
5766     @@@rdf:type:
5767     ManakaiDOM:InCase
5768     @@@Value:
5769     @@@@is-null:1
5770     @@@Description:
5771     @@@@lang:en
5772     @@@@@:
5773     The source of the name is not a node.
5774    
5775     ElementTypeBinding:
5776     @Name: ForParam
5777     @ElementType:
5778     dis:ResourceDef
5779     @ShadowContent:
5780     @@rdf:type:
5781     DISLang:MethodParameter
5782     @@DISPerl:isNamedParameter:1
5783     @@Name: forArg
5784     @@Type: ForURI
5785     @@Description:
5786     @@@lang:en
5787     @@@@:
5788     The <QUOTE::for> URI reference.
5789     @@ResourceDef:
5790     @@@rdf:type:
5791     ManakaiDOM:InCase
5792     @@@Value:
5793     @@@@is-null:1
5794     @@@Description:
5795     @@@@lang:en
5796     @@@@@:
5797     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
5798    
5799     ElementTypeBinding:
5800     @Name: ForpParam
5801     @ElementType:
5802     dis:ResourceDef
5803     @ShadowContent:
5804     @@rdf:type:
5805     DISLang:MethodParameter
5806     @@DISPerl:isNamedParameter:1
5807     @@Name: forpArg
5808     @@Type: ForURIList
5809     @@Description:
5810     @@@lang:en
5811     @@@@:
5812     An array reference containing additional <QUOTE::for>
5813     constraints (<QUOTE::For+> list).
5814     @@ResourceDef:
5815     @@@rdf:type:
5816     ManakaiDOM:InCase
5817     @@@Value:
5818     @@@@is-null:1
5819     @@@Description:
5820     @@@@lang:en
5821     @@@@@:
5822     Equivalent to the empty array reference.
5823    
5824     ElementTypeBinding:
5825     @Name: MediaTypeParam
5826     @ElementType:
5827     dis:ResourceDef
5828     @ShadowContent:
5829     @@rdf:type:
5830     DISLang:MethodParameter
5831     @@DISPerl:isNamedParameter:1
5832     @@Name: mediaType
5833     @@Type: MediaTypeURI
5834     @@Description:
5835     @@@lang:en
5836     @@@@:
5837     The URI reference identifying a media type.
5838     @@ResourceDef:
5839     @@@rdf:type:
5840     ManakaiDOM:InCase
5841     @@@Value:
5842     @@@@is-null:1
5843     @@@Description:
5844     @@@@lang:en
5845     @@@@@:
5846     No media type specified.
5847    
5848     ElementTypeBinding:
5849     @Name: MediaTypeDefaultParam
5850     @ElementType:
5851     dis:ResourceDef
5852     @ShadowContent:
5853     @@rdf:type:
5854     DISLang:MethodParameter
5855     @@DISPerl:isNamedParameter:1
5856     @@Name: defaultMediaType
5857     @@Type: MediaTypeURI
5858     @@Description:
5859     @@@lang:en
5860     @@@@:
5861     The default media type, i.e. the type used when no explicit
5862     specification is not found in the source tree.
5863     @@ResourceDef:
5864     @@@rdf:type:
5865     ManakaiDOM:InCase
5866     @@@Value:
5867     @@@@is-null:1
5868     @@@Description:
5869     @@@@lang:en
5870     @@@@@:
5871     Defaulted to <Q::DOMMain:any>.
5872    
5873     ElementTypeBinding:
5874     @Name: RaiseException
5875     @ElementType:
5876     ManakaiDOM:raises
5877    
5878     ElementTypeBinding:
5879     @Name: UndeclaredPrefixException
5880     @ElementType:
5881     ManakaiDOM:raises
5882     @ShadowContent:
5883     @@@: UNDECLARED_NS_PREFIX_ERR
5884     @@Description:
5885     @@@lang:en
5886     @@@@:
5887     The implementation has encounted an undeclared namespace prefix.
5888    
5889     ElementTypeBinding:
5890     @Name: NoDBException
5891     @ElementType:
5892     ManakaiDOM:raises
5893     @ShadowContent:
5894     @@@: NO_DB_ASSOCIATED_ERR
5895     @@Description:
5896     @@@lang:en
5897     @@@@:
5898     No <QUOTE::dis> database is associated to this document.
5899    
5900     ElementTypeBinding:
5901     @Name: XConstGroupDef
5902     @ElementType:
5903     dis:ResourceDef
5904     @ShadowContent:
5905     @@rdf:type:
5906     ManakaiDOM:ConstGroup
5907     @@Type:
5908     DOMMain:unsigned-short::ManakaiDOM:all
5909     @@rdfs:subClassOf:
5910     DOMMain:unsigned-short::ManakaiDOM:all
5911    
5912     ElementTypeBinding:
5913     @Name: XConstDef
5914     @ElementType:
5915     dis:ResourceDef
5916     @ShadowContent:
5917     @@rdf:type:
5918     ManakaiDOM:Const
5919    
5920     ElementTypeBinding:
5921     @Name: XSubTypeDef
5922     @ElementType:
5923     dis:ResourceDef
5924     @ShadowContent:
5925     @@rdf:type:
5926     ManakaiDOM:ExceptionOrWarningSubType
5927    
5928     ElementTypeBinding:
5929     @Name: XParam
5930     @ElementType:
5931     ManakaiDOM:exceptionOrWarningParameter
5932    
5933     ElementTypeBinding:
5934     @Name: XParamDef
5935     @ElementType:
5936     dis:ResourceDef
5937     @ShadowContent:
5938     @@rdf:type:
5939     DOMMain:XWParameter
5940 wakaba 1.12 @@For:
5941     =ManakaiDOM:all
5942 wakaba 1.3
5943     ElementTypeBinding:
5944     @Name: enMufDef
5945     @ElementType:
5946     dis:Def
5947     @ShadowContent:
5948     @@ContentType:
5949     lang:muf
5950     @@lang:en
5951    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24