/[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.14 - (hide annotations) (download)
Wed Mar 30 03:16:43 2005 UTC (20 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.13: +151 -94 lines
plPreprocessStatement now works

1 wakaba 1.1 Module:
2     @QName:
3     Util:DIS
4     @FullName:
5     @@lang: en
6     @@@:
7     <QUOTE::DIS> Object Model
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
10    
11     @Description:
12     @@lang:en
13     @@@:
14 wakaba 1.14 This module provides an object model for <QUOTE::dis> document format.
15 wakaba 1.1
16     @Author:
17     @@FullName: Wakaba
18     @@Mail: w@suika.fam.cx
19     @License:
20     @@@:
21     license:Perl+MPL
22     @@Original:
23     @@@FullName:
24     manakai <CODE::lib/manakai/dis.pl>
25     @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.14 $Date: 2005/03/16 09:08:13 $
32 wakaba 1.1 @@ContentType:
33     dis:Date.RCS
34    
35     @Require:
36     @@Module:
37     @@@Name: SuikaWikiConfig21
38 wakaba 1.5 @@@QName:
39     Markup:SuikaWikiConfig21
40 wakaba 1.1 @@@WithFor:
41 wakaba 1.3 swcfg21:ForLatest
42     @@Module:
43     @@@Name: DIS
44     @@@WithFor:
45     DIS:ForLatest
46 wakaba 1.12 @@Module:
47     @@@Name: PerlCode
48     @@@WithFor:
49     ManakaiDOM:Perl
50 wakaba 1.3
51     @DefaultFor:
52     DIS:ForLatest
53 wakaba 1.1
54     Namespace:
55     @DIS:
56     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
57     @dis:
58     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
59     @dis2pm:
60     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
61 wakaba 1.5 @DISlib:
62     http://suika.fam.cx/~wakaba/archive/2004/dis/
63 wakaba 1.13 @disPerl:
64     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--Perl--
65 wakaba 1.3 @DOMCore:
66     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
67     @DOMLS:
68     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
69     @DOMMain:
70     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
71     @infoset:
72     http://www.w3.org/2001/04/infoset#
73 wakaba 1.1 @lang:
74     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
75     @license:
76     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
77     @ManakaiDOM:
78     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
79 wakaba 1.5 @Markup:
80     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
81 wakaba 1.3 @MDOMX:
82     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
83 wakaba 1.1 @owl:
84     http://www.w3.org/2002/07/owl#
85     @Perl:
86     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
87     @rdf:
88     http://www.w3.org/1999/02/22-rdf-syntax-ns#
89     @rdfs:
90     http://www.w3.org/2000/01/rdf-schema#
91 wakaba 1.3 @swcfg21:
92     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
93 wakaba 1.1 @TreeCore:\
94     @Util:
95     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
96    
97     ## -- "For" definitions
98    
99     ForDef:
100     @QName:
101     DIS:ForLatest
102     @Description:
103     @@lang:en
104     @@@:
105     For latest version of the <Module::Util:DIS> module implementation
106     @ISA:
107     ManakaiDOM:Perl
108    
109     ## -- Features
110    
111     ElementTypeBinding:
112     @Name: FeatureDef
113     @ElementType:
114     dis:ResourceDef
115     @ShadowContent:
116     @@rdf:type:
117     DOMMain:DOMFeature
118     @@AliasFor:
119     @@@@:
120     ::ManakaiDOM:all
121     @@@For:
122     !=ManakaiDOM:all
123    
124     ElementTypeBinding:
125     @Name: FeatureVerDef
126     @ElementType:
127     dis:ResourceDef
128     @ShadowContent:
129     @@rdf:type:
130     DOMMain:DOMFeature
131    
132     ElementTypeBinding:
133     @Name: featureQName
134     @ElementType:
135     dis:AppName
136     @ShadowContent:
137     @@ContentType:
138     dis:TypeQName
139    
140     FeatureDef:
141     @QName: Core
142     @FeatureVerDef:
143     @@QName: CoreFeature10
144     @@Version: 1.0
145     @@ISA: Core
146     @@FullName:
147     @@@lang:en
148     @@@@:
149     The <QUOTE::dis> object model, version 1.0
150     @@Description:
151     @@@lang:en
152     @@@@:
153     The <QUOTE::dis> object model, version 1.0.
154     @@DOMMain:requireFeature:
155     swcfg21:CoreFeature21
156    
157     ## -- SuikaWikiConfig/2.1 extended classes
158    
159     ClsDef:
160     @ClsQName: ManakaiDISImplementation
161     @ClsISA:
162 wakaba 1.3 swcfg21:ManakaiSWCFGImplementation::swcfg21:ForLatest
163 wakaba 1.1 @Description:
164     @@lang:en
165     @@@:
166     A <QUOTE::dis> implementation object.
167    
168     @Method:
169     @@Name: createDISDocument
170     @@Description:
171     @@@lang:en
172     @@@@:
173     Creates an empty <Class::ManakaiDISDocument> object.
174     @@Return:
175     @@@Type:ManakaiDISDocument
176     @@@Description:
177     @@@@lang:en
178     @@@@@:
179     The newly created <QUOTE::dis> document object.
180     @@@PerlDef:
181 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
182     .createSWCFGDocument>;
183     $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
184     .defaultElementTypeNamespaceURI>
185 wakaba 1.1 (<Q::dis:>);
186    
187     @Method:
188 wakaba 1.2 @@Name: createDISParser
189     @@Description:
190     @@@lang:en
191     @@@@:
192 wakaba 1.1 Creates a <Class::ManakaiDISParser> object.
193 wakaba 1.2 @@Return:
194     @@@Type: ManakaiDISParser
195     @@@Description:
196     @@@@lang:en
197     @@@@@:
198 wakaba 1.1 A newly created <QUOTE::dis> parser.
199 wakaba 1.2 @@@PerlDef:
200 wakaba 1.3 $r = bless $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
201     .createSWCFGParser>,
202 wakaba 1.1 <ClassName::ManakaiDISParser>;
203    
204     @Method:
205 wakaba 1.2 @@Name: createDISDatabase
206 wakaba 1.1 @@Description:
207     @@@lang:en
208     @@@@:
209 wakaba 1.2 Creates a new <QUOTE::dis> database.
210 wakaba 1.1 @@Return:
211 wakaba 1.2 @@@Type:ManakaiDISDatabase
212 wakaba 1.4 @@@Description:
213     @@@@lang:en
214     @@@@@:
215 wakaba 1.2 A newly created <QUOTE::dis> parser.
216 wakaba 1.4 @@@PerlDef:
217 wakaba 1.2 $r = bless {
218     forDef => {
219 wakaba 1.5 <Q::ManakaiDOM:all> => bless ({
220 wakaba 1.2 uri => <Q::ManakaiDOM:all>,
221     isa => {<Q::ManakaiDOM:all> => 1},
222     revISA => {},
223 wakaba 1.5 }, <ClassName::ManakaiDISForDefinition>),
224 wakaba 1.2 },
225     resDef => {},
226 wakaba 1.9 modDef => {},
227     seq => 0,
228 wakaba 1.3 }, <ClassName::ManakaiDISDatabase>;
229    
230     @Method:
231     @@Name: tfurisToURI
232     @@Description:
233     @@@lang:en
234     @@@@:
235     Converts a pair of name URI reference and <QUOTE::for> URI reference
236     into a <TYPE::dis:TFQNames>-expanded URI reference.
237     @@Param:
238     @@@Name: typeURI
239     @@@Type: NameURI
240     @@@Description:
241     @@@@lang:en
242     @@@@@:
243     A URI reference to identify a resource.
244     @@@InCase:
245     @@@@Value:
246     @@@@@is-null:1
247     @@@@Description:
248     @@@@@lang:en
249     @@@@@@:
250     Equivalent to <Q::DOMMain:any> (for historical reason).
251     @@Param:
252     @@@Name: forURI
253     @@@Type: ForURI
254     @@@Description:
255     @@@@lang:en
256     @@@@@:
257     A <QUOTE::for> URI reference.
258     @@@InCase:
259     @@@@Value:
260     @@@@@is-null:1
261     @@@@Description:
262     @@@@@lang:en
263     @@@@@@:
264     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
265     @@Return:
266     @@@Type:
267     DISCore:TFURI::ManakaiDOM:all
268     @@@Description:
269     @@@@lang:en
270     @@@@@:
271     The <TYPE::dis:TFQNames>-expanded URI references.
272     @@@PerlDef:
273     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
274     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
275 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
276    
277     @ResourceDef:
278     @@QName: tfurisToURI
279     @@rdf:type:
280     dis2pm:BlockCode
281     @@enDesc:
282     Converts a pair of name URI reference and <QUOTE::for> URI reference
283     into a <TYPE::dis:TFQNames>-expanded URI reference.
284     @@PerlDef:
285     if ($furi eq <Q::ManakaiDOM:all>) {
286     $uri = $turi;
287 wakaba 1.3 } else {
288     ## NOTE: [RFC 3986]
289     ## fragment := *(pchar / "/" / "?")
290     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
291     ## unreserved := ALPHA / DIGIT / [._~-]
292     ## sub-delims := [!$&'()*+,;=]
293     ## NOTE: [XPointer Framework]
294     ## SchemeData := *EscapedData
295     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
296     ## / "(" SchemeData ")"
297     ## NormalChar := UnicodeChar - [()^]
298 wakaba 1.5 my $__turi = $turi;
299     my $__furi = $furi;
300     for my $__uri ($__turi, $__furi) {
301 wakaba 1.4 $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
302 wakaba 1.3 }
303 wakaba 1.4 $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
304 wakaba 1.5 qq<t:tf($__turi,$__furi)>;
305 wakaba 1.3 }
306 wakaba 1.2
307 wakaba 1.5 @ResourceDef:
308 wakaba 1.6 @@QName: tfpurisToURI
309     @@rdf:type:
310     dis2pm:BlockCode
311     @@enDesc:
312     Converts a set of name URI reference and <QUOTE::for> URI reference
313     and <QUOTE::for+> URI references into a URi reference.
314     @@PerlDef:
315     if ($furi eq <Q::ManakaiDOM:all> and @{$forp} == 0) {
316     $uri = $turi;
317     } elsif (@{$forp}) {
318     my $__turi = $turi;
319     my $__furi = $furi;
320     for my $__uri ($__turi, $__furi) {
321     $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
322     }
323     my @__fp;
324     for my $__uri (@{$forp}) {
325     my $__fpuri = $__uri;
326     $__fpuri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}
327     {sprintf '%%%02X', ord $1}ge;
328     push @__fp, $__fpuri;
329     }
330     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
331     qq<t:tfp($__turi,$__furi,>.join (',', @__fp).q<)>;
332     } else {
333     my $__turi = $turi;
334     my $__furi = $furi;
335     for my $__uri ($__turi, $__furi) {
336     $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
337     }
338     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
339     qq<t:tf($__turi,$__furi)>;
340     }
341    
342     @ResourceDef:
343 wakaba 1.5 @@QName: getChildResourceURI
344     @@rdf:type:
345     dis2pm:BlockCode
346     @@enDesc:
347     Gets an anonymous URI reference of a child resource of another
348     resource.
349     @@PerlDef:
350     my $__parent = $parentURI;
351     my $__ln = $localName;
352     for my $__uri ($__parent, $__ln) {
353 wakaba 1.6 $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
354 wakaba 1.5 }
355     $result = q<data:,200411tf#xmlns(t=data:,200411tf%23)>.
356     qq<t:child($__parent,$__ln)>;
357    
358 wakaba 1.8 @IntMethod:
359     @@Name: camelCaseToUnderscoreName
360     @@enDesc:
361     Converts a camelCase name to a underscored_name.
362     @@ManakaiDOM:isStatic:1
363     @@Param:
364     @@@Name: camelName
365     @@@Type:
366     DISLang:String
367     @@@enDesc:
368     The source name.
369     @@Return:
370     @@@Type:
371     DISLang:String
372     @@@enDesc:
373     The result name.
374     @@@PerlDef:
375     $r = $camelName;
376     $r =~ s/^([A-Z0-9]+)$/lc $1/ge;
377     $r =~ s/([A-Z][A-Z0-9]*)$/"_".lc $1/ge;
378     $r =~ s/([A-Z0-9])([A-Z0-9]*)([A-Z0-9])/$1.lc ($2)."_".lc $3/ge;
379     $r =~ s/([A-Z])/"_".lc $1/ge;
380     $r =~ s/(?=[0-9](?!$))/_/g;
381 wakaba 1.9
382     @Method:
383     @@Name: plLoadDISDatabase
384     @@enDesc:
385     Loads a database from a file that was saved by
386     <M::ManakaiDISDatabase.plStore>.
387     \
388     {NOTE:: <QUOTE::dis> documents restored from external file
389     would have different <A::ManakaiDISDocument.implementation>
390     than this <Class::ManakaiDISImplementation>, even if
391     it has been created by this implementation
392     and stored in the same session.
393     \
394     }
395     @@Param:
396     @@@Name:fileName
397     @@@Type:
398     DISLang:String
399     @@@enDesc:
400     An environment-dependent file name.
401     @@Return:
402     @@@Type: ManakaiDISDatabase
403     @@@SimpleException:
404     @@@PerlDef:
405     use Storable qw/retrieve/;
406     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
407     $r = retrieve $fileName;
408    
409     ## Restores weak references
410     require Scalar::Util;
411     for my $doc (values %{$r->{<Q::DIS:sourceFile>}}) {
412     Scalar::Util::weaken ($doc->{<Q::TreeCore:node>}->{<Q::DIS:db>});
413     }
414     for my $def (values %{$r->{modDef}},
415     values %{$r->{forDef}},
416     values %{$r->{resDef}}) {
417     Scalar::Util::weaken ($def->{db});
418     }
419 wakaba 1.1 ##DISImplementation
420    
421 wakaba 1.9 ElementTypeBinding:
422     @Name: SimpleException
423     @ElementType:
424     dis:Description
425     @ShadowContent:
426     @@lang:en
427     @@@:
428     - Exception of type <PerlModule::Error::Simple>:::
429     I/O error or other error reported by <PerlModule::Storable>.
430    
431     ## TODO: Formal description required for simple exception
432    
433 wakaba 1.1 ClsDef:
434     @ClsQName: ManakaiDISParser
435     @ClsISA:
436 wakaba 1.3 swcfg21:ManakaiSWCFGParser::swcfg21:ForLatest
437 wakaba 1.1 @Description:
438     @@lang:en
439     @@@:
440     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
441     @Method:
442 wakaba 1.3 @@Name: parse
443     @@Description:
444     @@@lang:en
445     @@@@:
446 wakaba 1.1 Parses a <QUOTE::dis> document and returns it as an object tree.
447 wakaba 1.3 @@Param:
448     @@@Name: input
449     @@@Type:
450     DOMLS:LSInput::ManakaiDOM:ManakaiDOM3
451     @@@Description:
452     @@@@lang:en
453     @@@@@:
454 wakaba 1.1 The input source.
455 wakaba 1.3 @@Return:
456     @@@Type: ManakaiDISDocument
457     @@@Description:
458     @@@@lang:en
459     @@@@@:
460 wakaba 1.1 The <QUOTE::dis> document object created from the <P::input>.
461     @@@RaiseException:
462     @@@@@:
463     swcfg21:SWCFG_PARSE_ERR
464     @@@@Description:
465     @@@@@lang:en
466     @@@@@@:
467     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
468     document.
469     @@@PerlDef:
470     __DEEP{
471 wakaba 1.3 $r = $self-><M::swcfg21:ManakaiSWCFGParser
472     ::swcfg21:ForLatest.parse> ($input);
473 wakaba 1.1 }__;
474     if (defined $r) {
475     $r = bless $r, <ClassName::ManakaiDISDocument>;
476 wakaba 1.4 $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
477     .defaultElementTypeNamespaceURI>
478     (<Q::dis:>);
479 wakaba 1.1 }
480     ##DISParser
481    
482     ClsDef:
483     @ClsQName: ManakaiDISNode
484     @Description:
485     @@lang:en
486     @@@:
487     <QUOTE::dis> node objects.
488 wakaba 1.7 @ImplNote:
489     @@lang:en
490     @@@:
491     This class does not inherit
492     <Class::swcfg21:ManakaiSWCFGNode::swcfg21:ForLatest>, since
493     inheriting classes such as <Class::ManakaiDISElement> indirectly
494     inherit it.
495 wakaba 1.1
496     @MethodRedef:
497     @@Name:lookupNamespacePrefix
498     @@Description:
499     @@@lang:en
500     @@@@:
501     Looks up the namespace prefix associated to the given
502     namespace URI. The default namespaces are ignored.
503     @@Param:
504     @@@Name:namespaceURI
505 wakaba 1.3 @@@Type: AnyURI
506 wakaba 1.1 @@@Description:
507     @@@@lang:en
508     @@@@@:
509     The namespace URI to look for.
510     @@@InCase:
511     @@@@Value:
512     @@@@@is-null:1
513     @@@@Description:
514     @@@@@lang:en
515     @@@@@@:
516     The <DOM::null> namespace.
517     @@NamedParam:
518     @@@Name: makeNewBinding
519     @@@Type:
520     DOMMain:boolean
521     @@@Description:
522     @@@@lang:en
523     @@@@@:
524     Whether a new namespace prefix should be bound when
525     no namespace URI has been associated yet.
526     @@@InCase:
527     @@@@Value:true
528     @@@@Description:
529     @@@@@lang:en
530     @@@@@@:
531     New binding is made if no prefix associated.
532     @@@InCase:
533     @@@@Value:false
534     @@@@Description:
535     @@@@@lang:en
536     @@@@@@:
537     Simply returns the <DOM::null> if no prefix associated.
538     @@Return:
539     @@@Type:
540 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
541 wakaba 1.1 @@@Description:
542     @@@@lang:en
543     @@@@@:
544     An associated namespace prefix. If more than one prefix
545     are associated to the namespace URI, the returned prefix
546     is implementation dependent.
547     @@@InCase:
548     @@@@Value:
549     @@@@@is-null:1
550     @@@@Description:
551     @@@@@lang:en
552     @@@@@@:
553     No associated namespace prefix found.
554     @@@PerlDef:
555     $r = null;
556 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
557     .ownerDocument> || $self;
558 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
559 wakaba 1.1 if (defined $namespaceURI) {
560     FIND: {
561     for my $prefix (keys %$binds) {
562     if (defined $binds->{$prefix} and
563     $binds->{$prefix} eq $namespaceURI) {
564     $r = $prefix;
565     last FIND;
566     }
567     }
568 wakaba 1.7
569     ## From module list
570     try {
571     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
572     -><AG::ManakaiDISDocument.disDatabase>;
573     for my $mod_uri (keys %{$db->{modDef}}) {
574     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
575     my $mod_ln = $mod-><AG::ManakaiDISModuleDefinition.localName>;
576     next if exists $binds->{$mod_ln};
577     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
578     .getPropertyText>
579     (<Q::dis:Namespace>, '');
580     if ($ns_uri eq $namespaceURI) {
581     $r = $mod_ln;
582     last FIND;
583     }
584     }
585     } catch <Class::ManakaiDISException> with {
586     my $err = shift;
587     $err->throw
588     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
589     };
590    
591 wakaba 1.1 last FIND unless $makeNewBinding;
592     ## Not found
593     if ($namespaceURI =~ /(\w+)$/) {
594     my $prefix = $1;
595     unless (exists $binds->{$prefix}) {
596     $binds->{$prefix} = $namespaceURI;
597     $r = $prefix;
598     last FIND;
599     }
600     }
601     my $i = 1;
602     {
603     unless (exists $binds->{'ns'.$i}) {
604     $binds->{$r = 'ns'.$i} = $namespaceURI;
605     last FIND;
606     }
607     $i++;
608     redo;
609     }
610     } # FIND
611     } else { ## Null namespace
612     FIND: {
613     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
614     $r = 'nu'.'ll';
615     last FIND;
616     }
617     for my $prefix (keys %$binds) {
618     if (not defined $prefix) {
619     $r = $prefix;
620     last FIND;
621     }
622     }
623     last FIND unless $makeNewBinding;
624     ## Not found
625     my $i = '';
626     {
627     unless (exists $binds->{'nu'.'ll'.$i}) {
628     $binds->{$r = 'nu'.'ll'.$i} = null;
629     last FIND;
630     }
631     $i++;
632     redo;
633     }
634     }
635     }
636    
637     @MethodRedef:
638     @@Name:lookupNamespaceURI
639     @@Description:
640     @@@lang:en
641     @@@@:
642     Looks up the namespace URI associated to the given prefix.
643     @@Param:
644     @@@Name:prefix
645     @@@Type:
646 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
647 wakaba 1.1 @@@Description:
648     @@@@lang:en
649     @@@@@:
650     The namespace URI to look for.
651     @@NamedParam:
652     @@@Name: makeNewBinding
653     @@@Type:
654     DOMMain:boolean
655     @@@Description:
656     @@@@lang:en
657     @@@@@:
658     Whether a new binding should be created if no namespace URI
659     is associated with the <P::prefix> or not.
660     @@@InCase:
661     @@@@Value:true
662     @@@@Description:
663     @@@@@lang:en
664     @@@@@@:
665     A new binding to the temporary namespace URI
666     exactly same as <P::prefix> is created
667     if no binding found.
668     @@@InCase:
669     @@@@Value:false
670     @@@@Description:
671     @@@@@lang:en
672     @@@@@@:
673     No new binding is created if no binding found. Note that
674     even if no association newly created, this method
675     returns the <DOM::null> value.
676 wakaba 1.12 @@NamedParam:
677     @@@Name: raisePrefixException
678     @@@Type:
679     DOMMain:boolean
680     @@@enDesc:
681     Whehter an exception should be thrown if <P::prefix>
682     is not declared or not.
683 wakaba 1.1 @@Return:
684 wakaba 1.3 @@@Type: AnyURI
685 wakaba 1.1 @@@Description:
686     @@@@lang:en
687     @@@@@:The associated namespace URI.
688     @@@InCase:
689     @@@@Value:
690     @@@@@is-null:1
691     @@@@Description:
692     @@@@@lang:en
693     @@@@@@:
694 wakaba 1.3 No namespace URI is associated to the prefix or
695 wakaba 1.1 the <DOM::null> namespace is associated.
696 wakaba 1.12 @@@UndeclaredPrefixException:
697 wakaba 1.1 @@@PerlDef:
698 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
699     .ownerDocument> || $self;
700 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
701 wakaba 1.1 if (exists $binds->{$prefix}) {
702     $r = $binds->{$prefix};
703     } else {
704 wakaba 1.7 ## From module list
705     FIND: {
706     try {
707     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
708     -><AG::ManakaiDISDocument.disDatabase>;
709     for my $mod_uri (keys %{$db->{modDef}}) {
710     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
711     if ($mod-><AG::ManakaiDISModuleDefinition.localName>
712     eq $prefix) {
713     $r = $mod-><M::ManakaiDISPropertyAccessor
714     .getPropertyText>
715     (<Q::dis:Namespace>, null);
716     last FIND;
717     }
718     }
719     } catch <Class::ManakaiDISException> with {
720     my $err = shift;
721     $err->throw
722     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
723     };
724     if ($makeNewBinding) {
725     $r = $binds->{$prefix} = $prefix;
726 wakaba 1.12 } elsif ($raisePrefixException) {
727     __EXCEPTION{DIS:UNDECLARED_NS_PREFIX_ERR::
728     infoset:prefix => {$prefix},
729     MDOMX:param-name => 'prefix',
730     DIS:sourceNode => {$self},
731     }__;
732 wakaba 1.7 } else {
733     $r = null;
734     }
735     } # FIND
736 wakaba 1.1 }
737    
738     @IntMethod:
739     @@Name:getNodeReference
740     @@Description:
741     @@@lang:en
742     @@@@:
743     Returns a new reference to the node object.
744     @@ManakaiDOM:isStatic:1
745     @@Param:
746     @@@Name:object
747     @@@Type:
748     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
749     @@@Description:
750     @@@@lang:en
751     @@@@@:
752     The node object to be referred.
753     @@Return:
754     @@@Type: ManakaiDISNode
755     @@@Description:
756     @@@@lang:en
757     @@@@@:
758     A newly created reference.
759     @@@PerlDef:
760     my $class;
761 wakaba 1.5 if ($object->{<Q::swcfg21:nodeType>} eq '#element') {
762 wakaba 1.1 $class = <ClassName::ManakaiDISElement>;
763 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#comment') {
764 wakaba 1.1 $class = <ClassName::ManakaiDISComment>;
765 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#document') {
766 wakaba 1.1 $class = <ClassName::ManakaiDISDocument>;
767 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#fragment') {
768 wakaba 1.1 $class = <ClassName::ManakaiDISDocumentFragment>;
769     } else {
770     __ASSERT{DISPerl:invariant::
771 wakaba 1.5 msg => {qq[Node type: "$object->{<Q::swcfg21:nodeType>}" ].
772 wakaba 1.1 qq[(ref: "@{[ref $object]}")]},
773     }__;
774     }
775     $r = $object-><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
776     .newReference> ($class);
777    
778 wakaba 1.2 @Attr:
779     @@Name:ownerDISDocument
780     @@Description:
781     @@@lang:en
782     @@@@:
783     The <QUOTE::dis> document object associated with this node.
784     @@Get:
785 wakaba 1.3 @@@Type:ManakaiDISDocument
786 wakaba 1.2 @@@Description:
787     @@@@lang:en
788     @@@@@:
789     The document object associated with this node.
790     @@@InCase:
791     @@@@Value:
792     @@@@@is-null:1
793     @@@@Description:
794     @@@@@lang:en
795     @@@@@@:
796     This node is a document node.
797     @@@PerlDef:
798     $r = <ClassM::ManakaiDISNode.getNodeReference>
799     ($self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>})
800     if $self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>};
801 wakaba 1.1 ##DISNode
802    
803     ClsDef:
804     @ClsQName: ManakaiDISElement
805 wakaba 1.7 @ClsISA: ManakaiDISNode
806 wakaba 1.1 @ClsISA:
807 wakaba 1.3 swcfg21:ManakaiSWCFGElement::swcfg21:ForLatest
808 wakaba 1.1 @Description:
809     @@lang:en
810     @@@:
811     <QUOTE::dis> element node objects.
812    
813     @Method:
814     @@Name: forMatch
815     @@Description:
816     @@@lang:en
817     @@@@:
818     Tests whether this element is for a <QUOTE::for> or not.
819     @@Param:
820     @@@Name: forArg
821     @@@Type: ForURI
822     @@@Description:
823     @@@@lang:en
824     @@@@@:
825     The <QUOTE::For> URI reference to test against.
826     @@Param:
827     @@@Name: forpArg
828     @@@Type: ForURIList
829     @@@Description:
830     @@@@lang:en
831     @@@@@:
832     The <QUOTE::For+> URI references to test against.
833     @@@InCase:
834     @@@@Value:
835     @@@@@is-null:1
836     @@@@Description:
837     @@@@@lang:en
838     @@@@@@:
839     No additional <QUOTE::For> URI reference.
840 wakaba 1.3 Equivalent to an empty array reference.
841 wakaba 1.1 @@Return:
842     @@@Type:
843     DOMMain:boolean
844     @@@Description:
845     @@@@lang:en
846     @@@@@:
847     Whether this element is for <P::forArg> and <P::forpArg> or not.
848 wakaba 1.2 @@@UndeclaredPrefixException:
849     @@@NoDBException:
850     @@@PerlDef:
851 wakaba 1.3 $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
852     $forpArg ||= [];
853 wakaba 1.2
854     FORMATCH: {
855     __DEEP{
856 wakaba 1.10 my $for_res = $self-><AG::ManakaiDISNode.ownerDISDocument>
857     -><AG::ManakaiDISDocument.disDatabase>
858     -><M::ManakaiDISDatabase.getFor> ($forArg);
859     my $forp_res = [map {
860     $self-><AG::ManakaiDISNode.ownerDISDocument>
861     -><AG::ManakaiDISDocument.disDatabase>
862     -><M::ManakaiDISDatabase.getFor> ($_)
863     } @{$forpArg}];
864    
865     my @ce = @{$self-><M::ManakaiDISElement.disAllChildElements>};
866 wakaba 1.2 for my $ce (@ce) {
867 wakaba 1.3 my $et = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
868     .expandedURI>;
869 wakaba 1.2 if ($et eq <Q::dis:ForCheck>) {
870 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
871     ::swcfg21:ForLatest.value>];
872 wakaba 1.9 FCs: for my $f (@$fors) {
873 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
874 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
875 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
876     -><AG::ManakaiDISDocument.disDatabase>
877     -><M::ManakaiDISDatabase.getFor> ($uri);
878 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
879 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
880     if ($arg_res eq $for) {
881 wakaba 1.2 $r = false;
882     last FORMATCH;
883     }
884     }
885     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
886 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
887 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
888     -><AG::ManakaiDISDocument.disDatabase>
889     -><M::ManakaiDISDatabase.getFor> ($uri);
890 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
891 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
892     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
893 wakaba 1.2 $r = false;
894     last FORMATCH;
895     }
896     }
897     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
898 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
899 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
900     -><AG::ManakaiDISDocument.disDatabase>
901     -><M::ManakaiDISDatabase.getFor> ($uri);
902 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
903 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
904     if ($arg_res eq $for) {
905 wakaba 1.2 next FCs;
906     }
907     }
908     $r = false;
909     last FORMATCH;
910     } else { ## -- ISA
911 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
912 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
913     -><AG::ManakaiDISDocument.disDatabase>
914     -><M::ManakaiDISDatabase.getFor> ($uri);
915 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
916 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
917     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
918 wakaba 1.2 next FCs;
919     }
920     }
921     $r = false;
922     last FORMATCH;
923     }
924     } # FCs
925     } # dis:ForCheck
926     } # children
927    
928     my $has_for = false;
929     for my $ce (@ce) {
930 wakaba 1.11 if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
931 wakaba 1.3 .expandedURI> eq
932 wakaba 1.2 <Q::dis:For>) {
933 wakaba 1.14 my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
934     ::swcfg21:ForLatest.value>];
935 wakaba 1.2 my $ok = true;
936     $has_for = true;
937 wakaba 1.9 AFOR: for my $f (@$fors) {
938 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
939 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
940 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
941     -><AG::ManakaiDISDocument.disDatabase>
942     -><M::ManakaiDISDatabase.getFor> ($uri);
943 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
944 wakaba 1.10 if ($for eq $for_res) {
945 wakaba 1.2 $ok = false;
946     last AFOR;
947     }
948     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
949 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
950 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
951     -><AG::ManakaiDISDocument.disDatabase>
952     -><M::ManakaiDISDatabase.getFor> ($uri);
953 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
954 wakaba 1.10 if ($for_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
955 wakaba 1.2 $ok = false;
956     last AFOR;
957     }
958     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
959 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($1);
960 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
961     -><AG::ManakaiDISDocument.disDatabase>
962     -><M::ManakaiDISDatabase.getFor> ($uri);
963 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
964 wakaba 1.10 unless ($for eq $for_res) {
965 wakaba 1.2 $ok = false;
966     last AFOR;
967     }
968     } else { ## -- ISA
969 wakaba 1.14 my $uri = $self-><M::ManakaiDISElement.qnameToURI> ($f);
970 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
971     -><AG::ManakaiDISDocument.disDatabase>
972     -><M::ManakaiDISDatabase.getFor> ($uri);
973 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($ce);
974 wakaba 1.10 unless ($for_res-><M::ManakaiDISForDefinition.isaURI>($uri)){
975 wakaba 1.2 $ok = false;
976     last AFOR;
977     }
978     }
979     } # AFOR
980 wakaba 1.3 if ($ok) {
981     $r = true;
982     last FORMATCH;
983     }
984 wakaba 1.2 } # dis:For
985     } # $ce
986     $r = $has_for ? false : true;
987     }__;
988     } # FORMATCH
989 wakaba 1.1
990     @Method:
991     @@Name: mediaTypeMatch
992     @@Description:
993     @@@lang:en
994     @@@@:
995     Tests whether the content media type of this element matches to
996     a type or not.
997     @@Param:
998     @@@Name: mediaType
999     @@@Type: MediaTypeURI
1000     @@@Description:
1001     @@@@lang:en
1002     @@@@@:
1003     A media type URI reference to test against.
1004     @@Param:
1005 wakaba 1.3 @@@Name: defaultMediaType
1006 wakaba 1.1 @@@Type: MediaTypeURI
1007     @@@Description:
1008     @@@@lang:en
1009     @@@@@:
1010     The default media type for this element.
1011     @@@InCase:
1012     @@@@Value:
1013     @@@@@is-null:1
1014     @@@@Description:
1015     @@@@@lang:en
1016     @@@@@@:
1017     No default type provided. All <P::mediaType> will match.
1018 wakaba 1.12 @@ForParam:
1019     @@ForpParam:
1020 wakaba 1.1 @@Return:
1021     @@@Type:
1022     DOMMain:boolean
1023     @@@Description:
1024     @@@@lang:en
1025     @@@@@:
1026     Whether this element is of <P::mediaType> or not.
1027 wakaba 1.2 @@@PerlDef:
1028     if (defined $mediaType) {
1029     __DEEP{
1030     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1031 wakaba 1.12 (<Q::dis:ContentType>, for_arg => $forArg,
1032     forp_arg => $forpArg);
1033 wakaba 1.2 my $ct;
1034     $ct = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1035     $ct = $defaultMediaType unless defined $ct;
1036     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
1037     -><AG::ManakaiDISDocument.disDatabase>
1038     -><M::ManakaiDISDatabase.getResource> ($ct);
1039     $res-><AS::ManakaiDISResourceDefinition.isReferred> ($ctn or $self);
1040 wakaba 1.7 unless ($res-><M::ManakaiDISResourceDefinition
1041 wakaba 1.10 .isSubsetOfURI> ($mediaType)) {
1042 wakaba 1.2 $r = false;
1043     } else {
1044     $r = true;
1045     }
1046     }__;
1047     } else {
1048     $r = true;
1049     }
1050 wakaba 1.1
1051     @Method:
1052 wakaba 1.10 @@Name:mediaTypeURI
1053     @@enDesc:
1054     The URI reference of the media type of this element.
1055     @@Type: MediaTypeURI
1056     @@NamedParam:
1057     @@@Name:defaultMediaType
1058     @@@Type:MediaTypeURI
1059     @@@enDesc:
1060     The default media type URI reference.
1061     @@@nullCase:
1062     @@@@enDesc:
1063     No default is specified.
1064     @@ForParam:
1065     @@ForpParam:
1066     @@Return:
1067     @@@enDesc:
1068     The media type URI reference of this element.
1069     @@@nullCase:
1070     @@@@enDesc:
1071     This element has no media type information and
1072     <P::defaultMediaType> parameter is not provided.
1073     @@@UndeclaredPrefixException:
1074     @@@PerlDef:
1075     __DEEP{
1076     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1077     (<Q::dis:ContentType>, for_arg => $forArg,
1078     forp_arg => $forpArg);
1079     $r = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1080     }__;
1081    
1082     @Method:
1083 wakaba 1.1 @@Name: prefixToURI
1084     @@Description:
1085     @@@lang:en
1086     @@@@:
1087     Converts a namespace prefix into associated URI reference.
1088     @@Param:
1089     @@@Name: prefix
1090     @@@Type:
1091 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
1092 wakaba 1.1 @@@Description:
1093     @@@@lang:en
1094     @@@@@:
1095     A namespace prefix to look for.
1096     @@@InCase:
1097     @@@@Value:
1098     @@@@@is-null:1
1099     @@@@Description:
1100     @@@@@lang:en
1101     @@@@@@:
1102     Returns the default namespace URI.
1103     @@NodeParam:
1104     @@Return:
1105 wakaba 1.3 @@@Type: AnyURI
1106 wakaba 1.1 @@@Description:
1107     @@@@lang:en
1108     @@@@@: The URI references associated.
1109     @@@UndeclaredPrefixException:
1110     @@@PerlDef:
1111 wakaba 1.3 if (defined $prefix) {
1112 wakaba 1.1 __DEEP{
1113 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1114     .lookupNamespaceURI> ($prefix);
1115 wakaba 1.1 }__;
1116     unless (defined $r) {
1117     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
1118     infoset:prefix => {$prefix},
1119     MDOMX:param-name => 'prefix',
1120     DIS:sourceNode => {$node},
1121     }__;
1122     }
1123 wakaba 1.7 } else { ## Default namespace
1124     __DEEP{
1125     $r = ($self-><AG::ManakaiDISNode.ownerDISDocument> || $self)
1126     -><AG::ManakaiDISDocument.moduleElement>
1127     -><AG::ManakaiDISModuleElement.definingNamespaceURI>;
1128     }__;
1129 wakaba 1.1 }
1130    
1131     @Method:
1132     @@QName: qnameToURI
1133     @@Description:
1134     @@@lang:en
1135     @@@@:
1136     Converts a qualified name (<TYPE::dis:TypeQName>) to
1137     an expanded URI reference.
1138     @@Param:
1139     @@@Name: qname
1140     @@@Type:
1141     dis:TypeQName
1142     @@@Description:
1143     @@@@lang:en
1144     @@@@@:
1145     A qualified name.
1146     @@NodeParam:
1147 wakaba 1.13 @@NamedParam:
1148     @@@Name: defaultNamespaceURI
1149     @@@Type: AnyURI
1150     @@@enDesc:
1151     Default namespace URI reference.
1152     @@@nullCase:
1153     @@@@enDesc:
1154     The default namespace is the namespace defined by the module
1155     to which this resource belongs.
1156 wakaba 1.1 @@Return:
1157     @@@Type: AnyURI
1158     @@@Description:
1159     @@@@lang:en
1160     @@@@@:
1161     The expanded URI reference.
1162     @@@UndeclaredPrefixException:
1163     @@@PerlDef:
1164     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1165 wakaba 1.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 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1421 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1422 wakaba 1.14 $r = $self-><M::ManakaiDISElement.qnameToURI> ($v, node => $self);
1423 wakaba 1.4 } else {
1424     $r = null;
1425     }
1426     }__;
1427    
1428     @Attr:
1429     @@Name: qnameValueLocalName
1430     @@enDesc:
1431     The local name part of the element value (assumed as
1432     written as <TYPE::dis:TypeQName>).
1433     \
1434     {NOTE:: What should be if list value?
1435     \
1436     }
1437     @@Get:
1438     @@@Type:
1439     DISCore:LocalName
1440     @@@nullCase:
1441     @@@@enDesc:
1442     No value.
1443     @@@PerlDef:
1444     __DEEP{
1445 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1446 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1447     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 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1472 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1473     my ($p, $v) = split /:/, $v, 2;
1474 wakaba 1.14 $r = $self-><M::ManakaiDISElement.prefixToURI>
1475 wakaba 1.4 (defined $v ? $p : null);
1476     } else {
1477     $r = null;
1478     }
1479     }__;
1480 wakaba 1.2
1481 wakaba 1.6 @Method:
1482 wakaba 1.3 @@Name: tfqnamesValueURI
1483 wakaba 1.2 @@enDesc:
1484 wakaba 1.3 The element value (written as <TYPE::dis:TFQNames>),
1485 wakaba 1.2 as URI reference.
1486     \
1487     {NOTE:: What should be if list value?
1488     \
1489     }
1490 wakaba 1.6 @@Param:
1491     @@@Name: defaultTypeURI
1492     @@@Type: NameURI
1493     @@@Description:
1494     @@@@lang:en
1495     @@@@@:
1496     A name URI reference used if it is missing from
1497     <P::tfqnames>.
1498     @@@InCase:
1499     @@@@Value:
1500     @@@@@is-null:1
1501     @@@@Description:
1502     @@@@@lang:en
1503     @@@@@@:
1504     Equivalent to <Q::DOMMain:any>.
1505     @@Param:
1506     @@@Name: defaultForURI
1507     @@@Type: ForURI
1508     @@@Description:
1509     @@@@lang:en
1510     @@@@@:
1511     A <QUOTE::for> URI reference used if it is missing from
1512     <P::tfqnames>.
1513     @@@InCase:
1514     @@@@Value:
1515     @@@@@is-null:1
1516     @@@@Description:
1517     @@@@@lang:en
1518     @@@@@@:
1519     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1520     @@Return:
1521 wakaba 1.2 @@@Type:ResourceURI
1522     @@@nullCase:
1523     @@@@enDesc:
1524     No value.
1525     @@@UndeclaredPrefixException:
1526 wakaba 1.3 @@@PerlDef:
1527 wakaba 1.14 my $v = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1528 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1529     __DEEP{
1530 wakaba 1.14 $r = $self-><M::ManakaiDISElement.tfqnamesToURI>
1531 wakaba 1.6 ($v, $defaultTypeURI, $defaultForURI);
1532 wakaba 1.2 }__;
1533     } else {
1534     $r = null;
1535     }
1536 wakaba 1.7
1537     @Method:
1538     @@Name: elementTypeMatch
1539     @@enDesc:
1540     Returns whether the element type of this element matches
1541     with another element type (either the same element type or
1542     this type is a subtype of another type).
1543     @@Param:
1544     @@@Name: etype
1545     @@@Type: ResourceURI
1546     @@@enDesc:
1547     An element type name URI reference to test.
1548     @@Return:
1549     @@@Type:
1550     DOMMain:boolean
1551     @@@TrueCase:
1552     @@@@enDesc:
1553     Either the element type expanded URI reference of this element is
1554     same as <P::etype> or it is a sub-element type of <P::etype>.
1555     @@@FalseCase:
1556     @@@@enDesc:
1557     This element is not of <P::etype>.
1558     @@@NoDBException:
1559     @@@PerlDef:
1560     __DEEP{
1561 wakaba 1.14 my $et = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1562 wakaba 1.7 .expandedURI>;
1563     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1564     -><AG::ManakaiDISDocument.disDatabase>
1565     -><M::ManakaiDISDatabase.getResource> ($et);
1566     $r = $rdef-><M::ManakaiDISResourceDefinition.isSubsetOfURI> ($etype);
1567     }__;
1568    
1569     @Attr:
1570     @@Name: isResourceElement
1571     @@enDesc:
1572     Whether this element defines a resource or not.
1573     \
1574     {NOTE:: An element defines a resource if its element type is
1575     <Q::dis:ResourceDef> or its subtype.
1576     \
1577     }
1578     @@Get:
1579     @@@Type:
1580     DOMMain:boolean
1581     @@@TrueCase:
1582     @@@@enDesc:
1583     This element defines a resource.
1584     @@@FalseCase:
1585     @@@@enDesc:
1586     This element does not define any resource.
1587     @@@NoDBException:
1588     @@@PerlDef:
1589     __DEEP{
1590     $r = $self-><M::ManakaiDISElement.elementTypeMatch>
1591     (<Q::dis:ResourceDef>);
1592     }__;
1593    
1594     @Attr:
1595     @@Name: isPropertyElement
1596     @@enDesc:
1597     Whether this element is a property or not.
1598     \
1599     {NOTE:: An element is a property if its element type is
1600     <Q::rdf:type> or if its element type's <Q::rdf:type>
1601     property is <Q::rdf:Property> or is <Q::dis:subsetOf>
1602     <Q::rdf:Property>.
1603     \
1604     }
1605     @@Get:
1606     @@@Type:
1607     DOMMain:boolean
1608     @@@TrueCase:
1609     @@@@enDesc:
1610     This element is a property.
1611     @@@FalseCase:
1612     @@@@enDesc:
1613     This element is not a property.
1614     @@@NoDBException:
1615     @@@PerlDef:
1616     __DEEP{
1617     my $xn = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1618     .expandedURI>;
1619     if ($xn eq <Q::rdf:type>) {
1620     $r = true;
1621     } else {
1622     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1623     -><AG::ManakaiDISDocument.disDatabase>
1624     -><M::ManakaiDISDatabase.getResource> ($xn);
1625     $r = $rdef-><M::ManakaiDISResourceDefinition.isTypeURI>
1626     (<Q::rdf:Resource>);
1627     }
1628     }__;
1629 wakaba 1.1 ##DISElement
1630    
1631     ClsDef:
1632 wakaba 1.4 @ClsQName: ManakaiDISModuleElement
1633     @ClsISA: ManakaiDISElement
1634     @enDesc:
1635     The <Q::dis:Module> elements.
1636    
1637     @Attr:
1638     @@Name: requireElement
1639     @@enDesc:
1640     The <Q::dis:Require> child element. The element is
1641     newly created if not exist.
1642     @@Type: ManakaiDISElement
1643     @@Get:
1644     @@@PerlDef:
1645     __DEEP{
1646     $r = $self-><M::swcfg21:SWCFGNode
1647     ::swcfg21:ForLatest.getAttributeNS>
1648     (<Q::dis:>, 'Require', make_new_node => true);
1649     }__;
1650    
1651     @Attr:
1652     @@Name: defaultForURI
1653     @@enDesc:
1654     The value of <Q::dis:DefaultFor> attribute.
1655     @@Type: ForURI
1656     @@Get:
1657     @@@enDesc:
1658     The value of <Q::dis:DefaultFor> child element. If missing,
1659     <Q::ManakaiDOM:all> is returned.
1660     @@@PerlDef:
1661     __DEEP{
1662     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1663     .getAttributeNS>
1664     (<Q::dis:>, 'DefaultFor');
1665     if ($df) {
1666     $r = $df-><AG::ManakaiDISElement.qnameValueURI>
1667     || <Q::ManakaiDOM:all>;
1668     } else {
1669     $r = <Q::ManakaiDOM:all>;
1670     }
1671     }__;
1672     @@Set:
1673     @@@PerlDef:
1674     __DEEP{
1675     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1676     (<Q::dis:>, 'DefaultFor' => $given);
1677     }__;
1678 wakaba 1.7
1679     @Attr:
1680     @@Name: definingNamespaceURI
1681     @@enDesc:
1682     The value of <Q::dis:NamespaceURI> attribute, i.e.
1683     the URI reference of the namespace that this module primary
1684     defines.
1685     \
1686     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
1687     \
1688     }
1689     @@Type: AnyURI
1690     @@Get:
1691     @@@PerlDef:
1692     __DEEP{
1693     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1694     .getAttributeNS>
1695     (<Q::dis:>, 'Namespace');
1696     if ($df) {
1697 wakaba 1.14 $r = $df-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1698 wakaba 1.7 } else {
1699     __ASSERT{DISPerl:invariant::
1700     msg => {qq["dis:Namespace" attribute not found]},
1701     }__;
1702     }
1703     }__;
1704     @@Set:
1705     @@@PerlDef:
1706     __DEEP{
1707     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1708     (<Q::dis:>, 'Namespace' => $given);
1709     }__;
1710 wakaba 1.4 ##DISModuleElement
1711    
1712     ClsDef:
1713 wakaba 1.2 @ClsQName: ManakaiDISElementList
1714     @enDesc:
1715     @@lang:en
1716     @@@:
1717     Lists of elements.
1718     \
1719     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
1720     later changes to the tree does not affect this type of objects.
1721     \
1722     }
1723     ##DISElementList
1724    
1725     ClsDef:
1726 wakaba 1.1 @ClsQName: ManakaiDISComment
1727 wakaba 1.7 @ClsISA: ManakaiDISNode
1728 wakaba 1.1 @ClsISA:
1729 wakaba 1.3 swcfg21:ManakaiSWCFGComment::swcfg21:ForLatest
1730 wakaba 1.1 @Description:
1731     @@lang:en
1732     @@@:
1733     <QUOTE::dis> comment node objects.
1734     ##DISComment
1735    
1736     ClsDef:
1737     @ClsQName: ManakaiDISDocumentFragment
1738 wakaba 1.7 @ClsISA: ManakaiDISNode
1739 wakaba 1.1 @ClsISA:
1740 wakaba 1.3 swcfg21:ManakaiSWCFGDocumentFragment::swcfg21:ForLatest
1741 wakaba 1.1 @Description:
1742     @@lang:en
1743     @@@:
1744     <QUOTE::dis> document fragment node objects.
1745     ##DISDocumentFragment
1746    
1747     ClsDef:
1748     @ClsQName: ManakaiDISDocument
1749 wakaba 1.7 @ClsISA: ManakaiDISNode
1750 wakaba 1.1 @ClsISA:
1751 wakaba 1.3 swcfg21:ManakaiSWCFGDocument::swcfg21:ForLatest
1752 wakaba 1.1 @Description:
1753     @@lang:en
1754     @@@:
1755     <QUOTE::dis> document node objects.
1756 wakaba 1.2
1757     @Attr:
1758 wakaba 1.4 @@Name: moduleElement
1759     @@enDesc:
1760     The <Q::dis:Module> element in this document. The element is
1761     newly created if not exist.
1762     @@Type: ManakaiDISModuleElement
1763     @@Get:
1764     @@@PerlDef:
1765     __DEEP{
1766     $r = $self-><M::swcfg21:SWCFGNode
1767     ::swcfg21:ForLatest.getAttributeNS>
1768     (<Q::dis:>, 'Module', make_new_node => true);
1769     }__;
1770     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
1771    
1772     @Attr:
1773 wakaba 1.2 @@Name: disDatabase
1774     @@enDesc:
1775     Associated <QUOTE::dis> database.
1776    
1777     @@Type: ManakaiDISDatabase
1778     @@Get:
1779     @@@NoDBException:
1780     @@@PerlDef:
1781     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
1782 wakaba 1.5 $r = $self->{<Q::TreeCore:node>}->{<Q::db>};
1783 wakaba 1.2 } else {
1784     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
1785     }
1786     @@Set:
1787     @@@PerlDef:
1788     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
1789     require Scalar::Util;
1790     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
1791 wakaba 1.5
1792     @Method:
1793     @@Name: disChildElements
1794     @@enDesc:
1795 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
1796 wakaba 1.5 @@ForParam:
1797     @@ForpParam:
1798     @@Return:
1799     @@@Type: ManakaiDISElementList
1800     @@@enDesc:
1801     The current snapshot of child nodes.
1802     @@@PerlDef:
1803     $r = bless [], <ClassName::ManakaiDISElementList>;
1804     __DEEP{
1805     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1806     .childNodes>}) {
1807     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1808     .nodeType> eq '#element';
1809     my $dn = $cn->{<Q::TreeCore:node>}
1810     -><M::ManakaiDOM:ManakaiDOMNodeObject
1811     ::ManakaiDOM:Perl.newReference>
1812     (<ClassName::ManakaiDISElement>);
1813     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1814     push @$r, $dn;
1815     }
1816     }__;
1817 wakaba 1.10
1818     @Method:
1819     @@Name: disAllChildElements
1820     @@enDesc:
1821     A list of child elements, without <QUOTE::for> checks.
1822     @@Return:
1823     @@@Type: ManakaiDISElementList
1824     @@@enDesc:
1825     The current snapshot of child nodes.
1826     @@@PerlDef:
1827     $r = bless [], <ClassName::ManakaiDISElementList>;
1828     __DEEP{
1829     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1830     .childNodes>}) {
1831     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1832     .nodeType> eq '#element';
1833     my $dn = $cn->{<Q::TreeCore:node>}
1834     -><M::ManakaiDOM:ManakaiDOMNodeObject
1835     ::ManakaiDOM:Perl.newReference>
1836     (<ClassName::ManakaiDISElement>);
1837     push @$r, $dn;
1838     }
1839     }__;
1840 wakaba 1.1 ##DISDocument
1841 wakaba 1.2
1842     PropDef:
1843     @QName: db
1844     @enDesc:
1845     Associated <QUOTE::dis> database.
1846     @rdfs:domain: ManakaiDISDocument
1847     @rdfs:range: ManakaiDISDatabase
1848    
1849     ## -- Definition object database
1850    
1851     ClsDef:
1852     @ClsQName: ManakaiDISDatabase
1853     @enDesc:
1854     Resource database created from <QUOTE::dis> source data.
1855 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
1856 wakaba 1.2
1857     @Method:
1858     @@Name: getModule
1859     @@Description:
1860     @@@lang:en
1861     @@@@:
1862     Returns a <QUOTE::dis> module definition.
1863     @@Param:
1864 wakaba 1.9 @@@Name: moduleURI
1865 wakaba 1.2 @@@Type: ModuleURI
1866     @@@Description:
1867     @@@@lang:en
1868     @@@@@:
1869     A <QUOTE::dis> module URI reference.
1870 wakaba 1.9 @@ForParam:
1871 wakaba 1.2 @@Return:
1872     @@@Type: ManakaiDISModuleDefinition
1873     @@@Description:
1874     @@@@lang:en
1875     @@@@@:
1876     The module definition.
1877     @@@PerlDef:
1878 wakaba 1.9 my $modURI;
1879     if (defined $forArg) {
1880     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
1881     $uri => $modURI}__;
1882     } else {
1883     $modURI = $moduleURI;
1884     }
1885 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
1886     $r = $self->{modDef}->{$modURI};
1887     } else {
1888     $r = $self->{modDef}->{$modURI}
1889     = bless {
1890     uri => $modURI,
1891     db => $self,
1892     for => <Q::ManakaiDOM:all>,
1893     forp => [],
1894     }, <ClassName::ManakaiDISModuleDefinition>;
1895     require Scalar::Util;
1896     Scalar::Util::weaken ($r->{db});
1897     }
1898    
1899     @Method:
1900     @@Name: getFor
1901     @@Description:
1902     @@@lang:en
1903     @@@@:
1904     Returns a <QUOTE::for> definition object.
1905     @@Param:
1906     @@@Name: forURI
1907     @@@Type: ForURI
1908     @@@Description:
1909     @@@@lang:en
1910     @@@@@:
1911     A <QUOTE::for> URI reference.
1912     @@@InCase:
1913     @@@@Value:
1914     @@@@@is-null:1
1915     @@@@Description:
1916     @@@@@lang:en
1917     @@@@@@:
1918     Defaulted to <Q::ManakaiDOM:all>.
1919     @@Return:
1920     @@@Type: ManakaiDISForDefinition
1921     @@@PerlDef:
1922     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
1923     if (defined $self->{forDef}->{$forURI}) {
1924     $r = $self->{forDef}->{$forURI};
1925     } else {
1926     $r = $self->{forDef}->{$forURI}
1927     = bless {
1928     uri => $forURI,
1929     isa => {<Q::ManakaiDOM:all> => true},
1930     revISA => {},
1931     db => $self,
1932     }, <ClassName::ManakaiDISForDefinition>;
1933     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
1934     require Scalar::Util;
1935     Scalar::Util::weaken ($r->{db});
1936     }
1937    
1938     @Method:
1939     @@Name: getResource
1940     @@Description:
1941     @@@lang:en
1942     @@@@:
1943     Returns a <QUOTE::dis> resource definition.
1944     @@Param:
1945 wakaba 1.9 @@@Name: resourceURI
1946 wakaba 1.2 @@@Type: ResourceURI
1947     @@@Description:
1948     @@@@lang:en
1949     @@@@@:
1950     A <QUOTE::dis> resource URI reference.
1951 wakaba 1.3 @@@nullCase:
1952 wakaba 1.2 @@@@Description:
1953     @@@@@lang:en
1954     @@@@@@:
1955     Defaulted to <Q::DOMMain:any>.
1956 wakaba 1.9 @@ForParam:
1957 wakaba 1.2 @@Return:
1958     @@@Type: ManakaiDISResourceDefinition
1959     @@@Description:
1960     @@@@lang:en
1961     @@@@@:
1962     The resource definition.
1963     @@@PerlDef:
1964 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
1965     my $resURI;
1966     if (defined $forArg) {
1967     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
1968     $uri => $resURI}__;
1969     } else {
1970     $resURI = $resourceURI;
1971     }
1972 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
1973     $r = $self->{resDef}->{$resURI};
1974     } else {
1975     $r = $self->{resDef}->{$resURI}
1976     = bless {
1977     uri => $resURI,
1978 wakaba 1.6 aliasURI => {$resURI => true},
1979 wakaba 1.2 subOf => {},
1980     supOf => {},
1981     db => $self,
1982     for => <Q::ManakaiDOM:all>,
1983     forp => [],
1984 wakaba 1.9 seq => -1,
1985 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
1986     require Scalar::Util;
1987     Scalar::Util::weaken ($r->{db});
1988     }
1989 wakaba 1.3
1990     @Method:
1991     @@Name: getSourceFile
1992     @@enDesc:
1993     Gets <QUOTE::dis> source document.
1994     @@Param:
1995     @@@Name: fileName
1996     @@@Type: FileURI
1997     @@@enDesc:
1998     A URI reference identifying a file.
1999     @@Return:
2000     @@@Type: ManakaiDISDocument
2001     @@@enDesc:
2002     The <QUOTE::dis> source document.
2003     @@@nullCase:
2004     @@@@enDesc:
2005     No document associated with that <P::fileName>.
2006     @@@PerlDef:
2007     $r = $self->{<Q::sourceFile>}->{$fileName};
2008     @Method:
2009     @@Name: setSourceFile
2010     @@enDesc:
2011     Puts <QUOTE::dis> source document object.
2012     @@Param:
2013     @@@Name: fileName
2014     @@@Type: FileURI
2015     @@@enDesc:
2016 wakaba 1.4 A URI reference identifying a file. If there is already a
2017 wakaba 1.3 source document, then the association has been updated.
2018     @@Param:
2019     @@@Name: doc
2020     @@@Type: ManakaiDISDocument
2021     @@@enDesc:
2022     The document object to set.
2023     @@Return:
2024     @@@PerlDef:
2025     $self->{<Q::sourceFile>}->{$fileName} = $doc;
2026 wakaba 1.4
2027     @Method:
2028     @@Name: loadModule
2029     @@enDesc:
2030     Loads definitions from a <QUOTE::dis> document.
2031     @@Param:
2032     @@@Name: doc
2033     @@@Type:ManakaiDISDocument
2034     @@@enDesc:
2035     The source <QUOTE::dis> document object. Its
2036     <A::ManakaiDISDocument.disDatabase> must be this database.
2037     @@Param:
2038     @@@Name: resolver
2039     @@@Type: DISModuleResolver
2040     @@@enDesc:
2041     The resolver to convert module name into <QUOTE::dis> document object.
2042     @@ForParam:
2043     @@Return:
2044     @@@RaiseException:
2045     @@@@@: NO_MODULE_QNAME_ERR
2046     @@@@enDesc:
2047     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2048     @@@RaiseException:
2049     @@@@@: UNABLE_TO_GET_MODULE_ERR
2050     @@@@enDesc:
2051     The implementation is unable to get a module source.
2052 wakaba 1.5 @@@ForDefDupException:
2053     @@@ForDefNoQNameException:
2054     @@@ResDefDupException:
2055     @@@ElementNotAllowedException:
2056 wakaba 1.7 @@@RaiseException:
2057     @@@@@:NO_REQUIRED_ATTR_ERR
2058     @@@@enDesc:
2059     The <Q::dis:Module> element does not have
2060     <Q::dis:Namespace> attribute.
2061 wakaba 1.4 @@@PerlDef:
2062     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2063     if ref $resolver eq 'CODE';
2064     ## -- Module Name, URI
2065     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2066     my $mod_node;
2067     my $mod_name_node;
2068     __DEEP{
2069     $mod_node = $doc-><AG::ManakaiDISDocument.moduleElement>;
2070     $mod_name_node = $mod_node-><M::swcfg21:SWCFGNode
2071     ::swcfg21:ForLatest.getAttributeNS>
2072     (<Q::dis:>, 'QName');
2073     unless ($mod_name_node) {
2074     __UNDEEP{
2075     __EXCEPTION{NO_MODULE_QNAME_ERR::
2076     DIS:sourceNode => {$mod_node},
2077     }__;
2078     }__;
2079     }
2080 wakaba 1.5 my $mod_name_uri = $mod_name_node
2081     -><AG::ManakaiDISElement.qnameValueURI>;
2082 wakaba 1.9 my $mod = $self-><M::ManakaiDISDatabase.getModule>
2083     ($mod_name_uri, for_arg => $forArg);
2084 wakaba 1.4
2085 wakaba 1.14 unless ($mod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2086 wakaba 1.4 ## -- Initializes Module Definition Object
2087     $mod->{nameURI} = $mod_name_uri;
2088     $mod->{localName} = $mod_name_node-><AG::ManakaiDISElement
2089     .qnameValueLocalName>;
2090     $mod->{namespaceURI} = $mod_name_node-><AG::ManakaiDISElement
2091     .qnameValueNamespaceURI>;
2092     $mod->{for} = $forArg;
2093     $mod->{src} = $mod_node;
2094 wakaba 1.5 $mod->{<Q::isDefined>} = true;
2095 wakaba 1.4 $self-><M::ManakaiDISDatabase.setSourceFile>
2096 wakaba 1.5 ($mod->{nameURI} => $doc);
2097    
2098 wakaba 1.9 $mod->{<Q::DIS:sourceFile>}
2099     = $mod->{src}
2100     -><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.ownerDocument>
2101     -><M::swcfg21:SWCFGNode::swcfg21:ForLatest.flag>
2102     (<Q::swcfg21:fileName>);
2103 wakaba 1.5
2104 wakaba 1.12 ## -- Loads "for" definition
2105     my $root_elements
2106     = $doc-><M::ManakaiDISDocument.disAllChildElements>;
2107     if ($mod->{for} eq <Q::ManakaiDOM:all>) {
2108     for my $el (@$root_elements) {
2109 wakaba 1.14 next unless $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2110 wakaba 1.12 .expandedURI> eq <Q::dis:ForDef>;
2111     $self-><M::ManakaiDISDatabase.loadFor> ($mod, $el);
2112     }
2113     }
2114    
2115 wakaba 1.5 ## -- Loads "for all"
2116 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2117     ($mod->{nameURI}, for_arg => <Q::ManakaiDOM:all>);
2118 wakaba 1.5 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2119     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2120 wakaba 1.9 ($self, $rmod->{uri}, $mod->{namespaceURI},
2121     $mod->{localName}, <Q::ManakaiDOM:all>);
2122 wakaba 1.5 unless ($rdoc) {
2123     __UNDEEP{
2124     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2125 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2126 wakaba 1.5 DIS:namespaceURI => {$mod->{namespaceURI}},
2127     DIS:localName => {$mod->{localName}},
2128 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2129 wakaba 1.5 DIS:sourceNode => {$mod->{src}},
2130     }__;
2131     }__;
2132     }
2133     $self-><M::ManakaiDISDatabase.loadModule>
2134 wakaba 1.9 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>);
2135 wakaba 1.5 } # Unless "for all" loaded
2136 wakaba 1.4
2137     ## -- Loads Required Modules
2138 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2139 wakaba 1.4 my $req_node = $mod_node-><AG::ManakaiDISModuleElement
2140     .requireElement>;
2141 wakaba 1.10 for my $rm (@{$req_node-><M::ManakaiDISElement
2142     .disAllChildElements>}) {
2143 wakaba 1.4 next unless $rm-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2144     .expandedURI> eq <Q::dis:Module>;
2145     my ($uri, $nuri, $ln, $for);
2146 wakaba 1.14 my $mqn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2147 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'QName');
2148     if ($mqn) {
2149 wakaba 1.14 my $mqv = $mqn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2150 wakaba 1.4 .value>;
2151 wakaba 1.14 my $mqp = $mqn-><M::ManakaiDISElement.qnameToPair>
2152 wakaba 1.4 ($mqv, node => $mqn);
2153     ($nuri, $ln) = @$mqp;
2154     } else {
2155 wakaba 1.14 my $mn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2156 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'Name');
2157     if ($mn) {
2158     $nuri = $mod->{namespaceURI};
2159 wakaba 1.14 $ln = $mn-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2160 wakaba 1.4 } else {
2161     $nuri = $mod->{namespaceURI};
2162     $ln = $mod->{localName};
2163     }
2164     }
2165 wakaba 1.14 my $wfn = $rm-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2166 wakaba 1.4 .getAttributeNS> (<Q::dis:>, 'WithFor');
2167     if ($wfn) {
2168     $for = $wfn-><AG::ManakaiDISElement.qnameValueURI>;
2169     } else {
2170     $for = $mod->{for};
2171     }
2172 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2173     ($nuri . $ln, for_arg => $for);
2174 wakaba 1.4 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2175     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2176 wakaba 1.9 ($self, $rmod->{uri}, $nuri, $ln, $for);
2177 wakaba 1.4 unless ($rdoc) {
2178     __UNDEEP{
2179     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2180 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2181 wakaba 1.4 DIS:namespaceURI => {$nuri},
2182     DIS:localName => {$ln},
2183     DIS:for => {$for},
2184     DIS:sourceNode => {$rm},
2185     }__;
2186     }__;
2187     }
2188     $self-><M::ManakaiDISDatabase.loadModule>
2189     ($rdoc, $resolver, for_arg => $for);
2190     }
2191     } # Child Module elements
2192    
2193 wakaba 1.12 ## -- Loads child resources
2194 wakaba 1.10 $root_elements = $doc-><M::ManakaiDISDocument.disChildElements>
2195     (for_arg => $forArg);
2196 wakaba 1.5 for my $el (@$root_elements) {
2197 wakaba 1.11 if ($el-><AG::ManakaiDISElement.isResourceElement>) {
2198 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2199 wakaba 1.9 ($mod, null, null, $el,
2200 wakaba 1.7 for_arg => $forArg);
2201     } else {
2202 wakaba 1.14 my $et = $el-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2203 wakaba 1.7 .expandedURI>;
2204     if ({
2205 wakaba 1.5 <Q::dis:ForDef> => 1,
2206     <Q::dis:Module> => 1,
2207     <Q::dis:ImplNote> => 1,
2208 wakaba 1.7 }->{$et}) {
2209     #
2210     } else {
2211     __UNDEEP{
2212     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2213     DIS:elementType => {$et},
2214     DIS:sourceNode => {$el},
2215     DIS:uri => {$mod->{uri}},
2216     }__;
2217 wakaba 1.5 }__;
2218 wakaba 1.7 }
2219     } # element types
2220     }
2221    
2222     my $dn = $mod_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2223     .getAttributeNS>
2224     (<Q::dis:>, 'Namespace');
2225 wakaba 1.14 unless ($dn and defined $dn-><M::swcfg21:SWCFGNode
2226     ::swcfg21:ForLatest.value>) {
2227 wakaba 1.7 __UNDEEP{
2228     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2229     DIS:elementType => {<Q::dis:Namespace>},
2230     DIS:sourceNode => {$mod_node},
2231 wakaba 1.5 }__;
2232 wakaba 1.7 }__;
2233 wakaba 1.5 }
2234     } # Unless this module loaded
2235     }__; # Deep
2236    
2237     @Method:
2238     @@Name: loadFor
2239     @@enDesc:
2240     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2241     @@Param:
2242     @@@Name: mod
2243     @@@Type: ManakaiDISModuleDefinition
2244     @@@enDesc:
2245     The module in which the <QUOTE::for> to load is defined.
2246     @@Param:
2247     @@@Name: el
2248     @@@Type:ManakaiDISElement
2249     @@@enDesc:
2250     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2251     @@Return:
2252     @@@ForDefDupException:
2253     @@@ForDefNoQNameException:
2254     @@@ElementNotAllowedException:
2255     @@@PerlDef:
2256     __DEEP{
2257     my $qn_node = $el-><M::swcfg21:SWCFGNode
2258     ::swcfg21:ForLatest.getAttributeNS>
2259     (<Q::dis:>, 'QName');
2260     unless ($qn_node) {
2261     __UNDEEP{
2262     __EXCEPTION{NO_FOR_QNAME_ERR::
2263     DIS:sourceNode => {$qn_node},
2264     }__;
2265     }__;
2266     }
2267     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2268     my $for = $self-><M::ManakaiDISDatabase.getFor> ($qn_uri);
2269    
2270 wakaba 1.14 unless ($for-><AG::ManakaiDISForDefinition.isDefined>) {
2271 wakaba 1.10 ## -- Initializes "For" Definition Object
2272 wakaba 1.5 $for->{src} = $el;
2273     $for->{<Q::isDefined>} = true;
2274     $for->{<Q::definingModule>} = $mod->{uri};
2275    
2276 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2277 wakaba 1.5 my $xn = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2278     .expandedURI>;
2279     if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2280     my $sfor = $self-><M::ManakaiDISDatabase.getFor>
2281 wakaba 1.7 ($ce-><AG::ManakaiDISElement.qnameValueURI>);
2282 wakaba 1.5 $for-><M::ManakaiDISForDefinition.addISA> ($sfor);
2283 wakaba 1.14 $sfor-><AS::ManakaiDISForDefinition.isReferred> ($ce);
2284 wakaba 1.5 ## TODO: warn if dis:Implement
2285     } elsif ({
2286     <Q::dis:Description> => 1,
2287     <Q::dis:ImplNote> => 1,
2288     <Q::dis:FullName> => 1,
2289     <Q::dis:QName> => 1,
2290     }->{$xn}) {
2291     #
2292     } else {
2293     __UNDEEP{
2294     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2295     DIS:elementType => {$xn},
2296     DIS:sourceNode => {$ce},
2297     DIS:uri => {$mod->{uri}},
2298     }__;
2299     }__;
2300     }
2301     }
2302     } else {
2303     __UNDEEP{
2304     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
2305     DIS:sourceNode => {$el},
2306     DIS:anotherSourceNode => {$for->{src}},
2307     }__;
2308     }__;
2309     } # isDefine?
2310     }__; # DEEP
2311    
2312     @Method:
2313     @@Name: loadResource
2314     @@enDesc:
2315     Loads definition of a <QUOTE::dis> resource from a
2316     <Q::dis:ResourceDef> element.
2317     @@Param:
2318     @@@Name: mod
2319     @@@Type: ManakaiDISModuleDefinition
2320     @@@enDesc:
2321     The module in which the resource to load is defined.
2322     @@Param:
2323     @@@Name: parentResource
2324     @@@Type: ManakaiDISResourceDefinition
2325     @@@enDesc:
2326 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
2327 wakaba 1.5 @@@nullCase:
2328     @@@@enDesc:
2329     The resource to load is a root resource, i.e. <P::el> is
2330     a direct child of the document node.
2331     @@Param:
2332 wakaba 1.7 @@@Name: dynParent
2333 wakaba 1.9 @@@Type: ManakaiDISResourceDefinition
2334 wakaba 1.7 @@@enDesc:
2335     The dynamic parent resource of the resource to load.
2336 wakaba 1.9 @@@nullCase:
2337 wakaba 1.7 @@@@enDesc:
2338 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
2339     a direct child of the document node.
2340 wakaba 1.7 @@Param:
2341 wakaba 1.5 @@@Name: el
2342     @@@Type:ManakaiDISElement
2343     @@@enDesc:
2344     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
2345     @@ForParam:
2346     @@ForpParam:
2347     @@Return:
2348     @@@ResDefDupException:
2349     @@@ElementNotAllowedException:
2350     @@@PerlDef:
2351     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2352     $forpArg ||= [];
2353     __DEEP{
2354 wakaba 1.6 ## -- Node names
2355    
2356     ## Unique resource identifier generated from node id
2357     my $node_id = $el-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.nodeID>;
2358     my $node_uri;
2359     __CODE{tfpurisToURI:: $turi => $node_id, $furi => $forArg,
2360     $forp => $forpArg, $uri => $node_uri}__;
2361    
2362     ## User defined resource identifiers
2363 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
2364     (<Q::dis:QName>, for_arg => $forArg,
2365     forp_arg => $forpArg);
2366     my $res;
2367     if ($qn_node) {
2368     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2369 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2370     ($qn_uri, for_arg => $forArg);
2371 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2372 wakaba 1.5 __UNDEEP{
2373     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2374 wakaba 1.9 DIS:uri => {$res->{uri}},
2375 wakaba 1.5 DIS:sourceNode => {$qn_node},
2376     DIS:anotherSourceNode => {$res->{src}},
2377     }__;
2378 wakaba 1.6 }__;
2379 wakaba 1.5 }
2380     $res->{nameURI} = $qn_uri;
2381     $res->{localName} = $qn_node-><AG::ManakaiDISElement
2382     .qnameValueLocalName>;
2383     $res->{namespaceURI} = $qn_node-><AG::ManakaiDISElement
2384     .qnameValueNamespaceURI>;
2385     } else { ## Anonymous or local
2386     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
2387     (<Q::dis:Name>, for_arg => $forArg,
2388     forp_arg => $forpArg);
2389     if ($n_node) {
2390     if ($parentResource) {
2391     my $puri = $parentResource->{uri};
2392     my $ru;
2393 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2394     ::swcfg21:ForLatest.value>;
2395 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
2396     $localName => $ln,
2397     $result => $ru}__;
2398 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2399     ($ru, for_arg => $forArg);
2400 wakaba 1.5 $res->{nameURI} = $ru;
2401 wakaba 1.14 $res->{localName} = $n_node-><M::swcfg21:SWCFGNode
2402     ::swcfg21:ForLatest.value>;
2403 wakaba 1.5 $res->{<Q::isAnon>} = true;
2404     } else { ## Root local name resource
2405 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
2406 wakaba 1.7 ::swcfg21:ForLatest.value>;
2407     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
2408     .getPropertyText>
2409     (<Q::dis:Namespace>, null);
2410     my $qn_uri = $ns_uri . $ln;
2411 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2412     ($qn_uri, for_arg => $forArg);
2413 wakaba 1.14 if ($res-><AG::ManakaiDISForDefinition.isDefined>) {
2414 wakaba 1.6 __UNDEEP{
2415     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2416 wakaba 1.9 DIS:uri => {$res->{uri}},
2417 wakaba 1.6 DIS:sourceNode => {$n_node},
2418     DIS:anotherSourceNode => {$res->{src}},
2419     }__;
2420     }__;
2421     }
2422     $res->{nameURI} = $qn_uri;
2423 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
2424     $res->{localName} = $ln;
2425 wakaba 1.5 }
2426     } else {
2427 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2428 wakaba 1.5 $res->{<Q::isAnon>} = true;
2429     }
2430 wakaba 1.6 } # anon
2431 wakaba 1.5 $res->{for} = $forArg;
2432     $res->{forp} = $forpArg;
2433     $res->{src} = $el;
2434     $res->{<Q::definingModule>} = $mod->{uri};
2435 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
2436     (<Q::DIS:resource>, $res);
2437 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
2438     = $parentResource ? $parentResource->{uri} : null;
2439     $res->{<Q::dynamicParentResource>}
2440 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
2441     unless ($res->{uri} eq $node_uri) {
2442     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2443     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
2444     }
2445 wakaba 1.7 $res->{<Q::isDefined>} = true;
2446 wakaba 1.9 $res->{seq} = $self->{seq}++;
2447    
2448 wakaba 1.6 ## -- Alias
2449     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
2450     (<Q::dis:AliasFor>, for_arg => $forArg,
2451     forp_arg => $forpArg);
2452     if ($al_node) {
2453     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
2454     ($node_id, $forArg);
2455     my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
2456     ($canon_uri);
2457 wakaba 1.14 $canon_res-><AS::ManakaiDISResourceDefinition.isReferred> ($al_node);
2458 wakaba 1.11 $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias>
2459     ($res, node => $al_node);
2460 wakaba 1.6 $res = $canon_res;
2461     }
2462 wakaba 1.5
2463 wakaba 1.11 ## -- Registers as child
2464     $parentResource-><M::ManakaiDISPropertyAccessor
2465     .addPropertyResourceList>
2466     (<Q::DIS:childResource>, $res)
2467     if $parentResource;
2468     $dynParent-><M::ManakaiDISPropertyAccessor
2469     .addPropertyResourceList>
2470     (<Q::DIS:dynamicChildResource>, $res)
2471     if $dynParent;
2472    
2473 wakaba 1.7 my $is_multires = false;
2474     my @props;
2475     my @cres;
2476 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
2477     (for_arg => $forArg, forp_arg => $forpArg)};
2478 wakaba 1.7 while (@ce0) {
2479     my $ce = shift @ce0;
2480     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
2481     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
2482     $res->{<Q::rdf:type>}->{$type_uri} = true;
2483     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
2484 wakaba 1.14 $type-><AS::ManakaiDISResourceDefinition.isReferred> ($ce);
2485 wakaba 1.7 if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
2486     (<Q::dis:MultipleResource>)) {
2487     $is_multires = true;
2488     }
2489     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
2490     (<Q::dis:subsetOf>)) {
2491     my $sres = $self-><M::ManakaiDISDatabase.getResource>
2492     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
2493     ($node_id, $forArg));
2494     $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
2495 wakaba 1.11 } elsif ($ce-><AG::ManakaiDISElement.isResourceElement>) {
2496 wakaba 1.7 push @cres, $ce;
2497     } else {
2498     ## Property and invalid element is not checked, since not
2499     ## all property definitions has loaded at this stage.
2500     push @props, $ce;
2501     }
2502     } # @ce0
2503    
2504     ## -- Child resources
2505     unless ($is_multires) {
2506     for my $re (@cres) {
2507     unless ($al_node) {
2508     $self-><M::ManakaiDISDatabase.loadResource>
2509     ($mod, $res, $res, $re,
2510     for_arg => $forArg, forp_arg => $forpArg);
2511 wakaba 1.5 } else {
2512 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
2513     (<Q::dis:aliasChild>, for_arg => $forArg,
2514     forp_arg => $forpArg);
2515     if ($ac and $ac-><M::swcfg21:SWCFGNode
2516     ::swcfg21:ForLatest.value>) {
2517     $self-><M::ManakaiDISDatabase.loadResource>
2518     ($mod, $res, $res, $re,
2519     for_arg => $forArg, forp_arg => $forpArg);
2520     }
2521 wakaba 1.4 }
2522     }
2523 wakaba 1.7 }
2524 wakaba 1.5
2525 wakaba 1.7 ## -- Multiple representations
2526     if ($is_multires) {
2527     for my $pe (@props) {
2528     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
2529 wakaba 1.10 (<Q::dis:resourceFor>)) {
2530 wakaba 1.14 my $for_uri = $pe-><AG::ManakaiDISElement.qnameValueURI>;
2531 wakaba 1.7 my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
2532 wakaba 1.14 $for-><AS::ManakaiDISForDefinition.isReferred> ($pe);
2533 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
2534     ($mod, $parentResource, $res, $el,
2535     for_arg => $forArg,
2536     forp_arg => [@{$forpArg}, $for_uri]);
2537     }
2538     }
2539     }
2540 wakaba 1.5 }__; # DEEP
2541 wakaba 1.8
2542     @Method:
2543     @@Name: checkUndefinedResource
2544     @@enDesc:
2545     Checks whether there is referred but undefined resource or not.
2546     @@Return:
2547     @@@RaiseException:
2548     @@@@@: FOR_NOT_DEFINED_ERR
2549     @@@@enDesc:
2550     There is a <QUOTE::for> that is referred but not defined.
2551     @@@RaiseException:
2552     @@@@@: RESOURCE_NOT_DEFINED_ERR
2553     @@@@enDesc:
2554     There is a resource that is referred but not defined.
2555     @@@PerlDef:
2556     for my $fd (values %{$self->{forDef}}) {
2557     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
2558     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
2559     __EXCEPTION{FOR_NOT_DEFINED_ERR::
2560     DIS:uri => {$fd->{uri}},
2561     DIS:sourceNode => {$ref},
2562     }__;
2563     }
2564     }
2565     for my $fd (values %{$self->{resDef}}) {
2566     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
2567     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
2568     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2569     DIS:uri => {$fd->{uri}},
2570     DIS:sourceNode => {$ref},
2571     }__;
2572     }
2573     }
2574 wakaba 1.5
2575 wakaba 1.9
2576     @Method:
2577     @@Name: plStore
2578     @@enDesc:
2579     Saves this database to an external file.
2580     \
2581     {NOTE:: Saved files can be loaded by
2582     <M::ManakaiDISImplementation.plLoadDISDatabase>.
2583     \
2584     }
2585     @@Param:
2586     @@@Name: fileName
2587     @@@Type:
2588     DISLang:String
2589     @@@enDesc:
2590     An environment-dependent file name of external database to save.
2591     \
2592     {NOTE:: If there is already a file named as <P::fileName>, then
2593     it is overwritten.
2594     \
2595     }
2596     @@Return:
2597     @@@SimpleException:
2598     @@@PerlDef:
2599     use Storable qw/nstore/;
2600     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
2601     nstore $self, $fileName;
2602 wakaba 1.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 wakaba 1.14 $r = $self-><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>;
2904 wakaba 1.8 }
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 wakaba 1.14 my $an_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3554 wakaba 1.8 (<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 wakaba 1.14 $r = $an_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3560 wakaba 1.8 } 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 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plInterfaceName>
3572 wakaba 1.8 . '::' . $self->{localName};
3573     } else {
3574     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3575 wakaba 1.14 -><AG::ManakaiDISModuleDefinition.plFullyQualifiedName>
3576 wakaba 1.8 . '::' . $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.14 $r = $op_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3617 wakaba 1.8 } 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 wakaba 1.14 my $source_code = $def-><M::swcfg21:SWCFGNode
3854     ::swcfg21:ForLatest.value>;
3855 wakaba 1.12 $r = $self->{<Q::plCodeFragment>}
3856 wakaba 1.14 = $self-><M::ManakaiDISResourceDefinition
3857     .plPreprocessPerlStatement> ($source_code);
3858    
3859     # $r = $self->{<Q::plCodeFragment>}
3860     # = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
3861     # -><M::MPLImpl.createPerlUnparsedCode>
3862     # ($def-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>);
3863     # $r-><AS::MPLUnparsedCode.sourceFile>
3864     # ($self->{src}-><M::swcfg21:SWCFGNode
3865     # ::swcfg21:ForLatest.nodePath>
3866     # (key => [qw/Name QName type Type/]));
3867     # $r-><AS::MPLUnparsedCode.sourceLine> (1);
3868 wakaba 1.12 } elsif ($def-><M::ManakaiDISElement.mediaTypeMatch>
3869     (<Q::lang:dis>)) {
3870     $r = $self->{<Q::plCodeFragment>}
3871 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
3872 wakaba 1.12 -><M::MPLImpl.createPerlUnparsedCode>
3873 wakaba 1.14 ($def-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>);
3874 wakaba 1.12 ## TODO: implement
3875     } else {
3876     my $mt = $def-><M::ManakaiDISElement.mediaTypeURI>
3877     (for_arg => $self->{for},
3878     forp_arg => $self->{forp});
3879     __UNDEEP{
3880     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3881     DIS:uri => {$mt},
3882     DIS:sourceNode => {$def},
3883     }__;
3884     }__;
3885     } # media type
3886     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3887     (<Q::DISLang:Method>)) {
3888 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
3889 wakaba 1.12 my $ret = $self-><M::ManakaiDISResourceDefinition
3890     .getChildResourceByType> (<Q::DISLang:MethodReturn>);
3891     unless ($ret) {
3892     __UNDEEP{
3893     __EXCEPTION{NO_METHOD_RETURN_ERR::
3894     DIS:errResource => {$self},
3895     DIS:sourceNode => {$self->{src}},
3896     }__;
3897     }__;
3898     }
3899     $r = $self->{<Q::plCodeFragment>}
3900 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
3901 wakaba 1.12 -><M::MPLImpl.createPerlSub>
3902     ($self-><AG::ManakaiDISResourceDefinition.plName>);
3903    
3904    
3905     ## TODO: Parameter, sub, ...
3906 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
3907 wakaba 1.12 ($ret-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
3908    
3909     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3910     (<Q::DISLang:Attribute>)) {
3911 wakaba 1.13 $self->{<Q::plCodeFragment>} = null; ## To avoid loop
3912 wakaba 1.12 my $get = $self-><M::ManakaiDISResourceDefinition
3913     .getChildResourceByType> (<Q::DISLang:AttributeGet>);
3914     unless ($get) {
3915     __UNDEEP{
3916     __EXCEPTION{NO_ATTR_GET_ERR::
3917     DIS:errResource => {$self},
3918     DIS:sourceNode => {$self->{src}},
3919     }__;
3920     }__;
3921     }
3922     $r = $self->{<Q::plCodeFragment>}
3923 wakaba 1.14 = $self-><AG::ManakaiDISResourceDefinition.plImplementation>
3924 wakaba 1.12 -><M::MPLImpl.createPerlSub>
3925     ($self-><AG::ManakaiDISResourceDefinition.plName>);
3926    
3927    
3928     ## TODO: Parameter, sub, set, ...
3929 wakaba 1.13 $r-><M::MPLSS.appendCodeFragment>
3930 wakaba 1.12 ($get-><AG::ManakaiDISResourceDefinition.plCodeFragment>);
3931    
3932 wakaba 1.13 } else { ## Not supported
3933 wakaba 1.12 $r = $self->{<Q::plCodeFragment>} = null;
3934     } # rdf:type
3935     }__;
3936    
3937     @Attr:
3938     @@Name:plImplementation
3939     @@enDesc:
3940     The <Class::PerlCode:ManakaiPerlCodeImplementation> object.
3941     @@Type: MPLImpl
3942     @@Get:
3943     @@@enDesc:
3944     The Perl code implementation object.
3945     @@@nullCase:
3946     This resource has no source tree associated.
3947     @@@RaiseException:
3948     @@@@@:NO_PERL_CODE_IMPL_ERR
3949     @@@@enDesc:
3950     There is no implementation that implements
3951     the <Feature::Util:PerlCode> feature, version <FeatureVer::1.0>.
3952     @@@PerlDef:
3953     if ($self->{src}) {
3954     __DEEP{
3955     $r = ($self->{src}-><AG::SWCFGNode.ownerDocument> or
3956     $self->{src})-><AG::SWCFGDoc.implementation>
3957     -><M::DOMMinImpl.getFeature>
3958     (<Q::Util:PerlCode> => '1.0');
3959     }__;
3960     unless (defined $r) {
3961     __EXCEPTION{NO_PERL_CODE_IMPL_ERR::
3962    
3963     }__;
3964     }
3965     }
3966    
3967     @Method:
3968     @@Name: getChildResourceByType
3969     @@enDesc:
3970     Gets a static child resource selected by its type.
3971     @@Param:
3972     @@@Name:typeURI
3973     @@@Type:ResourceURI
3974     @@@enDesc:
3975     A URI reference identifying a resource type.
3976     @@Return:
3977     @@@Type: ManakaiDISResourceDefinition
3978     @@@enDesc:
3979     The first (by document order) child resource whose
3980     type matches with <P::resType>.
3981     @@@nullCase:
3982     @@@@enDesc:
3983     There is no resource whose type is <P::resType>.
3984     @@@PerlDef:
3985     __DEEP{
3986     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
3987     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
3988     ($cr_uri);
3989     if ($cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
3990     $r = $cr;
3991     last;
3992     }
3993     }
3994     }__;
3995 wakaba 1.13
3996     @Method:
3997     @@Name: getChildResourceByNameAndType
3998     @@enDesc:
3999     Gets a static child resource selected by its local name and type.
4000     @@Param:
4001     @@@Name: localName
4002     @@@Type:
4003     DISCore:LocalName::ManakaiDOM:all
4004     @@@enDesc:
4005     A local name.
4006     @@Param:
4007     @@@Name:typeURI
4008     @@@Type:ResourceURI
4009     @@@enDesc:
4010     A URI reference identifying a resource type.
4011     @@Return:
4012     @@@Type: ManakaiDISResourceDefinition
4013     @@@enDesc:
4014     The first (by document order) child resource whose
4015     type matches for <P::localName> and <P::resType>.
4016     @@@nullCase:
4017     @@@@enDesc:
4018     There is no resource whose name is <P::localName> and
4019     whose type is <P::resType>.
4020     @@@PerlDef:
4021     __DEEP{
4022     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4023     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4024     ($cr_uri);
4025 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
4026 wakaba 1.13 if (defined $ln and $ln eq $localName and
4027     $cr-><M::ManakaiDISResourceDefinition.isTypeURI> ($typeURI)) {
4028     $r = $cr;
4029     last;
4030     }
4031     }
4032     }__;
4033    
4034     @Method:
4035     @@Name: getConstResourceByName
4036     @@enDesc:
4037     Gets a constant value resource by its local name.
4038     @@Param:
4039     @@@Name:localName
4040     @@@Type:
4041     DISLang:String::ManakaiDOM:all
4042     @@@enDesc:
4043     Constant name.
4044     @@Return:
4045     @@@Type: ManakaiDISResourceDefinition
4046     @@@enDesc:
4047     The constant resource identified by <P::localName>.
4048     @@@nullCase:
4049     @@@@enDesc:
4050     There is no such constant resource.
4051     @@@PerlDef:
4052     __DEEP{
4053     my @constGroup;
4054     for my $cr_uri (@{$self->{<Q::DIS:childResource>}}) {
4055     my $cr = $self->{db}-><M::ManakaiDISDatabase.getResource>
4056     ($cr_uri);
4057 wakaba 1.14 my $ln = $cr-><AG::ManakaiDISResourceDefinition.localName>;
4058 wakaba 1.13 if ($ln and $ln eq $localName and
4059     $cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4060     (<Q::ManakaiDOM:Const>)) {
4061     $r = $cr;
4062     last;
4063     } elsif ($cr-><M::ManakaiDISResourceDefinition.isTypeURI>
4064     (<Q::ManakaiDOM:ConstGroup>)) {
4065     push @constGroup, $cr;
4066     }
4067     }
4068     unless ($r) {
4069     for my $cg (@constGroup) {
4070     $r = $cg-><M::ManakaiDISResourceDefinition
4071     .getChildResourceByNameAndType>
4072     ($localName, <Q::ManakaiDOM:Const>);
4073     last if $r;
4074     }
4075     }
4076     }__;
4077    
4078     @Method:
4079     @@Name: plPreprocessPerlCode
4080     @@enDesc:
4081     Preprocesses a Perl block-level code fragment.
4082     @@Param:
4083     @@@Name:codeArg
4084     @@@Type:
4085     lang:Perl::ManakaiDOM:all
4086     @@@enDesc:
4087     A Perl block-level code (statements and/or blocks).
4088     @@Return:
4089     @@@Type:
4090     lang:Perl::ManakaiDOM:all
4091     @@@enDesc:
4092     Preprocessed Perl code.
4093     @@@PerlDef:
4094     \##
4095    
4096     @Method:
4097     @@Name: plPreprocessPerlStatement
4098     @@enDesc:
4099     Preprocesses a Perl inline code fragment
4100     (code fragment smaller than statement).
4101     @@Param:
4102     @@@Name:codeArg
4103     @@@Type:
4104     lang:Perl::ManakaiDOM:all
4105     @@@enDesc:
4106     A Perl code fragment.
4107     @@NodeParam:
4108     @@Return:
4109     @@@Type:
4110     lang:Perl::ManakaiDOM:all
4111     @@@enDesc:
4112     Preprocessed Perl code.
4113     @@@InlineElementException:
4114     @@@PerlDef:
4115     unless ($self->{src}) {
4116     __EXCEPTION{NO_SOURCE_NODE_ERR::
4117     DIS:uri => {$self->{uri}},
4118     }__;
4119     }
4120     __DEEP{
4121     our $RegQNameChar;
4122     my $plimpl = $self-><AG::ManakaiDISResourceDefinition
4123     .plImplementation>;
4124     $r = $plimpl-><M::MPLImpl.createPerlInlineContainer>;
4125     for my $source_code (split /(?<![?^qwr])(\x3C$RegQNameChar[^<>]+> |
4126     \b(?:null|true|false)\b)/x, $codeArg) {
4127     if ($source_code =~ s/^\x3C//) {
4128     $source_code =~ s/>$//;
4129     if ($source_code =~ /=$/) {
4130     ## TODO: Warning
4131     # valid_warn qq<Inline element "\x3C$source_code>" ends with a "=" - >.
4132     # q{should "=" be used place of "=>"?};
4133     }
4134     if ($source_code =~ s/^(.+?):://) {
4135     my $et = $self->{src}
4136     -><M::ManakaiDISElement.qnameToURI>
4137     ($1,
4138     node => $node,
4139     default_namespace_uri => <Q::disPerl:>);
4140     if ($et eq <Q::disPerl:Q>) { ## QName constant
4141     $r-><M::PLAnyCon.appendStringLiteral>
4142     ($self->{src}
4143     -><M::ManakaiDISElement.qnameToURI>
4144     ($source_code, node => $node));
4145     } elsif ({
4146     <Q::disPerl:M> => 1,
4147     <Q::disPerl:ClassM> => 1,
4148     <Q::disPerl:AG> => 1,
4149     <Q::disPerl:AS> => 1,
4150     }->{$et}) { ## Method call
4151     my ($class_qname, $method_qname)
4152     = split /\s*\.\s*/, $source_code, 2;
4153     my $class_uri
4154     = $self->{src}
4155     -><M::ManakaiDISElement.tfqnamesToURI>
4156     ($class_qname,
4157     $self-><AG::ManakaiDISResourceDefinition
4158     .ownerClassURI>,
4159     $self->{for},
4160     node => $node);
4161     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4162     ($class_uri);
4163 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
4164 wakaba 1.13 ($node || $self->{src});
4165     if ($et eq <Q::disPerl::ClassM> and
4166     $class-><M::ManakaiDISResourceDefinition.isTypeURI>
4167     (<Q::ManakaiDOM:IF>)) {
4168     __UNDEEP{
4169     __EXCEPTION{INTERFACE_CLASS_METHOD_ERR::
4170     DIS:uri => {$class_uri},
4171     DIS:elementType => {$et},
4172     DIS:sourceNode => {$node || $self->{src}},
4173     DIS:sourceCode => {$source_code},
4174 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:IF>},
4175 wakaba 1.13 }__;
4176     }__;
4177     }
4178     unless ($class-><M::ManakaiDISResourceDefinition.isTypeURI>
4179     (<Q::ManakaiDOM:IF>)) {
4180     $self-><AG::ManakaiDISResourceDefinition.definingModule>
4181     -><M::ManakaiDISModuleDefinition.plAddRequireModule>
4182     ($class-><AG::ManakaiDISResourceDefinition
4183     .definingModule>);
4184     }
4185 wakaba 1.14 my $method = $class-><M::ManakaiDISResourceDefinition
4186 wakaba 1.13 .getChildResourceByNameAndType>
4187     ($method_qname,
4188     {
4189     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
4190     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
4191     }->{$et} || <Q::DISLang:Method>);
4192     if (not $method or
4193     not $method-><AG::ManakaiDISResourceDefinition
4194     .isDefined>) {
4195     __UNDEEP{
4196     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4197     DIS:localName => {$method_qname},
4198     DIS:elementType => {$et},
4199     DIS:sourceNode => {$node || $self->{src}},
4200     DIS:sourceCode => {$source_code},
4201 wakaba 1.14 DIS:expectedType => {{
4202     <Q::disPerl:AG> => <Q::DISLang:Attribute>,
4203     <Q::disPerl:AS> => <Q::DISLang:Attribute>,
4204     }->{$et} || <Q::DISLang:Method>},
4205 wakaba 1.13 }__;
4206     }__;
4207     }
4208     my $class_name = '';
4209     if ($et eq <Q::disPerl:ClassM>) {
4210     $class_name = $class-><AG::ManakaiDISResourceDefinition
4211     .plFullyQualifiedName> . '->';
4212     }
4213     my $method_name = $method-><AG::ManakaiDISResourceDefinition
4214     .plName>;
4215     $r-><M::PLAnyCon.appendBare>
4216     ($class_name . $method_name);
4217     } elsif ({
4218     <Q::disPerl:Class> => 1,
4219     <Q::disPerl:ClassName> => 1,
4220     <Q::disPerl:IF> => 1,
4221     <Q::disPerl:IFName> => 1,
4222     }->{$et}) { ## Perl package name
4223     my $class_uri
4224     = $self->{src}
4225     -><M::ManakaiDISElement.tfqnamesToURI>
4226     ($source_code,
4227     $self-><AG::ManakaiDISResourceDefinition
4228     .ownerClassURI>,
4229     $self->{for},
4230     node => $node);
4231     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4232     ($class_uri);
4233 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
4234 wakaba 1.13 ($node || $self->{src});
4235 wakaba 1.14 my $pack = $class-><AG::ManakaiDISResourceDefinition
4236 wakaba 1.13 .plFullyQualifiedName>;
4237 wakaba 1.14 unless ($pack) {
4238     __UNDEEP{__EXCEPTION{NO_PERL_PACKAGE_NAME_ERR::
4239     DIS:sourceNode => {$node || $self->{src}},
4240     DIS:sourceCode => {$source_code},
4241     DIS:uri => {$class_uri},
4242     DIS:elementType => {$et},
4243     }__}__;
4244     }
4245 wakaba 1.13 if ({
4246     <Q::disPerl:ClassName> => 1,
4247     <Q::disPerl:IFName> => 1,
4248     }->{$et}) {
4249     $r-><M::PLAnyCon.appendStringLiteral> ($pack);
4250     } else {
4251     $r-><M::PLAnyCon.appendBare> ($pack);
4252     }
4253     } elsif ($et eq <Q::disPerl:Code>) { ## Inline code
4254     my $code_name;
4255     $source_code =~ s/^\s+//;
4256     if ($source_code =~ s/^((?>(?!::).)+)//s) {
4257     $code_name = $1;
4258     $code_name =~ tr/|/:/;
4259     } else {
4260     __UNDEEP{
4261     __EXCEPTION{PERL_PREPROCESS_NO_CODE_NAME_ERR::
4262     DIS:sourceCode => {$source_code},
4263     DIS:sourceNode => {$node || $self->{src}},
4264     }__;
4265     }__;
4266     }
4267     $source_code =~ s/^::\s*//;
4268     my $param = $self-><M::ManakaiDISResourceDefinition
4269     .plParsePreprocessParameter>
4270     ($source_code, node => $node);
4271     my $code_uri = $self->{src}-><M::ManakaiDISElement
4272     .tfqnamesToURI>
4273     ($code_name, null, $self->{for},
4274     node => $node);
4275     my $code = $self->{db}-><M::ManakaiDISDatabase.getResource>
4276     ($code_uri);
4277 wakaba 1.14 $code-><AS::ManakaiDISResourceDefinition.isReferred>
4278 wakaba 1.13 ($node || $self->{src});
4279     unless ($code-><M::ManakaiDISResourceDefinition.isTypeURI>
4280     (<Q::dis2pm:InlineCode>)) {
4281     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4282     DIS:uri => {$code_uri},
4283     DIS:sourceNode => {$node || $self->{src}},
4284     DIS:sourceCode => {$source_code},
4285     DIS:expectedType => {<Q::dis2pm:InlineCode>},
4286     }__;}__;
4287     }
4288     my $pc = $code-><AG::ManakaiDISResourceDefinition
4289     .plCodeFragment>->clone;
4290     unless (defined $pc) {
4291     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4292     DIS:sourceNode => {$node || $self->{src}},
4293     DIS:sourceCode => {$source_code},
4294     DIS:uri => {$code_uri},
4295     }__}__;
4296     }
4297     for my $var (grep {/^\$/} keys %$param) {
4298     my $value;
4299     if ($param->{$var}->{type} eq 'variable') {
4300     $value = $plimpl-><M::MPLImpl.createPerlVariable>
4301     ('$', null, $param->{$var}->{value});
4302     } elsif ($param->{$var}->{type} eq 'code') {
4303     $value = $plimpl-><M::MPLImpl.createPerlInlineUnparsedCode>
4304     ($param->{$var}->{value});
4305     } else {
4306     $value = $plimpl-><M::MPLImpl.createPerlStringLiteral>
4307     ($param->{$var}->{value});
4308     }
4309     $pc-><M::MPLCodeFragment.replaceVariable>
4310     ($var => $value);
4311     }
4312     $r-><M::PLInCon.appendCode> ($pc);
4313     } elsif ($et eq <Q::disPerl:C>) {
4314     my ($class_qname, $const_name) = split /\./, $source_code, 2;
4315     my $class_uri
4316     = $self->{src}
4317     -><M::ManakaiDISElement.tfqnamesToURI>
4318     ($class_qname,
4319     $self-><AG::ManakaiDISResourceDefinition
4320     .ownerClassURI>,
4321     $self->{for},
4322     node => $node);
4323     my $class = $self->{db}-><M::ManakaiDISDatabase.getResource>
4324     ($class_uri);
4325 wakaba 1.14 $class-><AS::ManakaiDISResourceDefinition.isReferred>
4326 wakaba 1.13 ($node || $self->{src});
4327     my $const = $class-><M::ManakaiDISResourceDefinition
4328     .getConstResourceByName> ($const_name);
4329     unless (defined $const) {
4330     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
4331     DIS:sourceNode => {$node || $self->{src}},
4332     DIS:sourceCode => {$source_code},
4333     DIS:localName => {$const_name},
4334 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:Const>},
4335 wakaba 1.13 }__}__;
4336     }
4337 wakaba 1.14 my $pc = $const-><AG::ManakaiDISResourceDefinition
4338 wakaba 1.13 .plCodeFragment>->clone;
4339     unless (defined $pc) {
4340     __UNDEEP{__EXCEPTION{PERL_CODE_NOT_DEFINED_ERR::
4341     DIS:sourceNode => {$node || $self->{src}},
4342     DIS:sourceCode => {$source_code},
4343     DIS:localName => {$const_name},
4344     }__}__;
4345     }
4346     $r-><M::PLInCon.appendCodeFragment> ($pc);
4347     } else {
4348     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4349     DIS:elementType => {$et},
4350     DIS:sourceNode => {$node || $self->{src}},
4351     }__}__;
4352     }
4353     } else {
4354     __UNDEEP{__EXCEPTION{PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR::
4355     DIS:sourceNode => {$node || $self->{src}},
4356     DIS:sourceCode => {$source_code},
4357 wakaba 1.14 DIS:expectedType => {<Q::ManakaiDOM:ConstGroup>},
4358 wakaba 1.13 }__}__;
4359     }
4360     } elsif ({
4361     'tr'.'ue' => true,
4362     'fal'.'se' => true,
4363     'nu'.'ll' => true,
4364     }->{$source_code}) {
4365     $r-><M::PLAnyCon.appendAtom> ({
4366     'tr'.'ue' => 1,
4367     'fal'.'se' => 0,
4368     'nu'.'ll' => 'undef',
4369     }->{$source_code});
4370     } else {
4371     $r-><M::PLInCon.appendCode> ($source_code);
4372     }
4373     } # for
4374     }__; # DEEP
4375    
4376     @Attr:
4377     @@Name: ownerClassURI
4378     @@enDesc:
4379     The URI reference of the class resource this resource
4380     belongs to.
4381     @@Type: ResourceURI
4382     @@Get:
4383     @@@enDesc:
4384     The URI reference of the <TYPE::ManakaiDOM:Class> resource.
4385     If this resource is a class, then the URI reference
4386     of this resource is returned.
4387     @@@nullCase:
4388     @@@@enDesc:
4389     This resource does not belong to any class.
4390     @@@PerlDef:
4391     if (exists $self->{<Q::DIS:ownerClass>}) {
4392     $r = $self->{<Q::DIS:ownerClass>};
4393     } else {
4394     my $res = $self;
4395     __DEEP{
4396     {
4397     if ($res-><M::ManakaiDISResourceDefinition.isTypeURI>
4398     (<Q::ManakaiDOM:Class>)) {
4399     $r = $res->{uri};
4400     } else {
4401     $res = $res-><M::ManakaiDISPropertyAccessor
4402     .getPropertyResource> (<Q::dis2pm:parentResource>);
4403     redo if $res;
4404     }
4405     }
4406     }__;
4407     $self->{<Q::DIS:ownerClass>} = $r;
4408     }
4409    
4410     @IntMethod:
4411     @@Name: plParsePreprocessParameter
4412     @@enDesc:
4413     Parses a parameter specification in preprocessing instruction
4414     and return it as a hash reference.
4415     \
4416     {NOTE:: The callee have to ensure that this resource has its
4417     <CODE::src> before the call to this method.
4418     \
4419     }
4420     @@Param:
4421     @@@Name: paramSpec
4422     @@@Type:
4423     DISLang:String::ManakaiDOM:all
4424     @@@enDesc:
4425     A parameter specification to parse.
4426     @@NodeParam:
4427     @@Return:
4428     @@@Type:
4429     Perl:hash::ManakaiDOM:all
4430     @@@enDesc:
4431     Hash containing parameters. Each hash value is also
4432     a hash reference, containing two keys <CODE::type>
4433     (its value is either <CODE::bare>, <CODE::quoted>,
4434     <CODE::code> or <CODE::variable>) and
4435     <CODE::value>.
4436     @@@RaiseException:
4437     @@@@@:BROKEN_PARAM_SPEC_ERR
4438     @@@@enDesc:
4439     The <P::paramSpec> is not well-formed.
4440     @@@PerlDef:
4441     BEGIN{
4442     our $RegQNameChar = qr/[^\s<>"'\\\[\]\{\},=\$\@%]/;
4443     use re 'eval';
4444     our $RegBlockContent;
4445     $RegBlockContent = qr/(?>[^{}\\]*)(?>(?>[^{}\\]+|\\.|\{(??{
4446     $RegBlockContent})\})*)/s;
4447     }
4448    
4449     our $RegQNameChar;
4450     our $RegBlockContent;
4451     $r = {};
4452     while ($paramSpec =~ s/^
4453     ## Parameter name
4454     (\$? $RegQNameChar+)\s*
4455    
4456     (?: =>? \s*
4457     ## ">" is now optional for inline element (">" is delimiter)
4458    
4459     ## Parameter value
4460     (
4461     ## Bare string
4462     $RegQNameChar+
4463     |
4464     ## Quoted string
4465     '(?>[^'\\]*)' ## ISSUE: escape mechanism required?
4466     |
4467     ## Code
4468     \{$RegBlockContent\}
4469    
4470     )
4471    
4472     \s*)?
4473    
4474     (?:,\s*|$)//ox) {
4475    
4476     my ($n, $v) = ($1, $2);
4477     if (defined $v) {
4478     if ($v =~ /^'/) {
4479     $v = {type => 'quoted',
4480     value => substr ($v, 1, length ($v) - 2)};
4481     } elsif ($v =~ /^\{/) {
4482     $v = {type => 'code', value => substr ($v, 1, length ($v) - 2)};
4483     } elsif ($v =~ /^\$/) {
4484     $v => {type => 'variable', value => $v};
4485     } else {
4486     $v = {type => 'bare', value => $v};
4487     }
4488     } else {
4489     $v = {type => 'boolean', value => true};
4490     }
4491    
4492     if ($n =~ /^\$/) {
4493     $r->{$n} = $v;
4494     } else {
4495     __DEEP{
4496     $r->{$self->{src}-><M::ManakaiDISElement.qnameToURI>
4497     ($n, node => $node || $self->{src})} = $v;
4498     }__;
4499     }
4500     } # while
4501    
4502     if (length $paramSpec) {
4503     __EXCEPTION{BROKEN_PARAM_SPEC_ERR::
4504     DIS:sourceCode => {$paramSpec},
4505     DIS:sourceNode => {$node || $self->{src}},
4506     }__;
4507     }
4508    
4509 wakaba 1.2 ##DISResourceDefinition
4510    
4511 wakaba 1.13 ElementTypeBinding:
4512     @Name: InlineElementException
4513     @ElementType:
4514     ManakaiDOM:raises
4515     @ShadowContent:
4516     @@@: NO_SOURCE_NODE_ERR
4517     @@Description:
4518     @@@lang:en
4519     @@@@:
4520     This resource definition does not have associated node
4521     in the source tree.
4522     @ShadowSibling:
4523     @@ManakaiDOM:raises:
4524     @@@@: INTERFACE_CLASS_METHOD_ERR
4525     @@@Description:
4526     @@@@lang:en
4527     @@@@@:
4528     An attempt is made to call a class (static) method
4529     via an interface, not class.
4530     @@ManakaiDOM:raises:
4531     @@@@: RESOURCE_NOT_DEFINED_ERR
4532     @@@Description:
4533     @@@@lang:en
4534     @@@@@:
4535     A package, method or attribute is not defined or not
4536     a resoure of that type.
4537     @@ManakaiDOM:raises:
4538     @@@@: NO_LOCAL_NAME_ERR
4539     @@@Description:
4540     @@@@lang:en
4541     @@@@@:
4542     A referred resource does not have its local name so
4543     that it is impossible to refer it by name.
4544     @@ManakaiDOM:raises:
4545     @@@@: RESERVED_PERL_METHOD_NAME_ERR
4546     @@@Description:
4547     @@@@lang:en
4548     @@@@@:
4549     A referred method has its name reserved for special-purpose.
4550     @@ManakaiDOM:raises:
4551     @@@@: BROKEN_PARAM_SPEC_ERR
4552     @@@Description:
4553     @@@@lang:en
4554     @@@@@:
4555     A parameter specification is not well-formed.
4556     @@ManakaiDOM:raises:
4557     @@@@: PERL_PREPROCESS_NO_CODE_NAME_ERR
4558 wakaba 1.14 @@@Description:
4559     @@@@lang:en
4560     @@@@@:
4561     A preprocessing instruction does not contain
4562     Perl code fragment name.
4563 wakaba 1.13 @@ManakaiDOM:raises:
4564     @@@@: PERL_CODE_NOT_DEFINED_ERR
4565 wakaba 1.14 @@@Description:
4566     @@@@lang:en
4567     @@@@@:
4568     The referred resource does not have its Perl definition.
4569 wakaba 1.13 @@ManakaiDOM:raises:
4570     @@@@: PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
4571 wakaba 1.14 @@@Description:
4572     @@@@lang:en
4573     @@@@@:
4574     A preprocessing instruction does not contain its element type name.
4575 wakaba 1.13 @@ManakaiDOM:raises:
4576     @@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
4577 wakaba 1.14 @@@Description:
4578     @@@@lang:en
4579     @@@@@:
4580     An unknown element type is encounted.
4581     @@ManakaiDOM:raises:
4582     @@@@: NO_PERL_PACKAGE_NAME_ERR
4583     @@@Description:
4584     @@@@lang:en
4585     @@@@@:
4586     No Perl package name is defined for a class or interface.
4587 wakaba 1.13
4588     PropDef:
4589     @QName: ownerClass
4590     @enDesc:
4591     The class to which this resource belongs.
4592     @Type: ResourceURI
4593     @rdfs:range:
4594     rdf:Resource
4595     @rdfs:domain:
4596     ManakaiDOM:Class
4597    
4598 wakaba 1.12 ResourceDef:
4599     @QName: DOMMinImpl
4600     @rdf:type:
4601     ManakaiDOM:IF
4602     @AliasFor:
4603     DOMMetaImpl:ManakaiDOMMinimumImplementationIF::ManakaiDOM:ManakaiDOMLatest
4604    
4605     ResourceDef:
4606     @QName: SWCFGNode
4607     @rdf:type:
4608     ManakaiDOM:IF
4609     @AliasFor:
4610     swcfg21:SWCFGNode::swcfg21:ForLatest
4611    
4612     ResourceDef:
4613     @QName: SWCFGDoc
4614     @rdf:type:
4615     ManakaiDOM:IF
4616     @AliasFor:
4617     swcfg21:SWCFGDocument::swcfg21:ForLatest
4618    
4619     ResourceDef:
4620     @QName: MPLImpl
4621     @rdf:type:
4622     ManakaiDOM:Class
4623     @AliasFor:
4624     PerlCode:ManakaiPerlCodeImplementation::ManakaiDOM:Perl
4625    
4626     ResourceDef:
4627     @QName: MPLCodeFragment
4628     @rdf:type:
4629     ManakaiDOM:Class
4630     @AliasFor:
4631     PerlCode:ManakaiPerlCodeFragment::ManakaiDOM:Perl
4632    
4633     ResourceDef:
4634 wakaba 1.13 @QName: PLInCon
4635     @rdf:type:
4636     ManakaiDOM:Class
4637     @AliasFor:
4638     PerlCode:ManakaiPerlInlineContainer::ManakaiDOM:Perl
4639    
4640     ResourceDef:
4641     @QName: PLAnyCon
4642     @rdf:type:
4643     ManakaiDOM:Class
4644     @AliasFor:
4645     PerlCode:ManakaiPerlAnyContainer::ManakaiDOM:Perl
4646    
4647     ResourceDef:
4648     @QName: MPLSS
4649     @rdf:type:
4650     ManakaiDOM:Class
4651     @AliasFor:
4652     PerlCode:ManakaiPerlStatementContainer::ManakaiDOM:Perl
4653    
4654     ResourceDef:
4655 wakaba 1.12 @QName: MPLSub
4656     @rdf:type:
4657     ManakaiDOM:Class
4658     @AliasFor:
4659     PerlCode:ManakaiPerlSub::ManakaiDOM:Perl
4660    
4661     ResourceDef:
4662     @QName: MPLUnparsedCode
4663     @rdf:type:
4664     ManakaiDOM:Class
4665     @AliasFor:
4666     PerlCode:ManakaiPerlUnparsedCode::ManakaiDOM:Perl
4667    
4668     PropDef:
4669     @QName: plCodeFragment
4670     @enDesc:
4671     Cache for <A::ManakaiDISResourceDefinition.plCodeFragment>.
4672    
4673     XParamDef:
4674     @QName: errResource
4675     @enDesc:
4676     A resource on which an error has occurred.
4677    
4678 wakaba 1.8 XParamDef:
4679     @QName: generatedName
4680     @enDesc:
4681     A generated name.
4682    
4683 wakaba 1.2 ClsDef:
4684     @ClsQName: ManakaiDISPropertyAccessor
4685 wakaba 1.3 @enDesc:
4686 wakaba 1.2 Accessor methods for resource or module properties.
4687    
4688     @Method:
4689 wakaba 1.8 @@Name: getPropertyBoolean
4690     @@enDesc:
4691     Gets boolean property value.
4692     @@PropNameParam:
4693     @@Param:
4694     @@@Name:default
4695     @@@Type:
4696     DOMMain:boolean::ManakaiDOM:all
4697     @@@enDesc:
4698     The default value that is returned if no explicit property
4699     value specification found for this resource.
4700     @@Return:
4701     @@@Type:
4702     DOMMain:boolean::ManakaiDOM:all
4703     @@@enDesc:
4704     The property value.
4705     @@@PerlDef:
4706     if (exists $self->{$propName}) {
4707     $r = defined $self->{$propName} ? $self->{$propName} : $default;
4708     } elsif ($self->{src}) {
4709     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4710     ($propName, for_arg => $self->{for},
4711     forp_arg => $self->{forp});
4712     $self->{$propName} = $r;
4713     $r = $default unless defined $r;
4714     } else {
4715     $r = $default;
4716     }
4717    
4718     @Method:
4719 wakaba 1.2 @@Name: getPropertyText
4720     @@enDesc:
4721     Gets property value text.
4722     @@PropNameParam:
4723     @@Param:
4724     @@@Name:default
4725     @@@Type:
4726 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
4727 wakaba 1.2 @@@enDesc:
4728     The default value that is returned if no explicit property
4729     value specification found for this resource.
4730     @@@nullCase:
4731     @@@@enDesc:
4732     No default value supplied; <DOM::null> is returned if
4733     no value specified.
4734     @@Return:
4735     @@@Type:
4736 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
4737 wakaba 1.2 @@@enDesc:
4738     The property value string.
4739     @@@nullCase:
4740     @@@@enDesc:
4741     No value nor default value has specified.
4742     @@@PerlDef:
4743     if (exists $self->{$propName}) {
4744     $r = defined $self->{$propName} ? $self->{$propName} : $default;
4745     } elsif ($self->{src}) {
4746     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4747     ($propName, for_arg => $self->{for},
4748     forp_arg => $self->{forp});
4749 wakaba 1.8 if ($r) {
4750     $r = $self->{$propName}
4751 wakaba 1.14 = $r-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
4752 wakaba 1.8 $r = $default unless defined $r;
4753     } else {
4754     $r = $default;
4755     $self->{$propName} = null;
4756     }
4757 wakaba 1.2 } else {
4758     $r = $default;
4759     }
4760    
4761     @Method:
4762     @@Name: getPropertyResource
4763     @@enDesc:
4764     Gets property value resource.
4765     @@PropNameParam:
4766 wakaba 1.10 @@NamedParam:
4767     @@@Name: defaultMediaType
4768     @@@Type: ResourceURI
4769     @@@enDesc:
4770     The URI reference of the default media type which is used
4771     when the property value is retrieved from the source tree
4772     and the source tree element does not have its <Q::dis:ContentType>
4773     attribute specified.
4774     @@@nullCase:
4775     @@@@enDesc:
4776     Defaulted to <Q::dis:TypeQName>.
4777 wakaba 1.2 @@Return:
4778     @@@Type: ManakaiDISResourceDefinition
4779     @@@enDesc:
4780     The property value resource.
4781     @@@nullCase:
4782     @@@@enDesc:
4783     No value has specified.
4784 wakaba 1.8 @@@UndeclaredPrefixException:
4785 wakaba 1.12 @@@RaiseException:
4786     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4787     @@@@enDesc:
4788     The media type of the attribute node in the source tree
4789     corresponding to this resource is not supported.
4790 wakaba 1.2 @@@PerlDef:
4791     if (defined $self->{$propName}) {
4792 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4793     ($self->{$propName});
4794 wakaba 1.8 } elsif ($self->{src}) {
4795     __DEEP{
4796     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
4797     ($propName, for_arg => $self->{for},
4798     forp_arg => $self->{forp});
4799     if ($r) {
4800 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
4801     unless defined $defaultMediaType;
4802     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
4803 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
4804     for_arg => $self->{for},
4805     forp_arg => $self->{forp})) {
4806 wakaba 1.10 $self->{$propName}
4807     = $r-><AG::ManakaiDISElement.qnameValueURI>;
4808     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
4809 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
4810     for_arg => $self->{for},
4811     forp_arg => $self->{forp})) {
4812 wakaba 1.10 $self->{$propName}
4813     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
4814     ($self->{src}-><AG::swcfg21:SWCFGNode
4815     ::swcfg21:ForLatest.nodeID>,
4816     $self->{for});
4817     } else {
4818     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
4819     (for_arg => $self->{for},
4820     forp_arg => $self->{forp});
4821     __UNDEEP{
4822     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4823     DIS:uri => {$mt},
4824     DIS:sourceNode => {$r},
4825     }__;
4826     }__;
4827     }
4828 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
4829     ($self->{$propName});
4830 wakaba 1.14 $r-><AS::ManakaiDISResourceDefinition.isReferred> ($self->{src});
4831 wakaba 1.8 }
4832     }__;
4833 wakaba 1.2 }
4834    
4835     @Method:
4836 wakaba 1.10 @@Name: getPropertyResourceList
4837     @@enDesc:
4838     Gets property value resource list.
4839     @@PropNameParam:
4840     @@NamedParam:
4841     @@@Name: recursiveISA
4842     @@@Type:
4843     DOMMain:boolean
4844     @@@enDesc:
4845     Whether property resource values of <Q::dis:ISA> resources
4846     of this resource should also be included to the returned list or not.
4847     @@NamedParam:
4848     @@@Name: defaultMediaType
4849     @@@Type: ResourceURI
4850     @@@enDesc:
4851     The URI reference of the default media type which is used
4852     when the property value is retrieved from the source tree
4853     and the source tree element does not have its <Q::dis:ContentType>
4854     attribute specified.
4855     @@@nullCase:
4856     @@@@enDesc:
4857     Defaulted to <Q::dis:TypeQName>.
4858     @@Return:
4859     @@@Type: ResourceList
4860     @@@enDesc:
4861     An array reference of the property value resources.
4862     \
4863     {NOTE:: This list is <QUOTE::dead>.
4864     \
4865     }
4866     @@@UndeclaredPrefixException:
4867 wakaba 1.12 @@@RaiseException:
4868     @@@@@:UNSUPPORTED_MEDIA_TYPE_ERR
4869     @@@@enDesc:
4870     The media type of the attribute node in the source tree
4871     corresponding to this resource is not supported.
4872 wakaba 1.10 @@@PerlDef:
4873     $r = [];
4874     if (defined $self->{$propName}) {
4875     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
4876     ? $self->{$propName} : []}) {
4877     push @$r,
4878     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
4879     }
4880     } elsif ($self->{src}) {
4881     __DEEP{
4882     $self->{$propName} = [];
4883     $defaultMediaType = <Q::dis:TypeQName>
4884     unless defined $defaultMediaType;
4885     for my $res_name_node
4886     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
4887     ($propName, for_arg => $self->{for},
4888     forp_arg => $self->{forp})}) {
4889     my $res_uri;
4890     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
4891 wakaba 1.12 (<Q::dis:TypeQName>, $defaultMediaType,
4892     for_arg => $self->{for},
4893     forp_arg => $self->{forp})) {
4894 wakaba 1.10 $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
4895     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
4896 wakaba 1.12 (<Q::dis:TFQNames>, $defaultMediaType,
4897     for_arg => $self->{for},
4898     forp_arg => $self->{forp})) {
4899 wakaba 1.10 $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
4900     ($self->{src}-><AG::swcfg21:SWCFGNode
4901     ::swcfg21:ForLatest.nodeID>,
4902     $self->{for});
4903     } else {
4904     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
4905     (for_arg => $self->{for},
4906     forp_arg => $self->{forp});
4907     __UNDEEP{
4908     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
4909     DIS:uri => {$mt},
4910     DIS:sourceNode => {$res_name_node},
4911     }__;
4912     }__;
4913     }
4914     push @{$self->{$propName}}, $res_uri;
4915     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
4916     ($res_uri);
4917     push @$r, $res;
4918 wakaba 1.14 $res-><AS::ManakaiDISResourceDefinition.isReferred>
4919 wakaba 1.10 ($res_name_node);
4920     }
4921     }__;
4922     }
4923     if ($recursiveISA) {
4924     __DEEP{
4925     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
4926     my @p_res = @$r;
4927     for my $p_res (@p_res) {
4928     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
4929     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
4930     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
4931     .getPropertyResourceList>
4932     (<Q::dis:ISA>, recursive_isa => true,
4933     ___recursive_isa_done => $opt{___recursive_isa_done},
4934     default_media_type => $defaultMediaType)};
4935     }
4936     }__;
4937     }
4938    
4939     @Method:
4940 wakaba 1.2 @@Name: addPropertyResourceList
4941     @@enDesc:
4942     Adds a resource to a resource-list property value.
4943     \
4944     {ISSUE:: Should an exception be thrown if the property is
4945     not of list?
4946     \
4947     }
4948 wakaba 1.10 \
4949     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
4950     an item clears the list --- i.e. the property values
4951     in the source tree will be ignored. Call
4952     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
4953     before adding to avoid this behavior.
4954     \
4955     }
4956 wakaba 1.2 @@PropNameParam:
4957     @@Param:
4958     @@@Name: res
4959     @@@Type: ManakaiDISResourceDefinition
4960     @@@enDesc:
4961     A resource to add.
4962     @@Return:
4963     @@@PerlDef:
4964     if (ref $self->{$propName} eq 'ARRAY') {
4965     push @{$self->{$propName}}, $res->{uri};
4966     } elsif (not defined $self->{$propName}) {
4967     $self->{$propName} = [$res->{uri}];
4968     }
4969    
4970 wakaba 1.3 ElementTypeBinding:
4971     @Name: PropNameParam
4972     @ElementType:
4973     dis:ResourceDef
4974     @ShadowContent:
4975     @@rdf:type:
4976     DISLang:MethodParameter
4977     @@Name: propName
4978     @@Type: ResourceURI
4979     @@Description:
4980     @@@lang:en
4981     @@@@:
4982     The name of the property.
4983    
4984 wakaba 1.2 ##DISPropertyAccessor
4985    
4986     PropDef:
4987     @QName:isAnon
4988     @Description:
4989     @@lang:en
4990     @@@:
4991     Whether the subject resource is anonymous or not.
4992     @Type:
4993     DOMMain:boolean
4994    
4995     PropDef:
4996     @QName:isDefined
4997     @Description:
4998     @@lang:en
4999     @@@:
5000     Whether the subject resource is defined or not.
5001    
5002     PropDef:
5003 wakaba 1.3 @QName:isReferred
5004 wakaba 1.2 @Description:
5005     @@lang:en
5006     @@@:
5007     Whether the subject resource is referred or not.
5008     @Type:
5009     DOMMain:any
5010    
5011     PropDef:
5012     @QName:definingModule
5013     @Description:
5014     @@lang:en
5015     @@@:
5016     The <QUOTE::dis> module in which the subject resource is defined.
5017     @rdfs:domain:
5018     DISCore:Module
5019 wakaba 1.1
5020     ## -- Datatypes
5021    
5022     URITypeDef:
5023 wakaba 1.3 @QName: AnyURI
5024     @Description:
5025     @@lang:en
5026     @@@:
5027     Any URI references.
5028    
5029     URITypeDef:
5030     @QName: FileURI
5031     @enDesc:
5032     URI references identifying file.
5033    
5034     URITypeDef:
5035 wakaba 1.1 @QName: ForURI
5036     @Description:
5037     @@lang:en
5038     @@@:
5039     <QUOTE::For> URI references.
5040    
5041     DataTypeDef:
5042     @QName: ForURIList
5043     @Description:
5044     @@lang:en
5045     @@@:
5046     References to the array containing <QUOTE::for> URI references.
5047    
5048     URITypeDef:
5049 wakaba 1.3 @QName: ResourceURI
5050     @Description:
5051     @@lang:en
5052     @@@:
5053     A URI reference for a <QUOTE::dis> resource.
5054    
5055     URITypeDef:
5056 wakaba 1.1 @QName: MediaTypeURI
5057     @Description:
5058     @@lang:en
5059     @@@:
5060     Media type URI references.
5061 wakaba 1.3 @rdfs:subClassOf: ResourceURI
5062    
5063     URITypeDef:
5064     @QName: ModuleURI
5065     @enDesc:
5066     URI references for <QUOET::dis> modules.
5067     @rdfs:subClassOf: ResourceURI
5068    
5069     URITypeDef:
5070     @QName: NameURI
5071     @enDesc:
5072     URI references identifying a resource.
5073     @rdfs:subClassOf: ResourceURI
5074 wakaba 1.10
5075     DataTypeDef:
5076     @QName: ResourceList
5077     @enDesc:
5078     References to array containing resource definition objects.
5079     @rdfs:subClassOf:
5080     Perl:ARRAY::ManakaiDOM:all
5081 wakaba 1.3
5082     ElementTypeBinding:
5083     @Name: DataTypeDef
5084     @ElementType:
5085     dis:ResourceDef
5086     @ShadowContent:
5087     @@rdf:type:
5088     ManakaiDOM:DataType
5089    
5090     ElementTypeBinding:
5091     @Name: URITypeDef
5092     @ElementType:
5093     dis:ResourceDef
5094     @ShadowContent:
5095     @@rdf:type:
5096     ManakaiDOM:DataType
5097     @@rdfs:subClassOf: AnyURI
5098 wakaba 1.1
5099     ## -- Exceptions
5100    
5101     XParamDef:
5102 wakaba 1.5 @QName: anotherSourceNode
5103     @enDesc:
5104     Another source node in which an error has occurred. In cases
5105     of <QUOTE::already defined> errors, it is the node that
5106     defines the resource first.
5107     @Type: ManakaiDISNode
5108 wakaba 1.3
5109 wakaba 1.12 ResourceDef:
5110     @QName: UNDECLARED_NS_PREFIX_ERR
5111     @For: ForLatest
5112     @AliasFor:
5113     DIS:UNDECLARED_NS_PREFIX_ERR::swcfg21:ForLatest
5114    
5115 wakaba 1.3 ExceptionDef:
5116     @ClsQName: ManakaiDISException
5117     @enDesc:
5118     Exceptions for the <QUOTE::dis> operations.
5119 wakaba 1.4 @ClsISA:
5120     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
5121 wakaba 1.3 @XConstGroupDef:
5122     @@ClsQName: ManakaiDISExceptionCode
5123     @@enDesc:
5124     Exception codes for <Class::ManakaiDISException>.
5125     @@XConstDef:
5126 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
5127     @@@Value:3
5128     @@@enDesc:
5129     An attempt is made to break the hierarchy.
5130     @@@XSubTypeDef:
5131     @@@@QName: MERGE_ITSELF_ERR
5132     @@@@enDesc:
5133     An attempt is made to merge the resource to itself.
5134     @@@@XSourceNodeParam:
5135     @@@@XParam:
5136     @@@@@QName:uri
5137     @@@@@enDesc:
5138     The URI reference of the resource to merge.
5139     @@@@enMufDef:
5140     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
5141     );> to itself
5142     @@XConstDef:
5143 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
5144     @@@Value:9
5145     @@@enDesc:
5146     An attempt is made to do something the implementation does not support.
5147     @@@XSubTypeDef:
5148     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
5149     @@@@enDesc:
5150     The implementation does not support the media type.
5151     @@@@XParam:
5152     @@@@@QName: uri
5153     @@@@@enDesc:
5154     The URI reference of the media type that is not supported.
5155     @@@@XSourceNodeParam:
5156 wakaba 1.12 @@@@enMufDef:
5157     Media type <%p (name => {<Q::DIS:uri>});> is not supported
5158 wakaba 1.3 @@@XSubTypeDef:
5159 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
5160     @@@@enDesc:
5161     An unsupported type of element is encounted.
5162     @@@@XSourceNodeParam:
5163     @@@@XParam:
5164     @@@@@QName:elementType
5165     @@@@@enDesc:
5166     The element type URI reference of the element.
5167     @@@XSubTypeDef:
5168 wakaba 1.12 @@@@QName: NO_PERL_CODE_IMPL_ERR
5169 wakaba 1.3 @@@@enDesc:
5170 wakaba 1.12 There is no implementation that supports the
5171     <Feature::Util:PerlCode> feature, version
5172     <FeatureVer::1.0>.
5173 wakaba 1.3 @@XConstDef:
5174     @@@Name: INVALID_STATE_ERR
5175     @@@Value:11
5176     @@@enDesc:
5177     An attempt is made to use an object that is not (or no longer) usable.
5178     @@@XSubTypeDef:
5179     @@@@QName: NO_ASSOCIATED_DB_ERR
5180     @@@@enDesc:
5181     No <QUOTE::dis> database has been associated with this document.
5182 wakaba 1.4 @@XConstDef:
5183     @@@Name: INVALID_SOURCE_ERR
5184     @@@Value: 200
5185     @@@enDesc:
5186     The source input is well-formed but invalid.
5187     @@@XSubTypeDef:
5188     @@@@QName: NO_MODULE_QNAME_ERR
5189     @@@@enDesc:
5190     The <Q::dis:Module> element must have its <Q::dis:QName>
5191     attribute.
5192 wakaba 1.8 @@@@XSourceNodeParam:
5193     @@@XSubTypeDef:
5194     @@@@QName: NO_LOCAL_NAME_ERR
5195     @@@@enDesc:
5196     The resource does not have a local name.
5197     @@@@XSourceNodeParam:
5198 wakaba 1.4 @@@XSubTypeDef:
5199     @@@@QName: UNABLE_TO_GET_MODULE_ERR
5200     @@@@enDesc:
5201     The implementation is unable to get the module source.
5202     @@@@Def:
5203     @@@@@ContentType:
5204     lang:muf
5205     @@@@@lang:en
5206     @@@@@@:
5207     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
5208     @@@@XParam:
5209     @@@@@QName: uri
5210     @@@@@enDesc:
5211     The URI reference of the module.
5212     @@@@XParam:
5213     @@@@@QName: namespaceURI
5214     @@@@@enDesc:
5215     The namespace URI of the module name.
5216     @@@@XParam:
5217     @@@@@QName: localName
5218     @@@@@enDesc:
5219     The local name of the module name.
5220     @@@@XParam:
5221     @@@@@QName: for
5222     @@@@@enDesc:
5223     The <QUOTE::for> of the module.
5224 wakaba 1.5 @@@XSubTypeDef:
5225     @@@@QName: NO_FOR_QNAME_ERR
5226     @@@@enDesc:
5227     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
5228     @@@@XSourceNodeParam:
5229     @@@XSubTypeDef:
5230     @@@@QName: FOR_ALREADY_DEFINED_ERR
5231     @@@@enDesc:
5232     The <QUOTE::for> named as the same URI reference has
5233     already defined.
5234     @@@@XSourceNodeParam:
5235     @@@@XParam:
5236     @@@@@QName: anotherSourceNode
5237     @@@@@enDesc:
5238     The node that defines the <QUOTE::for> URI reference before.
5239 wakaba 1.7 @@@@XParam:
5240     @@@@@Name: uri
5241     @@@@@enDesc:
5242     The URI reference of the <QUOTE::for> attempted to define.
5243     @@@@enMufDef:
5244     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
5245 wakaba 1.5 @@@XSubTypeDef:
5246     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
5247     @@@@enDesc:
5248     The <QUOTE::dis> resource named as the same URI reference has
5249     already defined.
5250     @@@@XSourceNodeParam:
5251     @@@@XParam:
5252     @@@@@QName: anotherSourceNode
5253     @@@@@enDesc:
5254     The node that defines the <QUOTE::for> URI reference before.
5255 wakaba 1.7 @@@@XParam:
5256     @@@@@Name: uri
5257     @@@@@enDesc:
5258     The URI reference of the resource attempted to define.
5259     @@@@enMufDef:
5260     Resource <%p (name => {<Q::DIS:uri>});> is already defined
5261 wakaba 1.5 @@@XSubTypeDef:
5262     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
5263     @@@@enDesc:
5264     An element has occured where it is not allowed.
5265     @@@@enMufDef:
5266     Module <%p (name => {<Q::DIS:uri>});>:
5267     Element of type <%p (name => {<Q::DIS:elementType>});>
5268     is not allowed here
5269     @@@@XSourceNodeParam:
5270     @@@@XParam:
5271     @@@@@QName: elementType
5272     @@@@@enDesc:
5273     The expanded element type name of the element.
5274     @@@@XParam:
5275     @@@@@QName: uri
5276     @@@@@enDesc:
5277     The URI reference of the module.
5278 wakaba 1.7 @@@XSubTypeDef:
5279     @@@@QName: NO_REQUIRED_ATTR_ERR
5280     @@@@enDesc:
5281     A required attribute is not specified.
5282     @@@@XSourceNodeParam:
5283     @@@@XParam:
5284     @@@@@QName: elementType
5285     @@@@@enDesc:
5286     The expanded URI reference of the attribute name.
5287     @@@@enMufDef:
5288     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
5289 wakaba 1.8 @@@XSubTypeDef:
5290     @@@@QName: FOR_NOT_DEFINED_ERR
5291     @@@@enDesc:
5292     A <QUOTE::for> is referred but not defined.
5293     @@@@XSourceNodeParam:
5294     @@@@XParam:
5295     @@@@@QName: uri
5296     @@@@@enDesc:
5297     The URI reference of the <QUOTE::for> that is not defined.
5298     @@@@enMufDef:
5299     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
5300     @@@XSubTypeDef:
5301     @@@@QName: RESOURCE_NOT_DEFINED_ERR
5302     @@@@enDesc:
5303 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
5304     or the resource referred does not have the type expected.
5305 wakaba 1.8 @@@@XSourceNodeParam:
5306     @@@@XParam:
5307     @@@@@QName: uri
5308     @@@@@enDesc:
5309     The URI reference of the resource that is not defined.
5310 wakaba 1.13 @@@@XParam:
5311     @@@@@QName: elementType
5312     @@@@@enDesc:
5313     <QUOTE::dis> element type (either tree element type
5314     or preprocessing element type) of the element
5315     in which a reference to the undefined resource is contained.
5316     @@@@XParam:
5317     @@@@@QName: localName
5318     @@@@@enDesc:
5319     The local name of the undefined resource.
5320     @@@@XParam:
5321     @@@@QName: sourceCode
5322     @@@@enDesc:
5323     Source code fragment that referres this resource.
5324     @@@@XParam:
5325     @@@@@QName:expectedType
5326     @@@@@enDesc:
5327     Expected resource type.
5328 wakaba 1.8 @@@@enMufDef:
5329 wakaba 1.14 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": });
5330 wakaba 1.13 Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
5331     suffix => {>});%p (name => {<Q::DIS:localName>},
5332     prefix => { "}, suffix => {"}); is not defined or wrong type%p
5333     (name => {<Q::DIS:expectedType>}, prefix => { (<},
5334     suffix => {> is expected)});
5335     @@@XSubTypeDef:
5336     @@@@QName: NO_SOURCE_NODE_ERR
5337     @@@@enDesc:
5338     A resource does not have associated node in the source tree.
5339     @@@@XSourceNodeParam:
5340     @@@@XParam:
5341     @@@@@QName:uri
5342     @@@@@enDesc:
5343     The URI reference of the resource.
5344 wakaba 1.8 @@@XSubTypeDef:
5345     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
5346     @@@@enDesc:
5347     A reserved Perl method name is used.
5348     @@@@XParam:
5349     @@@@@QName:uri
5350     @@@@@enDesc:
5351     The URI reference of the method resource.
5352     @@@@XSourceNodeParam:
5353     @@@@XParam:
5354     @@@@@QName: generatedName
5355     @@@@@enDesc:
5356     A reserved method name.
5357     @@@XSubTypeDef:
5358     @@@@QName: NO_DIS_TYPE_ERR
5359     @@@@enDesc:
5360     <Q::dis:Type> attribute is not found.
5361     @@@@XSourceNodeParam:
5362 wakaba 1.12 @@@XSubTypeDef:
5363     @@@@QName: NO_METHOD_RETURN_ERR
5364     @@@@enDesc:
5365     A <Q::DISLang:Method> resource does not have any
5366     <Q::DISLang:MethodReturn> child.
5367     @@@@XSourceNodeParam:
5368     @@@XSubTypeDef:
5369     @@@@QName: NO_ATTR_GET_ERR
5370     @@@@enDesc:
5371     A <Q::DISLang:Attribute> resource does not have any
5372     <Q::DISLang:AttributeGet> child.
5373     @@@@XSourceNodeParam:
5374 wakaba 1.13 @@@XSubTypeDef:
5375     @@@@QName:INTERFACE_CLASS_METHOD_ERR
5376     @@@@enDesc:
5377     An attempt is made to call a static (class) method
5378     from an interface.
5379     @@@@XSourceNodeParam:
5380     @@@@XParam:
5381     @@@@@QName:uri
5382     @@@@@enDesc:
5383     The URI reference of the interface.
5384     @@@@XParam:
5385     @@@@@QName:sourceCode
5386     @@@@@enDesc:
5387     Source code fragment that calls a class method.
5388     @@@@XParam:
5389     @@@@@QName:elementType
5390     @@@@@enDesc:
5391     The element type URI reference of the element
5392     that calls a method.
5393     @@@XSubTypeDef:
5394     @@@@QName: BROKEN_PARAM_SPEC_ERR
5395     @@@@enDesc:
5396     A parameter specification is broken.
5397     @@@@XParam:
5398     @@@@@QName: sourceCode
5399     @@@@@enDesc:
5400     Source code fragment that contains the broken parameter
5401     specification.
5402     @@@@XSourceNodeParam:
5403     @@@XSubTypeDef:
5404     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
5405     @@@@enDesc:
5406     A preprocessing instruction does not have its element
5407     type.
5408     @@@@XSourceNodeParam:
5409     @@@@XParam:
5410     @@@@@QName:sourceCode
5411     @@@@@enDesc:
5412     Source code fragment.
5413     @@@XSubTypeDef:
5414     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
5415     @@@@enDesc:
5416     A preprocessing instruction requires Perl code
5417     fragment name but it is not specified.
5418     @@@@XSourceNodeParam:
5419     @@@@XParam:
5420     @@@@@QName: sourceCode
5421     @@@@@enDesc:
5422     Source code fragment.
5423     @@@@XParam:
5424     @@@@@QName:elementType
5425     @@@@@enDesc:
5426     The type of the element in which code name should have
5427     been specified.
5428     @@@XSubTypeDef:
5429     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
5430     @@@@enDesc:
5431     A resource does not have its Perl definition.
5432     @@@@XSourceNodeParam:
5433     @@@@XParam:
5434     @@@@@QName:sourceCode
5435     @@@@@enDesc:
5436     Source code fragment.
5437     @@@@XParam:
5438     @@@@@QName:localName
5439     @@@@@enDesc:
5440     The local name of the resource referred.
5441     @@@@XParam:
5442     @@@@@QName:uri
5443     @@@@@enDesc:
5444     The URI reference of the resource referred.
5445 wakaba 1.14 @@@XSubTypeDef:
5446     @@@@QName: NO_PERL_PACKAGE_NAME_ERR
5447     @@@@enDesc:
5448     No Perl package name is defined for the resource referred.
5449     @@@@XSourceNodeParam:
5450     @@@@XParam:
5451     @@@@@QName:sourceCode
5452     @@@@@enDesc:
5453     Source code fragment.
5454     @@@@XParam:
5455     @@@@@QName:uri
5456     @@@@@enDesc:
5457     THe URI reference of the resource referred.
5458     @@@@XParam:
5459     @@@@@QName:elementType
5460     @@@@@enDesc:
5461     The element type of Perl preprocessing instruction
5462     in which the resource is referred.
5463     @@@@enMufDef:
5464     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
5465     package name is not defined
5466 wakaba 1.4 ##DISException
5467 wakaba 1.13
5468     XParamDef:
5469     @QName:expectedType
5470     @Type: ResourceURI
5471     @enDesc:
5472     Expected resource type URI reference.
5473    
5474     XParamDef:
5475     @QName: sourceCode
5476     @Type:
5477     DISLang:String::ManakaiDOM:all
5478     @enDesc:
5479     The source code fragment in which an error occurred.
5480 wakaba 1.5
5481     XParamDef:
5482     @QName: elementType
5483     @Type: ResourceURI
5484     @enDesc:
5485     The name of the element type.
5486    
5487     XParamDef:
5488     @QName: uri
5489     @Type: ResourceURI
5490     @enDesc:
5491     The name of the resource, composed from <Q::namespaceURI>,
5492     <Q::localName> and <Q::for>.
5493    
5494     XParamDef:
5495     @QName: localName
5496     @Type:
5497     DISCore:LocalName
5498     @enDesc:
5499     The local name of the resource, unique in <Q::namespaceURI> namespace.
5500    
5501     XParamDef:
5502     @QName: namespaceURI
5503     @Type: AnyURI
5504     @enDesc:
5505     The namespace URI reference of the resource name.
5506    
5507     XParamDef:
5508     @QName: for
5509     @Type: ForURI
5510     @enDesc:
5511     The <QUOTE::for> URI reference of the resource.
5512    
5513     ElementTypeBinding:
5514     @Name: XSourceNodeParam
5515     @ElementType:
5516     ManakaiDOM:exceptionOrWarningParameter
5517     @ShadowContent:
5518     @@QName: sourceNode
5519     @@Description:
5520     @@@lang:en
5521     @@@@:
5522     The node in which an error has occurred.
5523 wakaba 1.4
5524     ClsDef:
5525     @ClsQName: ManakaiDISExceptionTarget
5526     @enDesc:
5527     Objects that is able to be the target of an exception.
5528     @IntMethod:
5529     @@Operator:
5530     @@@@:
5531     ManakaiDOM:MUErrorHandler
5532     @@@ContentType:
5533     dis:TypeQName
5534     @@Description:
5535     @@@lang:en
5536     @@@@:
5537     This method is a generic error handler; all manakai exceptions
5538     and warnings associated to an object are once reported to this method
5539     and then delivered to appropriate entities.
5540     \
5541     If the error is an exception (such as <X::DOMCore:DOMException> or
5542     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
5543     simply thrown. If the error is only a warning, it is reported
5544     via the <IF::DOMCore:DOMError> interface.
5545     \
5546     See <PerlModule::Message::Util::Error> documentation for more
5547     information on the error reporting mechanism.
5548     \
5549     {NOTE:: This kind of methods are named as <Perl::___report_error>
5550     in the convention of <PerlModule::Message::Util::Error>.
5551     \
5552     }
5553     @@Param:
5554     @@@Name:err
5555     @@@Type:
5556     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
5557     @@@Description:
5558     @@@@lang:en
5559     @@@@@:
5560     An exception object that describes what kind of error it is
5561     and how it should be recovered.
5562     \
5563     {NOTE:: Exception objects in manakai implementation
5564     inherit the class <PerlModule::Message::Util::Error>,
5565     that in turn inherits <PerlModule::Error>.
5566     \
5567     }
5568     @@Return:
5569     @@@PerlDef:
5570     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
5571     ::ManakaiDOM:Perl>)) {
5572     $err->throw;
5573     } else {
5574     \## TODO: Implement warning reporting
5575     warn $err->stringify;
5576     }
5577     ##DISExceptionTarget
5578    
5579     ForDef:
5580     @QName:
5581     DIS:ForIF
5582     ForDef:
5583     @QName:
5584     DIS:ForClass
5585    
5586     ElementTypeBinding:
5587     @Name: IFClsDef
5588     @ElementType:
5589     dis:ResourceDef
5590     @ShadowContent:
5591     @@rdf:type:
5592     @@@@:
5593     dis:MultipleResource
5594     @@@ForCheck: !ForClass !ForIF
5595     @@rdf:type:
5596     @@@@:
5597     ManakaiDOM:IF
5598     @@@ForCheck: ForIF
5599     @@rdf:type:
5600     @@@@:
5601     ManakaiDOM:Class
5602     @@@ForCheck: ForClass
5603     @@resourceFor: ForIF
5604     @@resourceFor:
5605     @@@@: ForClass
5606     @@@ForCheck: ForLatest
5607     @@DOMMain:implementFeature:
5608     @@@@:CoreFeature10
5609     @@@ForCheck: ForClass
5610     @@ForCheck:
5611     ManakaiDOM:Perl
5612 wakaba 1.3
5613     ElementTypeBinding:
5614     @Name: ClsDef
5615     @ElementType:
5616     dis:ResourceDef
5617     @ShadowContent:
5618     @@rdf:type:
5619     ManakaiDOM:Class
5620     @@AliasFor:
5621     @@@@:
5622 wakaba 1.11 ::DIS:ForLatest
5623 wakaba 1.3 @@@For:
5624 wakaba 1.11 !=DIS:ForLatest
5625 wakaba 1.3 @@ForCheck:
5626     ManakaiDOM:Perl
5627     @@DOMMain:implementFeature: CoreFeature10
5628    
5629     ElementTypeBinding:
5630     @Name: ExceptionDef
5631     @ElementType:
5632     dis:ResourceDef
5633     @ShadowContent:
5634     @@rdf:type:
5635     ManakaiDOM:ExceptionClass
5636     @@AliasFor:
5637     @@@@:
5638     ::ForLatest
5639     @@@For:
5640     !=ForLatest
5641     @@ForCheck:
5642     ManakaiDOM:Perl
5643     @@DOMMain:implementFeature: CoreFeature10
5644    
5645     ElementTypeBinding:
5646     @Name: ClsQName
5647     @ElementType:
5648     dis:QName
5649    
5650     ElementTypeBinding:
5651     @Name: ClsISA
5652     @ElementType:
5653     dis:ISA
5654    
5655     ElementTypeBinding:
5656     @Name: Method
5657     @ElementType:
5658     dis:ResourceDef
5659     @ShadowContent:
5660     @@rdf:type:
5661     DISLang:Method
5662    
5663     ElementTypeBinding:
5664     @Name: IntMethod
5665     @ElementType:
5666     dis:ResourceDef
5667     @ShadowContent:
5668     @@rdf:type:
5669     DISLang:Method
5670     @@ManakaiDOM:isForInternal:1
5671    
5672     ElementTypeBinding:
5673     @Name: Attr
5674     @ElementType:
5675     dis:ResourceDef
5676     @ShadowContent:
5677     @@rdf:type:
5678     DISLang:Attribute
5679    
5680     ElementTypeBinding:
5681     @Name: Return
5682     @ElementType:
5683     dis:ResourceDef
5684     @ShadowContent:
5685     @@rdf:type:
5686     DISLang:MethodReturn
5687    
5688     ElementTypeBinding:
5689     @Name: Get
5690     @ElementType:
5691     dis:ResourceDef
5692     @ShadowContent:
5693     @@rdf:type:
5694     DISLang:AttributeGet
5695    
5696     ElementTypeBinding:
5697     @Name: Set
5698     @ElementType:
5699     dis:ResourceDef
5700     @ShadowContent:
5701     @@rdf:type:
5702     DISLang:AttributeSet
5703    
5704     ElementTypeBinding:
5705     @Name: Param
5706     @ElementType:
5707     dis:ResourceDef
5708     @ShadowContent:
5709     @@rdf:type:
5710     DISLang:MethodParameter
5711    
5712     ElementTypeBinding:
5713     @Name: PerlDef
5714     @ElementType:
5715     dis:Def
5716     @ShadowContent:
5717     @@ContentType:
5718     lang:Perl
5719    
5720     ElementTypeBinding:
5721     @Name: disDef
5722     @ElementType:
5723     dis:Def
5724     @ShadowContent:
5725     @@ContentType:
5726     lang:dis
5727    
5728     ElementTypeBinding:
5729     @Name: InCase
5730     @ElementType:
5731     dis:ResourceDef
5732     @ShadowContent:
5733     @@rdf:type:
5734     ManakaiDOM:InCase
5735    
5736     ElementTypeBinding:
5737     @Name: nullCase
5738     @ElementType:
5739     dis:ResourceDef
5740     @ShadowContent:
5741     @@rdf:type:
5742     ManakaiDOM:InCase
5743     @@Value:
5744     @@@is-null:1
5745    
5746     ElementTypeBinding:
5747     @Name: TrueCase
5748     @ElementType:
5749     dis:ResourceDef
5750     @ShadowContent:
5751     @@rdf:type:
5752     ManakaiDOM:InCase
5753     @@Value:true
5754     @@Type:
5755     DOMMain:boolean
5756    
5757    
5758     ElementTypeBinding:
5759     @Name: FalseCase
5760     @ElementType:
5761     dis:ResourceDef
5762     @ShadowContent:
5763     @@rdf:type:
5764     ManakaiDOM:InCase
5765     @@Value:false
5766     @@Type:
5767     DOMMain:boolean
5768    
5769     ElementTypeBinding:
5770     @Name: enDesc
5771     @ElementType:
5772     dis:Description
5773     @ShadowContent:
5774     @@lang:en
5775    
5776     ElementTypeBinding:
5777     @Name: PropDef
5778     @ElementType:
5779     dis:ResourceDef
5780     @ShadowContent:
5781     @@rdf:type:
5782     rdf:Property
5783     @@AliasFor:
5784     @@@@:
5785     ::ManakaiDOM:all
5786     @@@For:
5787     !=ManakaiDOM:all
5788    
5789     ElementTypeBinding:
5790     @Name: MethodRedef
5791     @ElementType:
5792     dis:ResourceDef
5793     @ShadowContent:
5794     @@rdf:type:
5795     DISLang:Method
5796     @@ManakaiDOM:isRedefining:1
5797    
5798     ElementTypeBinding:
5799     @Name: NamedParam
5800     @ElementType:
5801     dis:ResourceDef
5802     @ShadowContent:
5803     @@rdf:type:
5804     DISLang:MethodParameter
5805     @@DISPerl:isNamedParameter:1
5806    
5807     ElementTypeBinding:
5808     @Name: NodeParam
5809     @ElementType:
5810     dis:ResourceDef
5811     @ShadowContent:
5812     @@rdf:type:
5813     DISLang:MethodParameter
5814     @@DISPerl:isNamedParameter:1
5815     @@Name: node
5816     @@Type: ManakaiDISNode
5817     @@Description:
5818     @@@lang:en
5819     @@@@:
5820     The node in which the name has occurred. It is intended
5821     to be reported when an exception had been raised.
5822     @@ResourceDef:
5823     @@@rdf:type:
5824     ManakaiDOM:InCase
5825     @@@Value:
5826     @@@@is-null:1
5827     @@@Description:
5828     @@@@lang:en
5829     @@@@@:
5830     The source of the name is not a node.
5831    
5832     ElementTypeBinding:
5833     @Name: ForParam
5834     @ElementType:
5835     dis:ResourceDef
5836     @ShadowContent:
5837     @@rdf:type:
5838     DISLang:MethodParameter
5839     @@DISPerl:isNamedParameter:1
5840     @@Name: forArg
5841     @@Type: ForURI
5842     @@Description:
5843     @@@lang:en
5844     @@@@:
5845     The <QUOTE::for> URI reference.
5846     @@ResourceDef:
5847     @@@rdf:type:
5848     ManakaiDOM:InCase
5849     @@@Value:
5850     @@@@is-null:1
5851     @@@Description:
5852     @@@@lang:en
5853     @@@@@:
5854     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
5855    
5856     ElementTypeBinding:
5857     @Name: ForpParam
5858     @ElementType:
5859     dis:ResourceDef
5860     @ShadowContent:
5861     @@rdf:type:
5862     DISLang:MethodParameter
5863     @@DISPerl:isNamedParameter:1
5864     @@Name: forpArg
5865     @@Type: ForURIList
5866     @@Description:
5867     @@@lang:en
5868     @@@@:
5869     An array reference containing additional <QUOTE::for>
5870     constraints (<QUOTE::For+> list).
5871     @@ResourceDef:
5872     @@@rdf:type:
5873     ManakaiDOM:InCase
5874     @@@Value:
5875     @@@@is-null:1
5876     @@@Description:
5877     @@@@lang:en
5878     @@@@@:
5879     Equivalent to the empty array reference.
5880    
5881     ElementTypeBinding:
5882     @Name: MediaTypeParam
5883     @ElementType:
5884     dis:ResourceDef
5885     @ShadowContent:
5886     @@rdf:type:
5887     DISLang:MethodParameter
5888     @@DISPerl:isNamedParameter:1
5889     @@Name: mediaType
5890     @@Type: MediaTypeURI
5891     @@Description:
5892     @@@lang:en
5893     @@@@:
5894     The URI reference identifying a media type.
5895     @@ResourceDef:
5896     @@@rdf:type:
5897     ManakaiDOM:InCase
5898     @@@Value:
5899     @@@@is-null:1
5900     @@@Description:
5901     @@@@lang:en
5902     @@@@@:
5903     No media type specified.
5904    
5905     ElementTypeBinding:
5906     @Name: MediaTypeDefaultParam
5907     @ElementType:
5908     dis:ResourceDef
5909     @ShadowContent:
5910     @@rdf:type:
5911     DISLang:MethodParameter
5912     @@DISPerl:isNamedParameter:1
5913     @@Name: defaultMediaType
5914     @@Type: MediaTypeURI
5915     @@Description:
5916     @@@lang:en
5917     @@@@:
5918     The default media type, i.e. the type used when no explicit
5919     specification is not found in the source tree.
5920     @@ResourceDef:
5921     @@@rdf:type:
5922     ManakaiDOM:InCase
5923     @@@Value:
5924     @@@@is-null:1
5925     @@@Description:
5926     @@@@lang:en
5927     @@@@@:
5928     Defaulted to <Q::DOMMain:any>.
5929    
5930     ElementTypeBinding:
5931     @Name: RaiseException
5932     @ElementType:
5933     ManakaiDOM:raises
5934    
5935     ElementTypeBinding:
5936     @Name: UndeclaredPrefixException
5937     @ElementType:
5938     ManakaiDOM:raises
5939     @ShadowContent:
5940     @@@: UNDECLARED_NS_PREFIX_ERR
5941     @@Description:
5942     @@@lang:en
5943     @@@@:
5944     The implementation has encounted an undeclared namespace prefix.
5945    
5946     ElementTypeBinding:
5947     @Name: NoDBException
5948     @ElementType:
5949     ManakaiDOM:raises
5950     @ShadowContent:
5951     @@@: NO_DB_ASSOCIATED_ERR
5952     @@Description:
5953     @@@lang:en
5954     @@@@:
5955     No <QUOTE::dis> database is associated to this document.
5956    
5957     ElementTypeBinding:
5958     @Name: XConstGroupDef
5959     @ElementType:
5960     dis:ResourceDef
5961     @ShadowContent:
5962     @@rdf:type:
5963     ManakaiDOM:ConstGroup
5964     @@Type:
5965     DOMMain:unsigned-short::ManakaiDOM:all
5966     @@rdfs:subClassOf:
5967     DOMMain:unsigned-short::ManakaiDOM:all
5968    
5969     ElementTypeBinding:
5970     @Name: XConstDef
5971     @ElementType:
5972     dis:ResourceDef
5973     @ShadowContent:
5974     @@rdf:type:
5975     ManakaiDOM:Const
5976    
5977     ElementTypeBinding:
5978     @Name: XSubTypeDef
5979     @ElementType:
5980     dis:ResourceDef
5981     @ShadowContent:
5982     @@rdf:type:
5983     ManakaiDOM:ExceptionOrWarningSubType
5984    
5985     ElementTypeBinding:
5986     @Name: XParam
5987     @ElementType:
5988     ManakaiDOM:exceptionOrWarningParameter
5989    
5990     ElementTypeBinding:
5991     @Name: XParamDef
5992     @ElementType:
5993     dis:ResourceDef
5994     @ShadowContent:
5995     @@rdf:type:
5996     DOMMain:XWParameter
5997 wakaba 1.12 @@For:
5998     =ManakaiDOM:all
5999 wakaba 1.3
6000     ElementTypeBinding:
6001     @Name: enMufDef
6002     @ElementType:
6003     dis:Def
6004     @ShadowContent:
6005     @@ContentType:
6006     lang:muf
6007     @@lang:en
6008    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24