/[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.10 - (hide annotations) (download)
Sat Mar 5 08:09:29 2005 UTC (20 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.9: +314 -45 lines
lib/Message/Util/DIS.dis: forMatch now works; disAllChildElements added since disChildElements is for-sensitive

1 wakaba 1.1 Module:
2     @QName:
3     Util:DIS
4     @FullName:
5     @@lang: en
6     @@@:
7     <QUOTE::DIS> Object Model
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
10    
11     @Description:
12     @@lang:en
13     @@@:
14     This module provides an object model for <QUITE::dis> document format.
15    
16     @Author:
17     @@FullName: Wakaba
18     @@Mail: w@suika.fam.cx
19     @License:
20     @@@:
21     license:Perl+MPL
22     @@Original:
23     @@@FullName:
24     manakai <CODE::lib/manakai/dis.pl>
25     @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.10 $Date: 2005/03/04 12:18:52 $
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    
47     @DefaultFor:
48     DIS:ForLatest
49 wakaba 1.1
50     Namespace:
51     @DIS:
52     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
53     @dis:
54     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
55     @dis2pm:
56     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
57 wakaba 1.5 @DISlib:
58     http://suika.fam.cx/~wakaba/archive/2004/dis/
59 wakaba 1.3 @DOMCore:
60     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
61     @DOMLS:
62     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
63     @DOMMain:
64     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
65     @infoset:
66     http://www.w3.org/2001/04/infoset#
67 wakaba 1.1 @lang:
68     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
69     @license:
70     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
71     @ManakaiDOM:
72     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
73 wakaba 1.5 @Markup:
74     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
75 wakaba 1.3 @MDOMX:
76     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
77 wakaba 1.1 @owl:
78     http://www.w3.org/2002/07/owl#
79     @Perl:
80     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
81     @rdf:
82     http://www.w3.org/1999/02/22-rdf-syntax-ns#
83     @rdfs:
84     http://www.w3.org/2000/01/rdf-schema#
85 wakaba 1.3 @swcfg21:
86     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
87 wakaba 1.1 @TreeCore:\
88     @Util:
89     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
90    
91     ## -- "For" definitions
92    
93     ForDef:
94     @QName:
95     DIS:ForLatest
96     @Description:
97     @@lang:en
98     @@@:
99     For latest version of the <Module::Util:DIS> module implementation
100     @ISA:
101     ManakaiDOM:Perl
102    
103     ## -- Features
104    
105     ElementTypeBinding:
106     @Name: FeatureDef
107     @ElementType:
108     dis:ResourceDef
109     @ShadowContent:
110     @@rdf:type:
111     DOMMain:DOMFeature
112     @@AliasFor:
113     @@@@:
114     ::ManakaiDOM:all
115     @@@For:
116     !=ManakaiDOM:all
117    
118     ElementTypeBinding:
119     @Name: FeatureVerDef
120     @ElementType:
121     dis:ResourceDef
122     @ShadowContent:
123     @@rdf:type:
124     DOMMain:DOMFeature
125    
126     ElementTypeBinding:
127     @Name: featureQName
128     @ElementType:
129     dis:AppName
130     @ShadowContent:
131     @@ContentType:
132     dis:TypeQName
133    
134     FeatureDef:
135     @QName: Core
136     @FeatureVerDef:
137     @@QName: CoreFeature10
138     @@Version: 1.0
139     @@ISA: Core
140     @@FullName:
141     @@@lang:en
142     @@@@:
143     The <QUOTE::dis> object model, version 1.0
144     @@Description:
145     @@@lang:en
146     @@@@:
147     The <QUOTE::dis> object model, version 1.0.
148     @@DOMMain:requireFeature:
149     swcfg21:CoreFeature21
150    
151     ## -- SuikaWikiConfig/2.1 extended classes
152    
153     ClsDef:
154     @ClsQName: ManakaiDISImplementation
155     @ClsISA:
156 wakaba 1.3 swcfg21:ManakaiSWCFGImplementation::swcfg21:ForLatest
157 wakaba 1.1 @Description:
158     @@lang:en
159     @@@:
160     A <QUOTE::dis> implementation object.
161    
162     @Method:
163     @@Name: createDISDocument
164     @@Description:
165     @@@lang:en
166     @@@@:
167     Creates an empty <Class::ManakaiDISDocument> object.
168     @@Return:
169     @@@Type:ManakaiDISDocument
170     @@@Description:
171     @@@@lang:en
172     @@@@@:
173     The newly created <QUOTE::dis> document object.
174     @@@PerlDef:
175 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
176     .createSWCFGDocument>;
177     $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
178     .defaultElementTypeNamespaceURI>
179 wakaba 1.1 (<Q::dis:>);
180    
181     @Method:
182 wakaba 1.2 @@Name: createDISParser
183     @@Description:
184     @@@lang:en
185     @@@@:
186 wakaba 1.1 Creates a <Class::ManakaiDISParser> object.
187 wakaba 1.2 @@Return:
188     @@@Type: ManakaiDISParser
189     @@@Description:
190     @@@@lang:en
191     @@@@@:
192 wakaba 1.1 A newly created <QUOTE::dis> parser.
193 wakaba 1.2 @@@PerlDef:
194 wakaba 1.3 $r = bless $self-><M::swcfg21:SWCFGImplementation::swcfg21:ForLatest
195     .createSWCFGParser>,
196 wakaba 1.1 <ClassName::ManakaiDISParser>;
197    
198     @Method:
199 wakaba 1.2 @@Name: createDISDatabase
200 wakaba 1.1 @@Description:
201     @@@lang:en
202     @@@@:
203 wakaba 1.2 Creates a new <QUOTE::dis> database.
204 wakaba 1.1 @@Return:
205 wakaba 1.2 @@@Type:ManakaiDISDatabase
206 wakaba 1.4 @@@Description:
207     @@@@lang:en
208     @@@@@:
209 wakaba 1.2 A newly created <QUOTE::dis> parser.
210 wakaba 1.4 @@@PerlDef:
211 wakaba 1.2 $r = bless {
212     forDef => {
213 wakaba 1.5 <Q::ManakaiDOM:all> => bless ({
214 wakaba 1.2 uri => <Q::ManakaiDOM:all>,
215     isa => {<Q::ManakaiDOM:all> => 1},
216     revISA => {},
217 wakaba 1.5 }, <ClassName::ManakaiDISForDefinition>),
218 wakaba 1.2 },
219     resDef => {},
220 wakaba 1.9 modDef => {},
221     seq => 0,
222 wakaba 1.3 }, <ClassName::ManakaiDISDatabase>;
223    
224     @Method:
225     @@Name: tfurisToURI
226     @@Description:
227     @@@lang:en
228     @@@@:
229     Converts a pair of name URI reference and <QUOTE::for> URI reference
230     into a <TYPE::dis:TFQNames>-expanded URI reference.
231     @@Param:
232     @@@Name: typeURI
233     @@@Type: NameURI
234     @@@Description:
235     @@@@lang:en
236     @@@@@:
237     A URI reference to identify a resource.
238     @@@InCase:
239     @@@@Value:
240     @@@@@is-null:1
241     @@@@Description:
242     @@@@@lang:en
243     @@@@@@:
244     Equivalent to <Q::DOMMain:any> (for historical reason).
245     @@Param:
246     @@@Name: forURI
247     @@@Type: ForURI
248     @@@Description:
249     @@@@lang:en
250     @@@@@:
251     A <QUOTE::for> URI reference.
252     @@@InCase:
253     @@@@Value:
254     @@@@@is-null:1
255     @@@@Description:
256     @@@@@lang:en
257     @@@@@@:
258     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
259     @@Return:
260     @@@Type:
261     DISCore:TFURI::ManakaiDOM:all
262     @@@Description:
263     @@@@lang:en
264     @@@@@:
265     The <TYPE::dis:TFQNames>-expanded URI references.
266     @@@PerlDef:
267     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
268     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
269 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
270    
271     @ResourceDef:
272     @@QName: tfurisToURI
273     @@rdf:type:
274     dis2pm:BlockCode
275     @@enDesc:
276     Converts a pair of name URI reference and <QUOTE::for> URI reference
277     into a <TYPE::dis:TFQNames>-expanded URI reference.
278     @@PerlDef:
279     if ($furi eq <Q::ManakaiDOM:all>) {
280     $uri = $turi;
281 wakaba 1.3 } else {
282     ## NOTE: [RFC 3986]
283     ## fragment := *(pchar / "/" / "?")
284     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
285     ## unreserved := ALPHA / DIGIT / [._~-]
286     ## sub-delims := [!$&'()*+,;=]
287     ## NOTE: [XPointer Framework]
288     ## SchemeData := *EscapedData
289     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
290     ## / "(" SchemeData ")"
291     ## NormalChar := UnicodeChar - [()^]
292 wakaba 1.5 my $__turi = $turi;
293     my $__furi = $furi;
294     for my $__uri ($__turi, $__furi) {
295 wakaba 1.4 $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
296 wakaba 1.3 }
297 wakaba 1.4 $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
298 wakaba 1.5 qq<t:tf($__turi,$__furi)>;
299 wakaba 1.3 }
300 wakaba 1.2
301 wakaba 1.5 @ResourceDef:
302 wakaba 1.6 @@QName: tfpurisToURI
303     @@rdf:type:
304     dis2pm:BlockCode
305     @@enDesc:
306     Converts a set of name URI reference and <QUOTE::for> URI reference
307     and <QUOTE::for+> URI references into a URi reference.
308     @@PerlDef:
309     if ($furi eq <Q::ManakaiDOM:all> and @{$forp} == 0) {
310     $uri = $turi;
311     } elsif (@{$forp}) {
312     my $__turi = $turi;
313     my $__furi = $furi;
314     for my $__uri ($__turi, $__furi) {
315     $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
316     }
317     my @__fp;
318     for my $__uri (@{$forp}) {
319     my $__fpuri = $__uri;
320     $__fpuri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}
321     {sprintf '%%%02X', ord $1}ge;
322     push @__fp, $__fpuri;
323     }
324     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
325     qq<t:tfp($__turi,$__furi,>.join (',', @__fp).q<)>;
326     } else {
327     my $__turi = $turi;
328     my $__furi = $furi;
329     for my $__uri ($__turi, $__furi) {
330     $__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
331     }
332     $uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
333     qq<t:tf($__turi,$__furi)>;
334     }
335    
336     @ResourceDef:
337 wakaba 1.5 @@QName: getChildResourceURI
338     @@rdf:type:
339     dis2pm:BlockCode
340     @@enDesc:
341     Gets an anonymous URI reference of a child resource of another
342     resource.
343     @@PerlDef:
344     my $__parent = $parentURI;
345     my $__ln = $localName;
346     for my $__uri ($__parent, $__ln) {
347 wakaba 1.6 $__uri =~ s{([^0-9A-Za-z:;?=_./~!&+-])}{sprintf '%%%02X', ord $1}ge;
348 wakaba 1.5 }
349     $result = q<data:,200411tf#xmlns(t=data:,200411tf%23)>.
350     qq<t:child($__parent,$__ln)>;
351    
352 wakaba 1.8 @IntMethod:
353     @@Name: camelCaseToUnderscoreName
354     @@enDesc:
355     Converts a camelCase name to a underscored_name.
356     @@ManakaiDOM:isStatic:1
357     @@Param:
358     @@@Name: camelName
359     @@@Type:
360     DISLang:String
361     @@@enDesc:
362     The source name.
363     @@Return:
364     @@@Type:
365     DISLang:String
366     @@@enDesc:
367     The result name.
368     @@@PerlDef:
369     $r = $camelName;
370     $r =~ s/^([A-Z0-9]+)$/lc $1/ge;
371     $r =~ s/([A-Z][A-Z0-9]*)$/"_".lc $1/ge;
372     $r =~ s/([A-Z0-9])([A-Z0-9]*)([A-Z0-9])/$1.lc ($2)."_".lc $3/ge;
373     $r =~ s/([A-Z])/"_".lc $1/ge;
374     $r =~ s/(?=[0-9](?!$))/_/g;
375 wakaba 1.9
376     @Method:
377     @@Name: plLoadDISDatabase
378     @@enDesc:
379     Loads a database from a file that was saved by
380     <M::ManakaiDISDatabase.plStore>.
381     \
382     {NOTE:: <QUOTE::dis> documents restored from external file
383     would have different <A::ManakaiDISDocument.implementation>
384     than this <Class::ManakaiDISImplementation>, even if
385     it has been created by this implementation
386     and stored in the same session.
387     \
388     }
389     @@Param:
390     @@@Name:fileName
391     @@@Type:
392     DISLang:String
393     @@@enDesc:
394     An environment-dependent file name.
395     @@Return:
396     @@@Type: ManakaiDISDatabase
397     @@@SimpleException:
398     @@@PerlDef:
399     use Storable qw/retrieve/;
400     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
401     $r = retrieve $fileName;
402    
403     ## Restores weak references
404     require Scalar::Util;
405     for my $doc (values %{$r->{<Q::DIS:sourceFile>}}) {
406     Scalar::Util::weaken ($doc->{<Q::TreeCore:node>}->{<Q::DIS:db>});
407     }
408     for my $def (values %{$r->{modDef}},
409     values %{$r->{forDef}},
410     values %{$r->{resDef}}) {
411     Scalar::Util::weaken ($def->{db});
412     }
413 wakaba 1.1 ##DISImplementation
414    
415 wakaba 1.9 ElementTypeBinding:
416     @Name: SimpleException
417     @ElementType:
418     dis:Description
419     @ShadowContent:
420     @@lang:en
421     @@@:
422     - Exception of type <PerlModule::Error::Simple>:::
423     I/O error or other error reported by <PerlModule::Storable>.
424    
425     ## TODO: Formal description required for simple exception
426    
427 wakaba 1.1 ClsDef:
428     @ClsQName: ManakaiDISParser
429     @ClsISA:
430 wakaba 1.3 swcfg21:ManakaiSWCFGParser::swcfg21:ForLatest
431 wakaba 1.1 @Description:
432     @@lang:en
433     @@@:
434     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
435     @Method:
436 wakaba 1.3 @@Name: parse
437     @@Description:
438     @@@lang:en
439     @@@@:
440 wakaba 1.1 Parses a <QUOTE::dis> document and returns it as an object tree.
441 wakaba 1.3 @@Param:
442     @@@Name: input
443     @@@Type:
444     DOMLS:LSInput::ManakaiDOM:ManakaiDOM3
445     @@@Description:
446     @@@@lang:en
447     @@@@@:
448 wakaba 1.1 The input source.
449 wakaba 1.3 @@Return:
450     @@@Type: ManakaiDISDocument
451     @@@Description:
452     @@@@lang:en
453     @@@@@:
454 wakaba 1.1 The <QUOTE::dis> document object created from the <P::input>.
455     @@@RaiseException:
456     @@@@@:
457     swcfg21:SWCFG_PARSE_ERR
458     @@@@Description:
459     @@@@@lang:en
460     @@@@@@:
461     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
462     document.
463     @@@PerlDef:
464     __DEEP{
465 wakaba 1.3 $r = $self-><M::swcfg21:ManakaiSWCFGParser
466     ::swcfg21:ForLatest.parse> ($input);
467 wakaba 1.1 }__;
468     if (defined $r) {
469     $r = bless $r, <ClassName::ManakaiDISDocument>;
470 wakaba 1.4 $r-><AS::swcfg21:SWCFGDocument::swcfg21:ForLatest
471     .defaultElementTypeNamespaceURI>
472     (<Q::dis:>);
473 wakaba 1.1 }
474     ##DISParser
475    
476     ClsDef:
477     @ClsQName: ManakaiDISNode
478     @Description:
479     @@lang:en
480     @@@:
481     <QUOTE::dis> node objects.
482 wakaba 1.7 @ImplNote:
483     @@lang:en
484     @@@:
485     This class does not inherit
486     <Class::swcfg21:ManakaiSWCFGNode::swcfg21:ForLatest>, since
487     inheriting classes such as <Class::ManakaiDISElement> indirectly
488     inherit it.
489 wakaba 1.1
490     @MethodRedef:
491     @@Name:lookupNamespacePrefix
492     @@Description:
493     @@@lang:en
494     @@@@:
495     Looks up the namespace prefix associated to the given
496     namespace URI. The default namespaces are ignored.
497     @@Param:
498     @@@Name:namespaceURI
499 wakaba 1.3 @@@Type: AnyURI
500 wakaba 1.1 @@@Description:
501     @@@@lang:en
502     @@@@@:
503     The namespace URI to look for.
504     @@@InCase:
505     @@@@Value:
506     @@@@@is-null:1
507     @@@@Description:
508     @@@@@lang:en
509     @@@@@@:
510     The <DOM::null> namespace.
511     @@NamedParam:
512     @@@Name: makeNewBinding
513     @@@Type:
514     DOMMain:boolean
515     @@@Description:
516     @@@@lang:en
517     @@@@@:
518     Whether a new namespace prefix should be bound when
519     no namespace URI has been associated yet.
520     @@@InCase:
521     @@@@Value:true
522     @@@@Description:
523     @@@@@lang:en
524     @@@@@@:
525     New binding is made if no prefix associated.
526     @@@InCase:
527     @@@@Value:false
528     @@@@Description:
529     @@@@@lang:en
530     @@@@@@:
531     Simply returns the <DOM::null> if no prefix associated.
532     @@Return:
533     @@@Type:
534 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
535 wakaba 1.1 @@@Description:
536     @@@@lang:en
537     @@@@@:
538     An associated namespace prefix. If more than one prefix
539     are associated to the namespace URI, the returned prefix
540     is implementation dependent.
541     @@@InCase:
542     @@@@Value:
543     @@@@@is-null:1
544     @@@@Description:
545     @@@@@lang:en
546     @@@@@@:
547     No associated namespace prefix found.
548     @@@PerlDef:
549     $r = null;
550 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
551     .ownerDocument> || $self;
552 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
553 wakaba 1.1 if (defined $namespaceURI) {
554     FIND: {
555     for my $prefix (keys %$binds) {
556     if (defined $binds->{$prefix} and
557     $binds->{$prefix} eq $namespaceURI) {
558     $r = $prefix;
559     last FIND;
560     }
561     }
562 wakaba 1.7
563     ## From module list
564     try {
565     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
566     -><AG::ManakaiDISDocument.disDatabase>;
567     for my $mod_uri (keys %{$db->{modDef}}) {
568     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
569     my $mod_ln = $mod-><AG::ManakaiDISModuleDefinition.localName>;
570     next if exists $binds->{$mod_ln};
571     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
572     .getPropertyText>
573     (<Q::dis:Namespace>, '');
574     if ($ns_uri eq $namespaceURI) {
575     $r = $mod_ln;
576     last FIND;
577     }
578     }
579     } catch <Class::ManakaiDISException> with {
580     my $err = shift;
581     $err->throw
582     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
583     };
584    
585 wakaba 1.1 last FIND unless $makeNewBinding;
586     ## Not found
587     if ($namespaceURI =~ /(\w+)$/) {
588     my $prefix = $1;
589     unless (exists $binds->{$prefix}) {
590     $binds->{$prefix} = $namespaceURI;
591     $r = $prefix;
592     last FIND;
593     }
594     }
595     my $i = 1;
596     {
597     unless (exists $binds->{'ns'.$i}) {
598     $binds->{$r = 'ns'.$i} = $namespaceURI;
599     last FIND;
600     }
601     $i++;
602     redo;
603     }
604     } # FIND
605     } else { ## Null namespace
606     FIND: {
607     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
608     $r = 'nu'.'ll';
609     last FIND;
610     }
611     for my $prefix (keys %$binds) {
612     if (not defined $prefix) {
613     $r = $prefix;
614     last FIND;
615     }
616     }
617     last FIND unless $makeNewBinding;
618     ## Not found
619     my $i = '';
620     {
621     unless (exists $binds->{'nu'.'ll'.$i}) {
622     $binds->{$r = 'nu'.'ll'.$i} = null;
623     last FIND;
624     }
625     $i++;
626     redo;
627     }
628     }
629     }
630    
631     @MethodRedef:
632     @@Name:lookupNamespaceURI
633     @@Description:
634     @@@lang:en
635     @@@@:
636     Looks up the namespace URI associated to the given prefix.
637     @@Param:
638     @@@Name:prefix
639     @@@Type:
640 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
641 wakaba 1.1 @@@Description:
642     @@@@lang:en
643     @@@@@:
644     The namespace URI to look for.
645     @@NamedParam:
646     @@@Name: makeNewBinding
647     @@@Type:
648     DOMMain:boolean
649     @@@Description:
650     @@@@lang:en
651     @@@@@:
652     Whether a new binding should be created if no namespace URI
653     is associated with the <P::prefix> or not.
654     @@@InCase:
655     @@@@Value:true
656     @@@@Description:
657     @@@@@lang:en
658     @@@@@@:
659     A new binding to the temporary namespace URI
660     exactly same as <P::prefix> is created
661     if no binding found.
662     @@@InCase:
663     @@@@Value:false
664     @@@@Description:
665     @@@@@lang:en
666     @@@@@@:
667     No new binding is created if no binding found. Note that
668     even if no association newly created, this method
669     returns the <DOM::null> value.
670     @@Return:
671 wakaba 1.3 @@@Type: AnyURI
672 wakaba 1.1 @@@Description:
673     @@@@lang:en
674     @@@@@:The associated namespace URI.
675     @@@InCase:
676     @@@@Value:
677     @@@@@is-null:1
678     @@@@Description:
679     @@@@@lang:en
680     @@@@@@:
681 wakaba 1.3 No namespace URI is associated to the prefix or
682 wakaba 1.1 the <DOM::null> namespace is associated.
683     @@@PerlDef:
684 wakaba 1.3 my $od = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
685     .ownerDocument> || $self;
686 wakaba 1.7 my $binds = $od->{<Q::TreeCore:node>}->{<Q::swcfg21:nsBinding>};
687 wakaba 1.1 if (exists $binds->{$prefix}) {
688     $r = $binds->{$prefix};
689     } else {
690 wakaba 1.7 ## From module list
691     FIND: {
692     try {
693     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
694     -><AG::ManakaiDISDocument.disDatabase>;
695     for my $mod_uri (keys %{$db->{modDef}}) {
696     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
697     if ($mod-><AG::ManakaiDISModuleDefinition.localName>
698     eq $prefix) {
699     $r = $mod-><M::ManakaiDISPropertyAccessor
700     .getPropertyText>
701     (<Q::dis:Namespace>, null);
702     last FIND;
703     }
704     }
705     } catch <Class::ManakaiDISException> with {
706     my $err = shift;
707     $err->throw
708     unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_DB_ASSOCIATED_ERR>;
709     };
710     if ($makeNewBinding) {
711     $r = $binds->{$prefix} = $prefix;
712     } else {
713     $r = null;
714     }
715     } # FIND
716 wakaba 1.1 }
717    
718     @IntMethod:
719     @@Name:getNodeReference
720     @@Description:
721     @@@lang:en
722     @@@@:
723     Returns a new reference to the node object.
724     @@ManakaiDOM:isStatic:1
725     @@Param:
726     @@@Name:object
727     @@@Type:
728     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
729     @@@Description:
730     @@@@lang:en
731     @@@@@:
732     The node object to be referred.
733     @@Return:
734     @@@Type: ManakaiDISNode
735     @@@Description:
736     @@@@lang:en
737     @@@@@:
738     A newly created reference.
739     @@@PerlDef:
740     my $class;
741 wakaba 1.5 if ($object->{<Q::swcfg21:nodeType>} eq '#element') {
742 wakaba 1.1 $class = <ClassName::ManakaiDISElement>;
743 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#comment') {
744 wakaba 1.1 $class = <ClassName::ManakaiDISComment>;
745 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#document') {
746 wakaba 1.1 $class = <ClassName::ManakaiDISDocument>;
747 wakaba 1.5 } elsif ($object->{<Q::swcfg21:nodeType>} eq '#fragment') {
748 wakaba 1.1 $class = <ClassName::ManakaiDISDocumentFragment>;
749     } else {
750     __ASSERT{DISPerl:invariant::
751 wakaba 1.5 msg => {qq[Node type: "$object->{<Q::swcfg21:nodeType>}" ].
752 wakaba 1.1 qq[(ref: "@{[ref $object]}")]},
753     }__;
754     }
755     $r = $object-><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
756     .newReference> ($class);
757    
758 wakaba 1.2 @Attr:
759     @@Name:ownerDISDocument
760     @@Description:
761     @@@lang:en
762     @@@@:
763     The <QUOTE::dis> document object associated with this node.
764     @@Get:
765 wakaba 1.3 @@@Type:ManakaiDISDocument
766 wakaba 1.2 @@@Description:
767     @@@@lang:en
768     @@@@@:
769     The document object associated with this node.
770     @@@InCase:
771     @@@@Value:
772     @@@@@is-null:1
773     @@@@Description:
774     @@@@@lang:en
775     @@@@@@:
776     This node is a document node.
777     @@@PerlDef:
778     $r = <ClassM::ManakaiDISNode.getNodeReference>
779     ($self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>})
780     if $self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>};
781 wakaba 1.1 ##DISNode
782    
783     ClsDef:
784     @ClsQName: ManakaiDISElement
785 wakaba 1.7 @ClsISA: ManakaiDISNode
786 wakaba 1.1 @ClsISA:
787 wakaba 1.3 swcfg21:ManakaiSWCFGElement::swcfg21:ForLatest
788 wakaba 1.1 @Description:
789     @@lang:en
790     @@@:
791     <QUOTE::dis> element node objects.
792    
793     @Method:
794     @@Name: forMatch
795     @@Description:
796     @@@lang:en
797     @@@@:
798     Tests whether this element is for a <QUOTE::for> or not.
799     @@Param:
800     @@@Name: forArg
801     @@@Type: ForURI
802     @@@Description:
803     @@@@lang:en
804     @@@@@:
805     The <QUOTE::For> URI reference to test against.
806     @@Param:
807     @@@Name: forpArg
808     @@@Type: ForURIList
809     @@@Description:
810     @@@@lang:en
811     @@@@@:
812     The <QUOTE::For+> URI references to test against.
813     @@@InCase:
814     @@@@Value:
815     @@@@@is-null:1
816     @@@@Description:
817     @@@@@lang:en
818     @@@@@@:
819     No additional <QUOTE::For> URI reference.
820 wakaba 1.3 Equivalent to an empty array reference.
821 wakaba 1.1 @@Return:
822     @@@Type:
823     DOMMain:boolean
824     @@@Description:
825     @@@@lang:en
826     @@@@@:
827     Whether this element is for <P::forArg> and <P::forpArg> or not.
828 wakaba 1.2 @@@UndeclaredPrefixException:
829     @@@NoDBException:
830     @@@PerlDef:
831 wakaba 1.3 $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
832     $forpArg ||= [];
833 wakaba 1.2
834     FORMATCH: {
835     __DEEP{
836 wakaba 1.10 my $for_res = $self-><AG::ManakaiDISNode.ownerDISDocument>
837     -><AG::ManakaiDISDocument.disDatabase>
838     -><M::ManakaiDISDatabase.getFor> ($forArg);
839     my $forp_res = [map {
840     $self-><AG::ManakaiDISNode.ownerDISDocument>
841     -><AG::ManakaiDISDocument.disDatabase>
842     -><M::ManakaiDISDatabase.getFor> ($_)
843     } @{$forpArg}];
844    
845     my @ce = @{$self-><M::ManakaiDISElement.disAllChildElements>};
846 wakaba 1.2 for my $ce (@ce) {
847 wakaba 1.3 my $et = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
848     .expandedURI>;
849 wakaba 1.2 if ($et eq <Q::dis:ForCheck>) {
850 wakaba 1.9 my $fors = [split /\s+/, $ce-><AG::swcfg21:SWCFGNode
851     ::swcfg21:ForLatest.value>];
852     FCs: for my $f (@$fors) {
853 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
854     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
855 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
856     -><AG::ManakaiDISDocument.disDatabase>
857     -><M::ManakaiDISDatabase.getFor> ($uri);
858     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
859 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
860     if ($arg_res eq $for) {
861 wakaba 1.2 $r = false;
862     last FORMATCH;
863     }
864     }
865     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
866     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
867 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
868     -><AG::ManakaiDISDocument.disDatabase>
869     -><M::ManakaiDISDatabase.getFor> ($uri);
870     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
871 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
872     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
873 wakaba 1.2 $r = false;
874     last FORMATCH;
875     }
876     }
877     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
878     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
879 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
880     -><AG::ManakaiDISDocument.disDatabase>
881     -><M::ManakaiDISDatabase.getFor> ($uri);
882     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
883 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
884     if ($arg_res eq $for) {
885 wakaba 1.2 next FCs;
886     }
887     }
888     $r = false;
889     last FORMATCH;
890     } else { ## -- ISA
891 wakaba 1.9 my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($f);
892     my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
893     -><AG::ManakaiDISDocument.disDatabase>
894     -><M::ManakaiDISDatabase.getFor> ($uri);
895     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
896 wakaba 1.10 for my $arg_res ($for_res, @{$forp_res}) {
897     if ($arg_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
898 wakaba 1.2 next FCs;
899     }
900     }
901     $r = false;
902     last FORMATCH;
903     }
904     } # FCs
905     } # dis:ForCheck
906     } # children
907    
908     my $has_for = false;
909     for my $ce (@ce) {
910 wakaba 1.3 if ($self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
911     .expandedURI> eq
912 wakaba 1.2 <Q::dis:For>) {
913 wakaba 1.9 my $fors = [split /\s+/, $ce-><AG::swcfg21:SWCFGNode
914     ::swcfg21:ForLatest.value>];
915 wakaba 1.2 my $ok = true;
916     $has_for = true;
917 wakaba 1.9 AFOR: for my $f (@$fors) {
918 wakaba 1.2 if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
919     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
920 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
921     -><AG::ManakaiDISDocument.disDatabase>
922     -><M::ManakaiDISDatabase.getFor> ($uri);
923     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
924 wakaba 1.10 if ($for eq $for_res) {
925 wakaba 1.2 $ok = false;
926     last AFOR;
927     }
928     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
929     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
930 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
931     -><AG::ManakaiDISDocument.disDatabase>
932     -><M::ManakaiDISDatabase.getFor> ($uri);
933     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
934 wakaba 1.10 if ($for_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
935 wakaba 1.2 $ok = false;
936     last AFOR;
937     }
938     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
939     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
940 wakaba 1.9 my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
941     -><AG::ManakaiDISDocument.disDatabase>
942     -><M::ManakaiDISDatabase.getFor> ($uri);
943     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
944 wakaba 1.10 unless ($for eq $for_res) {
945 wakaba 1.2 $ok = false;
946     last AFOR;
947     }
948     } else { ## -- ISA
949 wakaba 1.9 my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($f);
950     my $for = $self-><AG::ManakaiDISNode.ownerDISDocument>
951     -><AG::ManakaiDISDocument.disDatabase>
952     -><M::ManakaiDISDatabase.getFor> ($uri);
953     $for-><AG::ManakaiDISForDefinition.isReferred> ($ce);
954 wakaba 1.10 unless ($for_res-><M::ManakaiDISForDefinition.isaURI>($uri)){
955 wakaba 1.2 $ok = false;
956     last AFOR;
957     }
958     }
959     } # AFOR
960 wakaba 1.3 if ($ok) {
961     $r = true;
962     last FORMATCH;
963     }
964 wakaba 1.2 } # dis:For
965     } # $ce
966     $r = $has_for ? false : true;
967     }__;
968     } # FORMATCH
969 wakaba 1.1
970     @Method:
971     @@Name: mediaTypeMatch
972     @@Description:
973     @@@lang:en
974     @@@@:
975     Tests whether the content media type of this element matches to
976     a type or not.
977     @@Param:
978     @@@Name: mediaType
979     @@@Type: MediaTypeURI
980     @@@Description:
981     @@@@lang:en
982     @@@@@:
983     A media type URI reference to test against.
984     @@Param:
985 wakaba 1.3 @@@Name: defaultMediaType
986 wakaba 1.1 @@@Type: MediaTypeURI
987     @@@Description:
988     @@@@lang:en
989     @@@@@:
990     The default media type for this element.
991     @@@InCase:
992     @@@@Value:
993     @@@@@is-null:1
994     @@@@Description:
995     @@@@@lang:en
996     @@@@@@:
997     No default type provided. All <P::mediaType> will match.
998     @@Return:
999     @@@Type:
1000     DOMMain:boolean
1001     @@@Description:
1002     @@@@lang:en
1003     @@@@@:
1004     Whether this element is of <P::mediaType> or not.
1005 wakaba 1.2 @@@PerlDef:
1006     if (defined $mediaType) {
1007     __DEEP{
1008     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1009     (<Q::dis:ContentType>);
1010     my $ct;
1011     $ct = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1012     $ct = $defaultMediaType unless defined $ct;
1013     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
1014     -><AG::ManakaiDISDocument.disDatabase>
1015     -><M::ManakaiDISDatabase.getResource> ($ct);
1016     $res-><AS::ManakaiDISResourceDefinition.isReferred> ($ctn or $self);
1017 wakaba 1.7 unless ($res-><M::ManakaiDISResourceDefinition
1018 wakaba 1.10 .isSubsetOfURI> ($mediaType)) {
1019 wakaba 1.2 $r = false;
1020     } else {
1021     $r = true;
1022     }
1023     }__;
1024     } else {
1025     $r = true;
1026     }
1027 wakaba 1.1
1028     @Method:
1029 wakaba 1.10 @@Name:mediaTypeURI
1030     @@enDesc:
1031     The URI reference of the media type of this element.
1032     @@Type: MediaTypeURI
1033     @@NamedParam:
1034     @@@Name:defaultMediaType
1035     @@@Type:MediaTypeURI
1036     @@@enDesc:
1037     The default media type URI reference.
1038     @@@nullCase:
1039     @@@@enDesc:
1040     No default is specified.
1041     @@ForParam:
1042     @@ForpParam:
1043     @@Return:
1044     @@@enDesc:
1045     The media type URI reference of this element.
1046     @@@nullCase:
1047     @@@@enDesc:
1048     This element has no media type information and
1049     <P::defaultMediaType> parameter is not provided.
1050     @@@UndeclaredPrefixException:
1051     @@@PerlDef:
1052     __DEEP{
1053     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
1054     (<Q::dis:ContentType>, for_arg => $forArg,
1055     forp_arg => $forpArg);
1056     $r = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
1057     }__;
1058    
1059     @Method:
1060 wakaba 1.1 @@Name: prefixToURI
1061     @@Description:
1062     @@@lang:en
1063     @@@@:
1064     Converts a namespace prefix into associated URI reference.
1065     @@Param:
1066     @@@Name: prefix
1067     @@@Type:
1068 wakaba 1.3 DISCore:NamespacePrefix::ManakaiDOM:all
1069 wakaba 1.1 @@@Description:
1070     @@@@lang:en
1071     @@@@@:
1072     A namespace prefix to look for.
1073     @@@InCase:
1074     @@@@Value:
1075     @@@@@is-null:1
1076     @@@@Description:
1077     @@@@@lang:en
1078     @@@@@@:
1079     Returns the default namespace URI.
1080     @@NodeParam:
1081     @@Return:
1082 wakaba 1.3 @@@Type: AnyURI
1083 wakaba 1.1 @@@Description:
1084     @@@@lang:en
1085     @@@@@: The URI references associated.
1086     @@@UndeclaredPrefixException:
1087     @@@PerlDef:
1088 wakaba 1.3 if (defined $prefix) {
1089 wakaba 1.1 __DEEP{
1090 wakaba 1.3 $r = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1091     .lookupNamespaceURI> ($prefix);
1092 wakaba 1.1 }__;
1093     unless (defined $r) {
1094     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
1095     infoset:prefix => {$prefix},
1096     MDOMX:param-name => 'prefix',
1097     DIS:sourceNode => {$node},
1098     }__;
1099     }
1100 wakaba 1.7 } else { ## Default namespace
1101     __DEEP{
1102     $r = ($self-><AG::ManakaiDISNode.ownerDISDocument> || $self)
1103     -><AG::ManakaiDISDocument.moduleElement>
1104     -><AG::ManakaiDISModuleElement.definingNamespaceURI>;
1105     }__;
1106 wakaba 1.1 }
1107    
1108     @Method:
1109     @@QName: qnameToURI
1110     @@Description:
1111     @@@lang:en
1112     @@@@:
1113     Converts a qualified name (<TYPE::dis:TypeQName>) to
1114     an expanded URI reference.
1115     @@Param:
1116     @@@Name: qname
1117     @@@Type:
1118     dis:TypeQName
1119     @@@Description:
1120     @@@@lang:en
1121     @@@@@:
1122     A qualified name.
1123     @@NodeParam:
1124     @@Return:
1125     @@@Type: AnyURI
1126     @@@Description:
1127     @@@@lang:en
1128     @@@@@:
1129     The expanded URI reference.
1130     @@@UndeclaredPrefixException:
1131     @@@PerlDef:
1132     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1133 wakaba 1.9 my ($prefix, $lname) = split /:/, $qname, 2;
1134 wakaba 1.1 __DEEP{
1135     if (defined $lname) {
1136     $r = $self-><M::ManakaiDISElement.prefixToURI> ($prefix) . $lname;
1137     } else { ## In default namespace
1138     $r = $self-><M::ManakaiDISElement.prefixToURI> (null) . $prefix;
1139     }
1140 wakaba 1.4 }__;
1141 wakaba 1.1
1142     @Method:
1143     @@QName: qnameToPair
1144     @@Description:
1145     @@@lang:en
1146     @@@@:
1147     Converts a qualified name (<TYPE::dis:TypeQName>) to
1148     a pair of namespace URI and local name.
1149     @@Param:
1150     @@@Name: qname
1151     @@@Type:
1152     dis:TypeQName
1153     @@@Description:
1154     @@@@lang:en
1155     @@@@@:
1156     A qualified name.
1157     @@NodeParam:
1158     @@Return:
1159     @@@Type:
1160     Perl:ARRAY
1161     @@@Description:
1162     @@@@lang:en
1163     @@@@@:
1164     A list of namespace URI and local name.
1165     @@@UndeclaredPrefixException:
1166     @@@PerlDef:
1167     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1168 wakaba 1.9 my ($prefix, $lname) = split /:/, $qname, 2;
1169 wakaba 1.1 __DEEP{
1170     if (defined $lname) {
1171     $r = [$self-><M::ManakaiDISElement.prefixToURI> ($prefix), $lname];
1172     } else { ## In default namespace
1173     $r = [$self-><M::ManakaiDISElement.prefixToURI> (null), $prefix];
1174     }
1175 wakaba 1.4 }__;
1176 wakaba 1.1
1177     @Method:
1178 wakaba 1.3 @@Name: tfqnamesToURI
1179 wakaba 1.1 @@Description:
1180     @@@lang:en
1181     @@@@:
1182 wakaba 1.3 Converts a <TYPE::dis:TFQNames>
1183 wakaba 1.1 into an expanded URI reference.
1184     @@Param:
1185     @@@Name: tfqnames
1186     @@@Type:
1187 wakaba 1.3 dis:TFQNames
1188 wakaba 1.1 @@@Description:
1189     @@@@lang:en
1190     @@@@@:
1191 wakaba 1.3 A <TYPE::dis:TFQNames> to identify a resource.
1192 wakaba 1.1 @@Param:
1193     @@@Name: defaultTypeURI
1194     @@@Type: NameURI
1195     @@@Description:
1196     @@@@lang:en
1197     @@@@@:
1198     A name URI reference used if it is missing from
1199     <P::tfqnames>.
1200     @@@InCase:
1201     @@@@Value:
1202     @@@@@is-null:1
1203     @@@@Description:
1204     @@@@@lang:en
1205     @@@@@@:
1206     Equivalent to <Q::DOMMain:any>.
1207     @@Param:
1208     @@@Name: defaultForURI
1209     @@@Type: ForURI
1210     @@@Description:
1211     @@@@lang:en
1212     @@@@@:
1213     A <QUOTE::for> URI reference used if it is missing from
1214     <P::tfqnames>.
1215     @@@InCase:
1216     @@@@Value:
1217     @@@@@is-null:1
1218     @@@@Description:
1219     @@@@@lang:en
1220     @@@@@@:
1221     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1222     @@NodeParam:
1223     @@Return:
1224     @@@Type:
1225 wakaba 1.3 DISCore:TFURI::ManakaiDOM:all
1226 wakaba 1.1 @@@Description:
1227     @@@@lang:en
1228     @@@@@:
1229 wakaba 1.3 The <TYPE::dis:TFQNames>-expanded URI references.
1230 wakaba 1.1 @@@UndeclaredPrefixException:
1231     @@@PerlDef:
1232     my ($typeq, $forq) = split /\s*::\s*/, $tfqnames, 2;
1233     my ($typeURI, $forURI);
1234     if (defined $forq) {
1235     __DEEP{
1236     $typeURI = $typeq eq ''
1237     ? defined $defaultTypeURI ? $defaultTypeURI
1238     : <Q::DOMMain:any>
1239     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1240     }__;
1241     if (length $forq) {
1242     $forURI = $self-><M::ManakaiDISElement.qnameToURI> ($forq, %opt);
1243     } else {
1244     $forURI = <Q::ManakaiDOM:all>;
1245     }
1246     } else { ## "For" omitted
1247     __DEEP{
1248     $typeURI = $typeq eq ''
1249     ? defined $defaultTypeURI ? $defaultTypeURI
1250     : <Q::DOMMain:any>
1251     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
1252     }__;
1253 wakaba 1.3 $forURI = defined $defaultForURI ? $defaultForURI
1254     : <Q::ManakaiDOM:all>;
1255 wakaba 1.1 }
1256 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
1257 wakaba 1.2
1258     @Method:
1259     @@Name: disGetAttribute
1260     @@enDesc:
1261     Gets an attribute node.
1262     @@Param:
1263     @@@Name: attrName
1264     @@@Type: AnyURI
1265     @@@enDesc:
1266     The name expanded URI of the node to retrieve.
1267     @@ForParam:
1268     @@ForpParam:
1269     @@MediaTypeParam:
1270     @@MediaTypeDefaultParam:
1271     @@Return:
1272     @@@Type: ManakaiDISElement
1273     @@@enDesc:
1274     The attribute (property) element node.
1275     @@@nullCase:
1276     @@@@enDesc:
1277     No attribute node found.
1278     @@@PerlDef:
1279 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1280     (for_arg => $forArg, forp_arg => $forpArg)}) {
1281 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1282     .expandedURI> eq $attrName and
1283 wakaba 1.2 $c-><AG::ManakaiDISElement.mediaTypeMatch>
1284 wakaba 1.3 ($mediaType, $defaultMediaType)) {
1285 wakaba 1.2 $r = $c;
1286     last;
1287     }
1288     }
1289    
1290     @Method:
1291     @@Name: disGetAttributeList
1292     @@enDesc:
1293     Gets attribute nodes.
1294 wakaba 1.3 @@Param:
1295     @@@Name: attrName
1296     @@@Type: AnyURI
1297     @@@enDesc:
1298     The name expanded URI of the node to retrieve.
1299 wakaba 1.2 @@ForParam:
1300     @@ForpParam:
1301     @@MediaTypeParam:
1302     @@MediaTypeDefaultParam:
1303     @@Return:
1304     @@@Type: ManakaiDISElementList
1305     @@@enDesc:
1306     The attribute (property) element nodes.
1307     @@@PerlDef:
1308     $r = bless [], <ClassName::ManakaiDISElementList>;
1309 wakaba 1.10 for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1310     (for_arg => $forArg, forp_arg => $forpArg)}) {
1311 wakaba 1.3 if ($c-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1312     .expandedURI> eq $attrName and
1313 wakaba 1.2 $c-><AG::ManakaiDISElement.mediaTypeMatch>
1314 wakaba 1.3 ($mediaType, $defaultMediaType)) {
1315 wakaba 1.2 push @$r, $c;
1316     }
1317     }
1318    
1319 wakaba 1.4 @Method:
1320 wakaba 1.2 @@Name: disChildElements
1321     @@enDesc:
1322 wakaba 1.10 A list of child elements, with <QUOTE::for> check.
1323 wakaba 1.4 @@ForParam:
1324     @@ForpParam:
1325     @@Return:
1326     @@@Type: ManakaiDISElementList
1327 wakaba 1.2 @@@enDesc:
1328     The current snapshot of child nodes.
1329     @@@PerlDef:
1330 wakaba 1.4 $r = bless [], <ClassName::ManakaiDISElementList>;
1331     __DEEP{
1332     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1333     .childNodes>}) {
1334     ## $cn is an #element.
1335     my $dn = $cn->{<Q::TreeCore:node>}
1336     -><M::ManakaiDOM:ManakaiDOMNodeObject
1337     ::ManakaiDOM:Perl.newReference>
1338     (<ClassName::ManakaiDISElement>);
1339     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1340     push @$r, $dn;
1341     }
1342     }__;
1343 wakaba 1.5
1344 wakaba 1.10 @Method:
1345     @@Name: disAllChildElements
1346     @@enDesc:
1347     A list of child elements, without <QUOTE::for> check.
1348     @@Return:
1349     @@@Type: ManakaiDISElementList
1350     @@@enDesc:
1351     The current snapshot of child nodes.
1352     @@@PerlDef:
1353     $r = bless [], <ClassName::ManakaiDISElementList>;
1354     __DEEP{
1355     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1356     .childNodes>}) {
1357     ## $cn is an #element.
1358     my $dn = $cn->{<Q::TreeCore:node>}
1359     -><M::ManakaiDOM:ManakaiDOMNodeObject
1360     ::ManakaiDOM:Perl.newReference>
1361     (<ClassName::ManakaiDISElement>);
1362     push @$r, $dn;
1363     }
1364     }__;
1365    
1366 wakaba 1.2 @Attr:
1367     @@Name: qnameValueURI
1368     @@enDesc:
1369     The element value (written as <TYPE::dis:TypeQName>), as URI reference.
1370     \
1371     {NOTE:: What should be if list value?
1372     \
1373     }
1374     @@Get:
1375     @@@Type:AnyURI
1376     @@@nullCase:
1377     @@@@enDesc:
1378     No value.
1379     @@@UndeclaredPrefixException:
1380 wakaba 1.3 @@@PerlDef:
1381 wakaba 1.4 __DEEP{
1382     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1383     if (defined $v and not ref $v eq 'ARRAY') {
1384     $r = $self-><AG::ManakaiDISElement.qnameToURI> ($v, node => $self);
1385     } else {
1386     $r = null;
1387     }
1388     }__;
1389    
1390     @Attr:
1391     @@Name: qnameValueLocalName
1392     @@enDesc:
1393     The local name part of the element value (assumed as
1394     written as <TYPE::dis:TypeQName>).
1395     \
1396     {NOTE:: What should be if list value?
1397     \
1398     }
1399     @@Get:
1400     @@@Type:
1401     DISCore:LocalName
1402     @@@nullCase:
1403     @@@@enDesc:
1404     No value.
1405     @@@PerlDef:
1406     __DEEP{
1407     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1408     if (defined $v and not ref $v eq 'ARRAY') {
1409     my ($n, $v) = split /:/, $v, 2;
1410     $r = defined $v ? $v : $n;
1411     } else {
1412     $r = null;
1413     }
1414     }__;
1415    
1416     @Attr:
1417     @@Name: qnameValueNamespaceURI
1418     @@enDesc:
1419     The namespace URI of the element value (assumed as written
1420     in <TYPE::dis:TypeQName>).
1421     \
1422     {NOTE:: What should be if list value?
1423     \
1424     }
1425     @@Get:
1426     @@@Type:AnyURI
1427     @@@nullCase:
1428     @@@@enDesc:
1429     No value.
1430     @@@UndeclaredPrefixException:
1431     @@@PerlDef:
1432     __DEEP{
1433     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1434     if (defined $v and not ref $v eq 'ARRAY') {
1435     my ($p, $v) = split /:/, $v, 2;
1436     $r = $self-><AG::ManakaiDISElement.prefixToURI>
1437     (defined $v ? $p : null);
1438     } else {
1439     $r = null;
1440     }
1441     }__;
1442 wakaba 1.2
1443 wakaba 1.6 @Method:
1444 wakaba 1.3 @@Name: tfqnamesValueURI
1445 wakaba 1.2 @@enDesc:
1446 wakaba 1.3 The element value (written as <TYPE::dis:TFQNames>),
1447 wakaba 1.2 as URI reference.
1448     \
1449     {NOTE:: What should be if list value?
1450     \
1451     }
1452 wakaba 1.6 @@Param:
1453     @@@Name: defaultTypeURI
1454     @@@Type: NameURI
1455     @@@Description:
1456     @@@@lang:en
1457     @@@@@:
1458     A name URI reference used if it is missing from
1459     <P::tfqnames>.
1460     @@@InCase:
1461     @@@@Value:
1462     @@@@@is-null:1
1463     @@@@Description:
1464     @@@@@lang:en
1465     @@@@@@:
1466     Equivalent to <Q::DOMMain:any>.
1467     @@Param:
1468     @@@Name: defaultForURI
1469     @@@Type: ForURI
1470     @@@Description:
1471     @@@@lang:en
1472     @@@@@:
1473     A <QUOTE::for> URI reference used if it is missing from
1474     <P::tfqnames>.
1475     @@@InCase:
1476     @@@@Value:
1477     @@@@@is-null:1
1478     @@@@Description:
1479     @@@@@lang:en
1480     @@@@@@:
1481     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1482     @@Return:
1483 wakaba 1.2 @@@Type:ResourceURI
1484     @@@nullCase:
1485     @@@@enDesc:
1486     No value.
1487     @@@UndeclaredPrefixException:
1488 wakaba 1.3 @@@PerlDef:
1489     my $v = $self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1490 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1491     __DEEP{
1492 wakaba 1.6 $r = $self-><AG::ManakaiDISElement.tfqnamesToURI>
1493     ($v, $defaultTypeURI, $defaultForURI);
1494 wakaba 1.2 }__;
1495     } else {
1496     $r = null;
1497     }
1498 wakaba 1.7
1499     @Method:
1500     @@Name: elementTypeMatch
1501     @@enDesc:
1502     Returns whether the element type of this element matches
1503     with another element type (either the same element type or
1504     this type is a subtype of another type).
1505     @@Param:
1506     @@@Name: etype
1507     @@@Type: ResourceURI
1508     @@@enDesc:
1509     An element type name URI reference to test.
1510     @@Return:
1511     @@@Type:
1512     DOMMain:boolean
1513     @@@TrueCase:
1514     @@@@enDesc:
1515     Either the element type expanded URI reference of this element is
1516     same as <P::etype> or it is a sub-element type of <P::etype>.
1517     @@@FalseCase:
1518     @@@@enDesc:
1519     This element is not of <P::etype>.
1520     @@@NoDBException:
1521     @@@PerlDef:
1522     __DEEP{
1523     my $et = $self-><M::swcfg21:SWCFGElement::swcfg21:ForLatest
1524     .expandedURI>;
1525     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1526     -><AG::ManakaiDISDocument.disDatabase>
1527     -><M::ManakaiDISDatabase.getResource> ($et);
1528     $r = $rdef-><M::ManakaiDISResourceDefinition.isSubsetOfURI> ($etype);
1529     }__;
1530    
1531     @Attr:
1532     @@Name: isResourceElement
1533     @@enDesc:
1534     Whether this element defines a resource or not.
1535     \
1536     {NOTE:: An element defines a resource if its element type is
1537     <Q::dis:ResourceDef> or its subtype.
1538     \
1539     }
1540     @@Get:
1541     @@@Type:
1542     DOMMain:boolean
1543     @@@TrueCase:
1544     @@@@enDesc:
1545     This element defines a resource.
1546     @@@FalseCase:
1547     @@@@enDesc:
1548     This element does not define any resource.
1549     @@@NoDBException:
1550     @@@PerlDef:
1551     __DEEP{
1552     $r = $self-><M::ManakaiDISElement.elementTypeMatch>
1553     (<Q::dis:ResourceDef>);
1554     }__;
1555    
1556     @Attr:
1557     @@Name: isPropertyElement
1558     @@enDesc:
1559     Whether this element is a property or not.
1560     \
1561     {NOTE:: An element is a property if its element type is
1562     <Q::rdf:type> or if its element type's <Q::rdf:type>
1563     property is <Q::rdf:Property> or is <Q::dis:subsetOf>
1564     <Q::rdf:Property>.
1565     \
1566     }
1567     @@Get:
1568     @@@Type:
1569     DOMMain:boolean
1570     @@@TrueCase:
1571     @@@@enDesc:
1572     This element is a property.
1573     @@@FalseCase:
1574     @@@@enDesc:
1575     This element is not a property.
1576     @@@NoDBException:
1577     @@@PerlDef:
1578     __DEEP{
1579     my $xn = $self-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
1580     .expandedURI>;
1581     if ($xn eq <Q::rdf:type>) {
1582     $r = true;
1583     } else {
1584     my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1585     -><AG::ManakaiDISDocument.disDatabase>
1586     -><M::ManakaiDISDatabase.getResource> ($xn);
1587     $r = $rdef-><M::ManakaiDISResourceDefinition.isTypeURI>
1588     (<Q::rdf:Resource>);
1589     }
1590     }__;
1591 wakaba 1.1 ##DISElement
1592    
1593     ClsDef:
1594 wakaba 1.4 @ClsQName: ManakaiDISModuleElement
1595     @ClsISA: ManakaiDISElement
1596     @enDesc:
1597     The <Q::dis:Module> elements.
1598    
1599     @Attr:
1600     @@Name: requireElement
1601     @@enDesc:
1602     The <Q::dis:Require> child element. The element is
1603     newly created if not exist.
1604     @@Type: ManakaiDISElement
1605     @@Get:
1606     @@@PerlDef:
1607     __DEEP{
1608     $r = $self-><M::swcfg21:SWCFGNode
1609     ::swcfg21:ForLatest.getAttributeNS>
1610     (<Q::dis:>, 'Require', make_new_node => true);
1611     }__;
1612    
1613     @Attr:
1614     @@Name: defaultForURI
1615     @@enDesc:
1616     The value of <Q::dis:DefaultFor> attribute.
1617     @@Type: ForURI
1618     @@Get:
1619     @@@enDesc:
1620     The value of <Q::dis:DefaultFor> child element. If missing,
1621     <Q::ManakaiDOM:all> is returned.
1622     @@@PerlDef:
1623     __DEEP{
1624     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1625     .getAttributeNS>
1626     (<Q::dis:>, 'DefaultFor');
1627     if ($df) {
1628     $r = $df-><AG::ManakaiDISElement.qnameValueURI>
1629     || <Q::ManakaiDOM:all>;
1630     } else {
1631     $r = <Q::ManakaiDOM:all>;
1632     }
1633     }__;
1634     @@Set:
1635     @@@PerlDef:
1636     __DEEP{
1637     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1638     (<Q::dis:>, 'DefaultFor' => $given);
1639     }__;
1640 wakaba 1.7
1641     @Attr:
1642     @@Name: definingNamespaceURI
1643     @@enDesc:
1644     The value of <Q::dis:NamespaceURI> attribute, i.e.
1645     the URI reference of the namespace that this module primary
1646     defines.
1647     \
1648     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
1649     \
1650     }
1651     @@Type: AnyURI
1652     @@Get:
1653     @@@PerlDef:
1654     __DEEP{
1655     my $df = $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
1656     .getAttributeNS>
1657     (<Q::dis:>, 'Namespace');
1658     if ($df) {
1659     $r = $df-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
1660     } else {
1661     __ASSERT{DISPerl:invariant::
1662     msg => {qq["dis:Namespace" attribute not found]},
1663     }__;
1664     }
1665     }__;
1666     @@Set:
1667     @@@PerlDef:
1668     __DEEP{
1669     $self-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.setAttributeNS>
1670     (<Q::dis:>, 'Namespace' => $given);
1671     }__;
1672 wakaba 1.4 ##DISModuleElement
1673    
1674     ClsDef:
1675 wakaba 1.2 @ClsQName: ManakaiDISElementList
1676     @enDesc:
1677     @@lang:en
1678     @@@:
1679     Lists of elements.
1680     \
1681     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
1682     later changes to the tree does not affect this type of objects.
1683     \
1684     }
1685     ##DISElementList
1686    
1687     ClsDef:
1688 wakaba 1.1 @ClsQName: ManakaiDISComment
1689 wakaba 1.7 @ClsISA: ManakaiDISNode
1690 wakaba 1.1 @ClsISA:
1691 wakaba 1.3 swcfg21:ManakaiSWCFGComment::swcfg21:ForLatest
1692 wakaba 1.1 @Description:
1693     @@lang:en
1694     @@@:
1695     <QUOTE::dis> comment node objects.
1696     ##DISComment
1697    
1698     ClsDef:
1699     @ClsQName: ManakaiDISDocumentFragment
1700 wakaba 1.7 @ClsISA: ManakaiDISNode
1701 wakaba 1.1 @ClsISA:
1702 wakaba 1.3 swcfg21:ManakaiSWCFGDocumentFragment::swcfg21:ForLatest
1703 wakaba 1.1 @Description:
1704     @@lang:en
1705     @@@:
1706     <QUOTE::dis> document fragment node objects.
1707     ##DISDocumentFragment
1708    
1709     ClsDef:
1710     @ClsQName: ManakaiDISDocument
1711 wakaba 1.7 @ClsISA: ManakaiDISNode
1712 wakaba 1.1 @ClsISA:
1713 wakaba 1.3 swcfg21:ManakaiSWCFGDocument::swcfg21:ForLatest
1714 wakaba 1.1 @Description:
1715     @@lang:en
1716     @@@:
1717     <QUOTE::dis> document node objects.
1718 wakaba 1.2
1719     @Attr:
1720 wakaba 1.4 @@Name: moduleElement
1721     @@enDesc:
1722     The <Q::dis:Module> element in this document. The element is
1723     newly created if not exist.
1724     @@Type: ManakaiDISModuleElement
1725     @@Get:
1726     @@@PerlDef:
1727     __DEEP{
1728     $r = $self-><M::swcfg21:SWCFGNode
1729     ::swcfg21:ForLatest.getAttributeNS>
1730     (<Q::dis:>, 'Module', make_new_node => true);
1731     }__;
1732     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
1733    
1734     @Attr:
1735 wakaba 1.2 @@Name: disDatabase
1736     @@enDesc:
1737     Associated <QUOTE::dis> database.
1738    
1739     @@Type: ManakaiDISDatabase
1740     @@Get:
1741     @@@NoDBException:
1742     @@@PerlDef:
1743     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
1744 wakaba 1.5 $r = $self->{<Q::TreeCore:node>}->{<Q::db>};
1745 wakaba 1.2 } else {
1746     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
1747     }
1748     @@Set:
1749     @@@PerlDef:
1750     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
1751     require Scalar::Util;
1752     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
1753 wakaba 1.5
1754     @Method:
1755     @@Name: disChildElements
1756     @@enDesc:
1757 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
1758 wakaba 1.5 @@ForParam:
1759     @@ForpParam:
1760     @@Return:
1761     @@@Type: ManakaiDISElementList
1762     @@@enDesc:
1763     The current snapshot of child nodes.
1764     @@@PerlDef:
1765     $r = bless [], <ClassName::ManakaiDISElementList>;
1766     __DEEP{
1767     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1768     .childNodes>}) {
1769     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1770     .nodeType> eq '#element';
1771     my $dn = $cn->{<Q::TreeCore:node>}
1772     -><M::ManakaiDOM:ManakaiDOMNodeObject
1773     ::ManakaiDOM:Perl.newReference>
1774     (<ClassName::ManakaiDISElement>);
1775     next unless $dn-><M::ManakaiDISElement.forMatch> ($forArg, $forpArg);
1776     push @$r, $dn;
1777     }
1778     }__;
1779 wakaba 1.10
1780     @Method:
1781     @@Name: disAllChildElements
1782     @@enDesc:
1783     A list of child elements, without <QUOTE::for> checks.
1784     @@Return:
1785     @@@Type: ManakaiDISElementList
1786     @@@enDesc:
1787     The current snapshot of child nodes.
1788     @@@PerlDef:
1789     $r = bless [], <ClassName::ManakaiDISElementList>;
1790     __DEEP{
1791     for my $cn (@{$self-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1792     .childNodes>}) {
1793     next unless $cn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
1794     .nodeType> eq '#element';
1795     my $dn = $cn->{<Q::TreeCore:node>}
1796     -><M::ManakaiDOM:ManakaiDOMNodeObject
1797     ::ManakaiDOM:Perl.newReference>
1798     (<ClassName::ManakaiDISElement>);
1799     push @$r, $dn;
1800     }
1801     }__;
1802 wakaba 1.1 ##DISDocument
1803 wakaba 1.2
1804     PropDef:
1805     @QName: db
1806     @enDesc:
1807     Associated <QUOTE::dis> database.
1808     @rdfs:domain: ManakaiDISDocument
1809     @rdfs:range: ManakaiDISDatabase
1810    
1811     ## -- Definition object database
1812    
1813     ClsDef:
1814     @ClsQName: ManakaiDISDatabase
1815     @enDesc:
1816     Resource database created from <QUOTE::dis> source data.
1817 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
1818 wakaba 1.2
1819     @Method:
1820     @@Name: getModule
1821     @@Description:
1822     @@@lang:en
1823     @@@@:
1824     Returns a <QUOTE::dis> module definition.
1825     @@Param:
1826 wakaba 1.9 @@@Name: moduleURI
1827 wakaba 1.2 @@@Type: ModuleURI
1828     @@@Description:
1829     @@@@lang:en
1830     @@@@@:
1831     A <QUOTE::dis> module URI reference.
1832 wakaba 1.9 @@ForParam:
1833 wakaba 1.2 @@Return:
1834     @@@Type: ManakaiDISModuleDefinition
1835     @@@Description:
1836     @@@@lang:en
1837     @@@@@:
1838     The module definition.
1839     @@@PerlDef:
1840 wakaba 1.9 my $modURI;
1841     if (defined $forArg) {
1842     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
1843     $uri => $modURI}__;
1844     } else {
1845     $modURI = $moduleURI;
1846     }
1847 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
1848     $r = $self->{modDef}->{$modURI};
1849     } else {
1850     $r = $self->{modDef}->{$modURI}
1851     = bless {
1852     uri => $modURI,
1853     db => $self,
1854     for => <Q::ManakaiDOM:all>,
1855     forp => [],
1856     }, <ClassName::ManakaiDISModuleDefinition>;
1857     require Scalar::Util;
1858     Scalar::Util::weaken ($r->{db});
1859     }
1860    
1861     @Method:
1862     @@Name: getFor
1863     @@Description:
1864     @@@lang:en
1865     @@@@:
1866     Returns a <QUOTE::for> definition object.
1867     @@Param:
1868     @@@Name: forURI
1869     @@@Type: ForURI
1870     @@@Description:
1871     @@@@lang:en
1872     @@@@@:
1873     A <QUOTE::for> URI reference.
1874     @@@InCase:
1875     @@@@Value:
1876     @@@@@is-null:1
1877     @@@@Description:
1878     @@@@@lang:en
1879     @@@@@@:
1880     Defaulted to <Q::ManakaiDOM:all>.
1881     @@Return:
1882     @@@Type: ManakaiDISForDefinition
1883     @@@PerlDef:
1884     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
1885     if (defined $self->{forDef}->{$forURI}) {
1886     $r = $self->{forDef}->{$forURI};
1887     } else {
1888     $r = $self->{forDef}->{$forURI}
1889     = bless {
1890     uri => $forURI,
1891     isa => {<Q::ManakaiDOM:all> => true},
1892     revISA => {},
1893     db => $self,
1894     }, <ClassName::ManakaiDISForDefinition>;
1895     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
1896     require Scalar::Util;
1897     Scalar::Util::weaken ($r->{db});
1898     }
1899    
1900     @Method:
1901     @@Name: getResource
1902     @@Description:
1903     @@@lang:en
1904     @@@@:
1905     Returns a <QUOTE::dis> resource definition.
1906     @@Param:
1907 wakaba 1.9 @@@Name: resourceURI
1908 wakaba 1.2 @@@Type: ResourceURI
1909     @@@Description:
1910     @@@@lang:en
1911     @@@@@:
1912     A <QUOTE::dis> resource URI reference.
1913 wakaba 1.3 @@@nullCase:
1914 wakaba 1.2 @@@@Description:
1915     @@@@@lang:en
1916     @@@@@@:
1917     Defaulted to <Q::DOMMain:any>.
1918 wakaba 1.9 @@ForParam:
1919 wakaba 1.2 @@Return:
1920     @@@Type: ManakaiDISResourceDefinition
1921     @@@Description:
1922     @@@@lang:en
1923     @@@@@:
1924     The resource definition.
1925     @@@PerlDef:
1926 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
1927     my $resURI;
1928     if (defined $forArg) {
1929     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
1930     $uri => $resURI}__;
1931     } else {
1932     $resURI = $resourceURI;
1933     }
1934 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
1935     $r = $self->{resDef}->{$resURI};
1936     } else {
1937     $r = $self->{resDef}->{$resURI}
1938     = bless {
1939     uri => $resURI,
1940 wakaba 1.6 aliasURI => {$resURI => true},
1941 wakaba 1.2 subOf => {},
1942     supOf => {},
1943     db => $self,
1944     for => <Q::ManakaiDOM:all>,
1945     forp => [],
1946 wakaba 1.9 seq => -1,
1947 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
1948     require Scalar::Util;
1949     Scalar::Util::weaken ($r->{db});
1950     }
1951 wakaba 1.3
1952     @Method:
1953     @@Name: getSourceFile
1954     @@enDesc:
1955     Gets <QUOTE::dis> source document.
1956     @@Param:
1957     @@@Name: fileName
1958     @@@Type: FileURI
1959     @@@enDesc:
1960     A URI reference identifying a file.
1961     @@Return:
1962     @@@Type: ManakaiDISDocument
1963     @@@enDesc:
1964     The <QUOTE::dis> source document.
1965     @@@nullCase:
1966     @@@@enDesc:
1967     No document associated with that <P::fileName>.
1968     @@@PerlDef:
1969     $r = $self->{<Q::sourceFile>}->{$fileName};
1970     @Method:
1971     @@Name: setSourceFile
1972     @@enDesc:
1973     Puts <QUOTE::dis> source document object.
1974     @@Param:
1975     @@@Name: fileName
1976     @@@Type: FileURI
1977     @@@enDesc:
1978 wakaba 1.4 A URI reference identifying a file. If there is already a
1979 wakaba 1.3 source document, then the association has been updated.
1980     @@Param:
1981     @@@Name: doc
1982     @@@Type: ManakaiDISDocument
1983     @@@enDesc:
1984     The document object to set.
1985     @@Return:
1986     @@@PerlDef:
1987     $self->{<Q::sourceFile>}->{$fileName} = $doc;
1988 wakaba 1.4
1989     @Method:
1990     @@Name: loadModule
1991     @@enDesc:
1992     Loads definitions from a <QUOTE::dis> document.
1993     @@Param:
1994     @@@Name: doc
1995     @@@Type:ManakaiDISDocument
1996     @@@enDesc:
1997     The source <QUOTE::dis> document object. Its
1998     <A::ManakaiDISDocument.disDatabase> must be this database.
1999     @@Param:
2000     @@@Name: resolver
2001     @@@Type: DISModuleResolver
2002     @@@enDesc:
2003     The resolver to convert module name into <QUOTE::dis> document object.
2004     @@ForParam:
2005     @@Return:
2006     @@@RaiseException:
2007     @@@@@: NO_MODULE_QNAME_ERR
2008     @@@@enDesc:
2009     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2010     @@@RaiseException:
2011     @@@@@: UNABLE_TO_GET_MODULE_ERR
2012     @@@@enDesc:
2013     The implementation is unable to get a module source.
2014 wakaba 1.5 @@@ForDefDupException:
2015     @@@ForDefNoQNameException:
2016     @@@ResDefDupException:
2017     @@@ElementNotAllowedException:
2018 wakaba 1.7 @@@RaiseException:
2019     @@@@@:NO_REQUIRED_ATTR_ERR
2020     @@@@enDesc:
2021     The <Q::dis:Module> element does not have
2022     <Q::dis:Namespace> attribute.
2023 wakaba 1.4 @@@PerlDef:
2024     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2025     if ref $resolver eq 'CODE';
2026     ## -- Module Name, URI
2027     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2028     my $mod_node;
2029     my $mod_name_node;
2030     __DEEP{
2031     $mod_node = $doc-><AG::ManakaiDISDocument.moduleElement>;
2032     $mod_name_node = $mod_node-><M::swcfg21:SWCFGNode
2033     ::swcfg21:ForLatest.getAttributeNS>
2034     (<Q::dis:>, 'QName');
2035     unless ($mod_name_node) {
2036     __UNDEEP{
2037     __EXCEPTION{NO_MODULE_QNAME_ERR::
2038     DIS:sourceNode => {$mod_node},
2039     }__;
2040     }__;
2041     }
2042 wakaba 1.5 my $mod_name_uri = $mod_name_node
2043     -><AG::ManakaiDISElement.qnameValueURI>;
2044 wakaba 1.9 my $mod = $self-><M::ManakaiDISDatabase.getModule>
2045     ($mod_name_uri, for_arg => $forArg);
2046 wakaba 1.4
2047     unless ($mod-><M::ManakaiDISModuleDefinition.isDefined>) {
2048     ## -- Initializes Module Definition Object
2049     $mod->{nameURI} = $mod_name_uri;
2050     $mod->{localName} = $mod_name_node-><AG::ManakaiDISElement
2051     .qnameValueLocalName>;
2052     $mod->{namespaceURI} = $mod_name_node-><AG::ManakaiDISElement
2053     .qnameValueNamespaceURI>;
2054     $mod->{for} = $forArg;
2055     $mod->{src} = $mod_node;
2056 wakaba 1.5 $mod->{<Q::isDefined>} = true;
2057 wakaba 1.4 $self-><M::ManakaiDISDatabase.setSourceFile>
2058 wakaba 1.5 ($mod->{nameURI} => $doc);
2059    
2060 wakaba 1.9 $mod->{<Q::DIS:sourceFile>}
2061     = $mod->{src}
2062     -><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.ownerDocument>
2063     -><M::swcfg21:SWCFGNode::swcfg21:ForLatest.flag>
2064     (<Q::swcfg21:fileName>);
2065 wakaba 1.5
2066     ## -- Loads "for all"
2067 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2068     ($mod->{nameURI}, for_arg => <Q::ManakaiDOM:all>);
2069 wakaba 1.5 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2070     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2071 wakaba 1.9 ($self, $rmod->{uri}, $mod->{namespaceURI},
2072     $mod->{localName}, <Q::ManakaiDOM:all>);
2073 wakaba 1.5 unless ($rdoc) {
2074     __UNDEEP{
2075     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2076 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2077 wakaba 1.5 DIS:namespaceURI => {$mod->{namespaceURI}},
2078     DIS:localName => {$mod->{localName}},
2079 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2080 wakaba 1.5 DIS:sourceNode => {$mod->{src}},
2081     }__;
2082     }__;
2083     }
2084     $self-><M::ManakaiDISDatabase.loadModule>
2085 wakaba 1.9 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>);
2086 wakaba 1.5 } # Unless "for all" loaded
2087 wakaba 1.4
2088     ## -- Loads Required Modules
2089 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2090 wakaba 1.4 my $req_node = $mod_node-><AG::ManakaiDISModuleElement
2091     .requireElement>;
2092 wakaba 1.10 for my $rm (@{$req_node-><M::ManakaiDISElement
2093     .disAllChildElements>}) {
2094 wakaba 1.4 next unless $rm-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2095     .expandedURI> eq <Q::dis:Module>;
2096     my ($uri, $nuri, $ln, $for);
2097     my $mqn = $rm-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2098     .getAttributeNS> (<Q::dis:>, 'QName');
2099     if ($mqn) {
2100     my $mqv = $mqn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2101     .value>;
2102     my $mqp = $mqn-><AG::ManakaiDISElement.qnameToPair>
2103     ($mqv, node => $mqn);
2104     ($nuri, $ln) = @$mqp;
2105     } else {
2106     my $mn = $rm-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2107     .getAttributeNS> (<Q::dis:>, 'Name');
2108     if ($mn) {
2109     $nuri = $mod->{namespaceURI};
2110     $ln = $mn-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2111     } else {
2112     $nuri = $mod->{namespaceURI};
2113     $ln = $mod->{localName};
2114     }
2115     }
2116     my $wfn = $rm-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest
2117     .getAttributeNS> (<Q::dis:>, 'WithFor');
2118     if ($wfn) {
2119     $for = $wfn-><AG::ManakaiDISElement.qnameValueURI>;
2120     } else {
2121     $for = $mod->{for};
2122     }
2123 wakaba 1.9 my $rmod = $self-><M::ManakaiDISDatabase.getModule>
2124     ($nuri . $ln, for_arg => $for);
2125 wakaba 1.4 unless ($rmod-><AG::ManakaiDISModuleDefinition.isDefined>) {
2126     my $rdoc = $resolver-><M::ManakaiDISModuleResolver.uriToDocument>
2127 wakaba 1.9 ($self, $rmod->{uri}, $nuri, $ln, $for);
2128 wakaba 1.4 unless ($rdoc) {
2129     __UNDEEP{
2130     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2131 wakaba 1.9 DIS:uri => {$rmod->{uri}},
2132 wakaba 1.4 DIS:namespaceURI => {$nuri},
2133     DIS:localName => {$ln},
2134     DIS:for => {$for},
2135     DIS:sourceNode => {$rm},
2136     }__;
2137     }__;
2138     }
2139     $self-><M::ManakaiDISDatabase.loadModule>
2140     ($rdoc, $resolver, for_arg => $for);
2141     }
2142     } # Child Module elements
2143    
2144 wakaba 1.10 my $root_elements
2145     = $doc-><M::ManakaiDISDocument.disAllChildElements>;
2146 wakaba 1.5 if ($mod->{for} eq <Q::ManakaiDOM:all>) {
2147     ## -- Loads "for" definitions
2148     for my $el (@$root_elements) {
2149     next unless $el-><M::swcfg21:SWCFGElement::swcfg21:ForLatest
2150     .expandedURI> eq <Q::dis:ForDef>;
2151     $self-><M::ManakaiDISDatabase.loadFor> ($mod, $el);
2152     }
2153     }
2154    
2155 wakaba 1.10 $root_elements = $doc-><M::ManakaiDISDocument.disChildElements>
2156     (for_arg => $forArg);
2157 wakaba 1.5 for my $el (@$root_elements) {
2158 wakaba 1.7 if ($el-><M::ManakaiDISElement.isResourceElement>) {
2159     $self-><M::ManakaiDISDatabase.loadResource>
2160 wakaba 1.9 ($mod, null, null, $el,
2161 wakaba 1.7 for_arg => $forArg);
2162     } else {
2163     my $et = $el-><M::swcfg21:SWCFGElement::swcfg21:ForLatest
2164     .expandedURI>;
2165     if ({
2166 wakaba 1.5 <Q::dis:ForDef> => 1,
2167     <Q::dis:Module> => 1,
2168     <Q::dis:ImplNote> => 1,
2169 wakaba 1.7 }->{$et}) {
2170     #
2171     } else {
2172     __UNDEEP{
2173     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2174     DIS:elementType => {$et},
2175     DIS:sourceNode => {$el},
2176     DIS:uri => {$mod->{uri}},
2177     }__;
2178 wakaba 1.5 }__;
2179 wakaba 1.7 }
2180     } # element types
2181     }
2182    
2183     my $dn = $mod_node-><M::swcfg21:SWCFGNode::swcfg21:ForLatest
2184     .getAttributeNS>
2185     (<Q::dis:>, 'Namespace');
2186     unless ($dn and defined $dn-><AG::swcfg21:SWCFGNode
2187     ::swcfg21:ForLatest.value>) {
2188     __UNDEEP{
2189     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2190     DIS:elementType => {<Q::dis:Namespace>},
2191     DIS:sourceNode => {$mod_node},
2192 wakaba 1.5 }__;
2193 wakaba 1.7 }__;
2194 wakaba 1.5 }
2195     } # Unless this module loaded
2196     }__; # Deep
2197    
2198     @Method:
2199     @@Name: loadFor
2200     @@enDesc:
2201     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2202     @@Param:
2203     @@@Name: mod
2204     @@@Type: ManakaiDISModuleDefinition
2205     @@@enDesc:
2206     The module in which the <QUOTE::for> to load is defined.
2207     @@Param:
2208     @@@Name: el
2209     @@@Type:ManakaiDISElement
2210     @@@enDesc:
2211     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2212     @@Return:
2213     @@@ForDefDupException:
2214     @@@ForDefNoQNameException:
2215     @@@ElementNotAllowedException:
2216     @@@PerlDef:
2217     __DEEP{
2218     my $qn_node = $el-><M::swcfg21:SWCFGNode
2219     ::swcfg21:ForLatest.getAttributeNS>
2220     (<Q::dis:>, 'QName');
2221     unless ($qn_node) {
2222     __UNDEEP{
2223     __EXCEPTION{NO_FOR_QNAME_ERR::
2224     DIS:sourceNode => {$qn_node},
2225     }__;
2226     }__;
2227     }
2228     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2229     my $for = $self-><M::ManakaiDISDatabase.getFor> ($qn_uri);
2230    
2231     unless ($for-><M::ManakaiDISForDefinition.isDefined>) {
2232 wakaba 1.10 ## -- Initializes "For" Definition Object
2233 wakaba 1.5 $for->{src} = $el;
2234     $for->{<Q::isDefined>} = true;
2235     $for->{<Q::definingModule>} = $mod->{uri};
2236    
2237 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2238 wakaba 1.5 my $xn = $ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
2239     .expandedURI>;
2240     if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2241     my $sfor = $self-><M::ManakaiDISDatabase.getFor>
2242 wakaba 1.7 ($ce-><AG::ManakaiDISElement.qnameValueURI>);
2243 wakaba 1.5 $for-><M::ManakaiDISForDefinition.addISA> ($sfor);
2244 wakaba 1.7 $sfor-><M::ManakaiDISForDefinition.isReferred> ($ce);
2245 wakaba 1.5 ## TODO: warn if dis:Implement
2246     } elsif ({
2247     <Q::dis:Description> => 1,
2248     <Q::dis:ImplNote> => 1,
2249     <Q::dis:FullName> => 1,
2250     <Q::dis:QName> => 1,
2251     }->{$xn}) {
2252     #
2253     } else {
2254     __UNDEEP{
2255     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2256     DIS:elementType => {$xn},
2257     DIS:sourceNode => {$ce},
2258     DIS:uri => {$mod->{uri}},
2259     }__;
2260     }__;
2261     }
2262     }
2263     } else {
2264     __UNDEEP{
2265     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
2266     DIS:sourceNode => {$el},
2267     DIS:anotherSourceNode => {$for->{src}},
2268     }__;
2269     }__;
2270     } # isDefine?
2271     }__; # DEEP
2272    
2273     @Method:
2274     @@Name: loadResource
2275     @@enDesc:
2276     Loads definition of a <QUOTE::dis> resource from a
2277     <Q::dis:ResourceDef> element.
2278     @@Param:
2279     @@@Name: mod
2280     @@@Type: ManakaiDISModuleDefinition
2281     @@@enDesc:
2282     The module in which the resource to load is defined.
2283     @@Param:
2284     @@@Name: parentResource
2285     @@@Type: ManakaiDISResourceDefinition
2286     @@@enDesc:
2287 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
2288 wakaba 1.5 @@@nullCase:
2289     @@@@enDesc:
2290     The resource to load is a root resource, i.e. <P::el> is
2291     a direct child of the document node.
2292     @@Param:
2293 wakaba 1.7 @@@Name: dynParent
2294 wakaba 1.9 @@@Type: ManakaiDISResourceDefinition
2295 wakaba 1.7 @@@enDesc:
2296     The dynamic parent resource of the resource to load.
2297 wakaba 1.9 @@@nullCase:
2298 wakaba 1.7 @@@@enDesc:
2299 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
2300     a direct child of the document node.
2301 wakaba 1.7 @@Param:
2302 wakaba 1.5 @@@Name: el
2303     @@@Type:ManakaiDISElement
2304     @@@enDesc:
2305     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
2306     @@ForParam:
2307     @@ForpParam:
2308     @@Return:
2309     @@@ResDefDupException:
2310     @@@ElementNotAllowedException:
2311     @@@PerlDef:
2312     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
2313     $forpArg ||= [];
2314     __DEEP{
2315 wakaba 1.6 ## -- Node names
2316    
2317     ## Unique resource identifier generated from node id
2318     my $node_id = $el-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.nodeID>;
2319     my $node_uri;
2320     __CODE{tfpurisToURI:: $turi => $node_id, $furi => $forArg,
2321     $forp => $forpArg, $uri => $node_uri}__;
2322    
2323     ## User defined resource identifiers
2324 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
2325     (<Q::dis:QName>, for_arg => $forArg,
2326     forp_arg => $forpArg);
2327     my $res;
2328     if ($qn_node) {
2329     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
2330 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2331     ($qn_uri, for_arg => $forArg);
2332 wakaba 1.5 if ($res-><M::ManakaiDISForDefinition.isDefined>) {
2333     __UNDEEP{
2334     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2335 wakaba 1.9 DIS:uri => {$res->{uri}},
2336 wakaba 1.5 DIS:sourceNode => {$qn_node},
2337     DIS:anotherSourceNode => {$res->{src}},
2338     }__;
2339 wakaba 1.6 }__;
2340 wakaba 1.5 }
2341     $res->{nameURI} = $qn_uri;
2342     $res->{localName} = $qn_node-><AG::ManakaiDISElement
2343     .qnameValueLocalName>;
2344     $res->{namespaceURI} = $qn_node-><AG::ManakaiDISElement
2345     .qnameValueNamespaceURI>;
2346     } else { ## Anonymous or local
2347     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
2348     (<Q::dis:Name>, for_arg => $forArg,
2349     forp_arg => $forpArg);
2350     if ($n_node) {
2351     if ($parentResource) {
2352     my $puri = $parentResource->{uri};
2353     my $ru;
2354     my $ln = $res->{localName};
2355     __CODE{getChildResourceURI:: $parentURI => $puri,
2356     $localName => $ln,
2357     $result => $ru}__;
2358 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2359     ($ru, for_arg => $forArg);
2360 wakaba 1.5 $res->{nameURI} = $ru;
2361 wakaba 1.6 $res->{localName} = $n_node-><AG::swcfg21:SWCFGNode
2362     ::swcfg21:ForLatest.value>;
2363 wakaba 1.5 $res->{<Q::isAnon>} = true;
2364 wakaba 1.6 $res->{aliasURI}->{$node_uri} = true;
2365     $self->{resDef}->{$node_uri} = $res;
2366 wakaba 1.5 } else { ## Root local name resource
2367 wakaba 1.7 my $ln = $n_node-><AG::swcfg21:SWCFGNode
2368     ::swcfg21:ForLatest.value>;
2369     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
2370     .getPropertyText>
2371     (<Q::dis:Namespace>, null);
2372     my $qn_uri = $ns_uri . $ln;
2373 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2374     ($qn_uri, for_arg => $forArg);
2375 wakaba 1.6 if ($res-><M::ManakaiDISForDefinition.isDefined>) {
2376     __UNDEEP{
2377     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2378 wakaba 1.9 DIS:uri => {$res->{uri}},
2379 wakaba 1.6 DIS:sourceNode => {$n_node},
2380     DIS:anotherSourceNode => {$res->{src}},
2381     }__;
2382     }__;
2383     }
2384     $res->{nameURI} = $qn_uri;
2385 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
2386     $res->{localName} = $ln;
2387 wakaba 1.5 }
2388     } else {
2389 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2390 wakaba 1.5 $res->{<Q::isAnon>} = true;
2391     }
2392 wakaba 1.6 } # anon
2393 wakaba 1.5 $res->{for} = $forArg;
2394     $res->{forp} = $forpArg;
2395     $res->{src} = $el;
2396     $res->{<Q::definingModule>} = $mod->{uri};
2397 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
2398     (<Q::DIS:resource>, $res);
2399 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
2400     = $parentResource ? $parentResource->{uri} : null;
2401     $res->{<Q::dynamicParentResource>}
2402 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
2403     unless ($res->{uri} eq $node_uri) {
2404     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2405     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
2406     }
2407 wakaba 1.7 $res->{<Q::isDefined>} = true;
2408 wakaba 1.9 $res->{seq} = $self->{seq}++;
2409    
2410 wakaba 1.6 ## -- Alias
2411     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
2412     (<Q::dis:AliasFor>, for_arg => $forArg,
2413     forp_arg => $forpArg);
2414     if ($al_node) {
2415     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
2416     ($node_id, $forArg);
2417     my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
2418     ($canon_uri);
2419     $canon_res-><M::ManakaiDISResourceDefinition.isReferred> ($al_node);
2420     $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($res);
2421     $res = $canon_res;
2422     }
2423 wakaba 1.5
2424 wakaba 1.7 my $is_multires = false;
2425     my @props;
2426     my @cres;
2427 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
2428     (for_arg => $forArg, forp_arg => $forpArg)};
2429 wakaba 1.7 while (@ce0) {
2430     my $ce = shift @ce0;
2431     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
2432     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
2433     $res->{<Q::rdf:type>}->{$type_uri} = true;
2434     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
2435     $type-><M::ManakaiDISResourceDefinition.isReferred> ($ce);
2436     if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
2437     (<Q::dis:MultipleResource>)) {
2438     $is_multires = true;
2439     }
2440     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
2441     (<Q::dis:subsetOf>)) {
2442     my $sres = $self-><M::ManakaiDISDatabase.getResource>
2443     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
2444     ($node_id, $forArg));
2445     $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
2446     } elsif ($ce-><M::ManakaiDISElement.isResourceElement>) {
2447     push @cres, $ce;
2448     } else {
2449     ## Property and invalid element is not checked, since not
2450     ## all property definitions has loaded at this stage.
2451     push @props, $ce;
2452     }
2453     } # @ce0
2454    
2455     ## -- Child resources
2456     unless ($is_multires) {
2457     for my $re (@cres) {
2458     unless ($al_node) {
2459     $self-><M::ManakaiDISDatabase.loadResource>
2460     ($mod, $res, $res, $re,
2461     for_arg => $forArg, forp_arg => $forpArg);
2462 wakaba 1.5 } else {
2463 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
2464     (<Q::dis:aliasChild>, for_arg => $forArg,
2465     forp_arg => $forpArg);
2466     if ($ac and $ac-><M::swcfg21:SWCFGNode
2467     ::swcfg21:ForLatest.value>) {
2468     $self-><M::ManakaiDISDatabase.loadResource>
2469     ($mod, $res, $res, $re,
2470     for_arg => $forArg, forp_arg => $forpArg);
2471     }
2472 wakaba 1.4 }
2473     }
2474 wakaba 1.7 }
2475 wakaba 1.5
2476 wakaba 1.7 ## -- Multiple representations
2477     if ($is_multires) {
2478     for my $pe (@props) {
2479     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
2480 wakaba 1.10 (<Q::dis:resourceFor>)) {
2481 wakaba 1.7 my $for_uri = $pe-><M::ManakaiDISElement.qnameValueURI>;
2482     my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
2483     $for-><M::ManakaiDISForDefinition.isReferred> ($pe);
2484     $self-><M::ManakaiDISDatabase.loadResource>
2485     ($mod, $parentResource, $res, $el,
2486     for_arg => $forArg,
2487     forp_arg => [@{$forpArg}, $for_uri]);
2488     }
2489     }
2490     }
2491 wakaba 1.5 }__; # DEEP
2492 wakaba 1.8
2493     @Method:
2494     @@Name: checkUndefinedResource
2495     @@enDesc:
2496     Checks whether there is referred but undefined resource or not.
2497     @@Return:
2498     @@@RaiseException:
2499     @@@@@: FOR_NOT_DEFINED_ERR
2500     @@@@enDesc:
2501     There is a <QUOTE::for> that is referred but not defined.
2502     @@@RaiseException:
2503     @@@@@: RESOURCE_NOT_DEFINED_ERR
2504     @@@@enDesc:
2505     There is a resource that is referred but not defined.
2506     @@@PerlDef:
2507     for my $fd (values %{$self->{forDef}}) {
2508     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
2509     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
2510     __EXCEPTION{FOR_NOT_DEFINED_ERR::
2511     DIS:uri => {$fd->{uri}},
2512     DIS:sourceNode => {$ref},
2513     }__;
2514     }
2515     }
2516     for my $fd (values %{$self->{resDef}}) {
2517     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
2518     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
2519     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2520     DIS:uri => {$fd->{uri}},
2521     DIS:sourceNode => {$ref},
2522     }__;
2523     }
2524     }
2525 wakaba 1.5
2526 wakaba 1.9
2527     @Method:
2528     @@Name: plStore
2529     @@enDesc:
2530     Saves this database to an external file.
2531     \
2532     {NOTE:: Saved files can be loaded by
2533     <M::ManakaiDISImplementation.plLoadDISDatabase>.
2534     \
2535     }
2536     @@Param:
2537     @@@Name: fileName
2538     @@@Type:
2539     DISLang:String
2540     @@@enDesc:
2541     An environment-dependent file name of external database to save.
2542     \
2543     {NOTE:: If there is already a file named as <P::fileName>, then
2544     it is overwritten.
2545     \
2546     }
2547     @@Return:
2548     @@@SimpleException:
2549     @@@PerlDef:
2550     use Storable qw/nstore/;
2551     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
2552     nstore $self, $fileName;
2553 wakaba 1.2 ##DISDatabase
2554    
2555 wakaba 1.8 PropDef:
2556 wakaba 1.9 @QName: resource
2557     @enDesc:
2558     Resources defined in a module.
2559     @rdfs:range: ManakaiDISResourceDefinition
2560     @rdfs:domain: ManakaiDISModuleDefinition
2561    
2562     PropDef:
2563 wakaba 1.8 @QName:
2564     dis2pm:parentResource
2565     @enDesc:
2566     Static parent resource. No parent for root resources.
2567    
2568     PropDef:
2569     @QName: dynamicParentResource
2570     @enDesc:
2571     Dynamic parent resource. No parent for root resources.
2572    
2573 wakaba 1.5 ElementTypeBinding:
2574     @Name: ForDefDupException
2575     @ElementType:
2576     ManakaiDOM:raises
2577     @ShadowContent:
2578     @@@: FOR_ALREADY_DEFINED_ERR
2579     @@Description:
2580     @@@lang:en
2581     @@@@:
2582     The <QUOTE::for> is already defined elsewhere.
2583    
2584     ElementTypeBinding:
2585     @Name: ForDefNoQNameException
2586     @ElementType:
2587     ManakaiDOM:raises
2588     @ShadowContent:
2589     @@@: NO_FOR_QNAME_ERR
2590     @@Description:
2591     @@@lang:en
2592     @@@@:
2593     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
2594    
2595     ElementTypeBinding:
2596     @Name: ResDefDupException
2597     @ElementType:
2598     ManakaiDOM:raises
2599     @ShadowContent:
2600     @@@: RESOURCE_ALREADY_DEFINED_ERR
2601     @@Description:
2602     @@@lang:en
2603     @@@@:
2604     The <QUOTE::dis> resource is already defined elsewhere.
2605    
2606     ElementTypeBinding:
2607     @Name: ElementNotAllowedException
2608     @ElementType:
2609     ManakaiDOM:raises
2610     @ShadowContent:
2611     @@@: ELEMENT_NOT_ALLOWED_ERR
2612     @@Description:
2613     @@@lang:en
2614     @@@@:
2615     An element has found where it is not allowed.
2616    
2617 wakaba 1.4 IFClsDef:
2618     @QName:
2619     @@@: DISModuleResolver
2620     @@ForCheck: ForIF
2621     @QName:
2622     @@@: ManakaiDISModuleResolver
2623     @@ForCheck: ForClass
2624     @enDesc:
2625     Objects implementing <IF::DISModuleResolver> interface
2626     are used to convert module name into <QUOTE::dis> document object.
2627     \
2628     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
2629     as a method parameter where <IF::DISModuleResolver> is
2630     expected.
2631     \
2632     }
2633     @Method:
2634     @@Name: uriToDocument
2635     @@enDesc:
2636     Returns a <QUOTE::dis> document from module name information.
2637     @@Param:
2638     @@@Name: disDB
2639     @@@Type: ManakaiDISDatabase
2640     @@@enDesc:
2641     The <QUOTE::dis> database.
2642     @@Param:
2643     @@@Name: moduleURI
2644     @@@Type: ModuleURI
2645     @@@enDesc:
2646     The URI reference of the module.
2647     \
2648     {NOTE:: This parameter is redundant, since it can be
2649     composed from other three parameters.
2650     \
2651     }
2652     @@Param:
2653     @@@Name: moduleNamespaceURI
2654     @@@Type: AnyURI
2655     @@@enDesc:
2656     The namespace URI of the module name.
2657     @@Param:
2658     @@@Name: moduleLocalName
2659     @@@Type:
2660     DISCore:LocalName
2661     @@@enDesc:
2662     The local name of the module name.
2663     @@Param:
2664     @@@Name: moduleFor
2665     @@@Type: ForURI
2666     @@@enDesc:
2667     The <QUOTE::for> URI reference for which the module is defined.
2668     @@Return:
2669     @@@Type: ManakaiDISDocument
2670     @@@enDesc:
2671     The <QUOTE::dis> document. It don't have to be a newly created
2672     object.
2673     @@@nullCase:
2674     @@@@enDesc:
2675     The method is unable to resolve the reference.
2676     @@@PerlDef:
2677     $r = $self->(@_);
2678     @ManakaiDOM:inputNormalizer:
2679     @@ContentType:
2680     lang:Perl
2681     @@@:
2682     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
2683     if ref $INPUT eq 'CODE';
2684     @@ImplNote:
2685     @@@lang:en
2686     @@@@:
2687     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
2688     ##DISModuleResolver
2689    
2690 wakaba 1.3 PropDef:
2691     @QName: sourceFile
2692     @enDesc:
2693     Source <QUOTE::dis> documents.
2694     @rdfs:domain: ManakaiDISDatabase
2695     @rdfs:range: ManakaiDISDocument
2696    
2697 wakaba 1.2 ClsDef:
2698     @ClsQName: ManakaiDISModuleDefinition
2699     @enDesc:
2700     <QUOTE::dis> module definitions.
2701     @ClsISA: ManakaiDISPropertyAccessor
2702 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2703 wakaba 1.2
2704     @Attr:
2705     @@Name: uri
2706     @@Type: ModuleURI
2707     @@Description:
2708     @@@lang:en
2709     @@@@:
2710     The URI reference of this <QUOTE::dis> module.
2711     @@Get:
2712     @@@PerlDef:
2713     $r = $self->{uri};
2714    
2715     @Attr:
2716     @@Name: nameURI
2717     @@Type: NameURI
2718     @@enDesc:
2719     The URI reference of this module, without
2720     <QUOTE::for> identifier.
2721     @@Get:
2722 wakaba 1.3 @@@PerlDef:
2723 wakaba 1.4 $r = $self->{nameURI};
2724 wakaba 1.2
2725     @Attr:
2726     @@Name: localName
2727     @@enDesc:
2728     The local name of this module.
2729     @@Type:
2730 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
2731 wakaba 1.2 @@Get:
2732     @@@PerlDef:
2733     $r = $self->{localName};
2734    
2735     @Attr:
2736     @@Name: namespaceURI
2737     @@Type: AnyURI
2738     @@enDesc:
2739     The namespace URI of the name of this resource.
2740     @@Get:
2741     @@@PerlDef:
2742     $r = $self->{namespaceURI};
2743    
2744     @Attr:
2745     @@Name: forURI
2746     @@Type: ForURI
2747     @@enDesc:
2748     The <QUOTE::for> URI reference for which this module is defined.
2749     @@Get:
2750     @@@PerlDef:
2751     $r = $self->{for};
2752    
2753     @Attr:
2754     @@Name: isDefined
2755     @@Description:
2756     @@@lang:en
2757     @@@@:
2758     Whether this module is defined or not.
2759     @@Type:
2760     DOMMain:boolean
2761     @@Get:
2762     @@@PerlDef:
2763     $r = $self->{<Q::isDefined>};
2764 wakaba 1.8
2765     @Attr:
2766     @@Name: plFullyQualifiedName
2767     @@enDesc:
2768     The fully-qualified Perl class package name.
2769     @@Type:
2770     Perl:package-name::ManakaiDOM:all
2771     @@Get:
2772     @@@NoPerlModuleNameException:
2773     @@@PerlDef:
2774     __DEEP{
2775     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2776     ($self->{namespaceURI});
2777     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2778     __UNDEEP{
2779     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2780     DIS:uri => {$self->{namespaceURI}},
2781     DIS:sourceNode => {$self->{src}},
2782     }__;
2783     }__;
2784     }
2785     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2786     (<Q::dis:AppName>, for_arg => $self->{for},
2787 wakaba 1.10 media_type => <Q::lang:Perl>,
2788     default_media_type => <Q::lang:Perl>);
2789 wakaba 1.8 if ($an) {
2790     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2791     $r =~ s/::$//g;
2792     $r .= '::' . $self->{localName};
2793     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2794     (<Q::ManakaiDOM:moduleSuffix>,
2795     for_arg => $self->{for},
2796     media_type => <Q::lang:Perl>,
2797     default_media_type => <Q::lang:Perl>);
2798     if ($sf) {
2799     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2800     }
2801     } else {
2802 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
2803 wakaba 1.8 }
2804     }__;
2805    
2806     @Attr:
2807     @@Name: plInterfaceName
2808     @@enDesc:
2809     The fully-qualified Perl interface package name.
2810     @@Type:
2811     Perl:package-name::ManakaiDOM:all
2812     @@Get:
2813     @@@NoPerlModuleNameException:
2814     @@@PerlDef:
2815     __DEEP{
2816     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2817     ($self->{namespaceURI});
2818     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2819     __UNDEEP{
2820     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2821     DIS:uri => {$self->{namespaceURI}},
2822     DIS:sourceNode => {$self->{src}},
2823     }__;
2824     }__;
2825     }
2826     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2827     (<Q::dis:AppName>, for_arg => $self->{for},
2828     forp_arg => [<Q::ManakaiDOM:ForIF>],
2829 wakaba 1.10 media_type => <Q::lang:Perl>,
2830     default_media_type => <Q::lang:Perl>);
2831 wakaba 1.8 if ($an) {
2832     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2833     $r =~ s/::$//g;
2834     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2835     (<Q::ManakaiDOM:moduleSuffix>,
2836     for_arg => $self->{for},
2837     forp_arg => [<Q::ManakaiDOM:ForIF>],
2838     media_type => <Q::lang:Perl>,
2839     default_media_type => <Q::lang:Perl>);
2840     if ($sf) {
2841     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2842     }
2843     } else {
2844     $r = $self-><M::ManakaiDISModuleDefinition.plFullyQualifiedName>;
2845     }
2846     }__;
2847 wakaba 1.2 ##DISModuleDefinition
2848    
2849 wakaba 1.8 ElementTypeBinding:
2850     @Name: NoPerlModuleNameException
2851     @ElementType:
2852     ManakaiDOM:raises
2853     @ShadowContent:
2854     @@@: RESOURCE_NOT_DEFINED_ERR
2855     @@Description:
2856     @@@lang:en
2857     @@@@:
2858     The module group corresponding to the namespace URI
2859     of this module is not defined.
2860    
2861 wakaba 1.2 ClsDef:
2862     @ClsQName: ManakaiDISForDefinition
2863     @Description:
2864     @@lang:en
2865     @@@:
2866     <QUOTE::dis> <QUOTE::for> definitions.
2867 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2868 wakaba 1.2
2869     @Attr:
2870     @@Name: uri
2871     @@Type: ForURI
2872     @@Description:
2873     @@@lang:en
2874     @@@@:
2875     The URI reference of this <QUOTE::for>.
2876     @@Get:
2877     @@@PerlDef:
2878     $r = $self->{uri};
2879 wakaba 1.10
2880     @IntMethod:
2881     @@Operator:
2882     @@@@:eq
2883     @@@ContentType:
2884     lang:Perl
2885     @@enDesc:
2886     Whether two <QUOTE::for> definitions are equal or not.
2887     Two <QUOTE::for> definitions are equal iff one's URI reference
2888     is one of another's URI reference.
2889     \
2890     {NOTE:: Aliases for <QUOTE::for> is not allowed.
2891     \
2892     }
2893     @@ImplNote:
2894     @@@lang:en
2895     @@@@:
2896     In the current implementation, two are equal iff two are
2897     equal as reference.
2898     @@Param:
2899     @@@Name: anotherFor
2900     @@@Type: ManakaiDISForDefinition
2901     @@@enDesc:
2902     Another <QUOTE::for> definition to compare.
2903     @@Return:
2904     @@@Type:
2905     DOMMain:boolean
2906     @@@enDesc:
2907     Whether two resources are equal or not.
2908     @@@PerlDef:
2909     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
2910     $r = $self->{uri} eq $anotherFor->{uri};
2911     } else {
2912     $r = false;
2913     }
2914 wakaba 1.2
2915     @Method:
2916     @@Name: isaURI
2917     @@Description:
2918     @@@lang:en
2919     @@@@:
2920     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
2921     @@Param:
2922     @@@Name: superURI
2923     @@@Type: ForURI
2924     @@@Description:
2925     @@@@lang:en
2926     @@@@@:
2927     Another <QUOTE::for> URI reference to test.
2928     @@Return:
2929     @@@Type:
2930     DOMMain:boolean
2931     @@@TrueCase:
2932     @@@@enDesc:
2933     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
2934     @@@FalseCase:
2935     @@@@enDesc:
2936     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
2937     @@@PerlDef:
2938     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
2939    
2940     @Attr:
2941     @@Name: isDefined
2942     @@Description:
2943     @@@lang:en
2944     @@@@:
2945     Whether this <QUOTE::for> is already defined or not.
2946     @@Type:
2947     DOMMain:boolean
2948     @@Get:
2949     @@@TrueCase:
2950     This <QUOTE::for> is already defined.
2951     @@@FalseCase:
2952     This <QUOTE::for> is not defined.
2953     @@@PerlDef:
2954     $r = $self->{<Q::isDefined>};
2955    
2956     @Attr:
2957     @@Name: isReferred
2958     @@Description:
2959     @@@lang:en
2960     @@@@:
2961     Whether this <QUOTE::for> is referred somewhere or not.
2962 wakaba 1.9 @@Type: ManakaiDISElement
2963 wakaba 1.2 @@Get:
2964     @@@InCase:
2965     @@@@Type:ManakaiDISElement
2966     @@@@enDesc:
2967     This <QUOTE::for> is referred by the element.
2968     @@@nullCase:
2969     This <QUOTE::for> is not referred.
2970     @@@PerlDef:
2971     $r = $self->{<Q::isReferred>};
2972     @@Set:
2973     @@@InCase:
2974     @@@@Type:ManakaiDISElement
2975     @@@@enDesc:
2976     This <QUOTE::for> is referred by the element.
2977     @@@PerlDef:
2978 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
2979 wakaba 1.2
2980     @Attr:
2981     @@Name: definingModule
2982     @@Description:
2983     @@@lang:en
2984     @@@@:
2985     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
2986     @@Type: ManakaiDISModuleDefinition
2987     @@Get:
2988     @@@Description:
2989     @@@@lang:en
2990     @@@@@:
2991     The module object.
2992 wakaba 1.3 @@@nullCase:
2993 wakaba 1.2 @@@@Description:
2994     @@@@@lang:en
2995     @@@@@@:
2996     This <QUOTE::for> is not associated to any module.
2997     @@@PerlDef:
2998     $r = $self->{db}
2999     -><M::ManakaiDISDatabase.getResource>
3000     ($self->{<Q::definingModule>})
3001     if defined $self->{<Q::definingModule>};
3002 wakaba 1.5
3003 wakaba 1.2 @Method:
3004 wakaba 1.5 @@Name: addISA
3005 wakaba 1.2 @@enDesc:
3006 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3007     <QUOTE::for>.
3008 wakaba 1.2 @@Param:
3009 wakaba 1.5 @@@Name: superFor
3010     @@@Type: ManakaiDISForDefinition
3011     @@@enDesc:
3012     A <QUOTE::for> definition object.
3013 wakaba 1.2 @@Return:
3014     @@@PerlDef:
3015 wakaba 1.5 my @from = ($self->{uri},
3016     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3017     my @to = ($superFor->{uri},
3018     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3019 wakaba 1.7 __DEEP{
3020     for my $from (@from) {
3021     for my $to (@to) {
3022     $self->{db}-><M::ManakaiDISDatabase.getFor>
3023     ($from)->{isa}->{$to} = true;
3024     $self->{db}-><M::ManakaiDISDatabase.getFor>
3025     ($to)->{revISA}->{$from} = true;
3026     }
3027 wakaba 1.5 }
3028 wakaba 1.7 }__;
3029 wakaba 1.5
3030 wakaba 1.2 ##DISForDefinition
3031    
3032     ClsDef:
3033     @ClsQName: ManakaiDISResourceDefinition
3034     @enDesc:
3035     <QUOTE::dis> resource definitions.
3036     @ClsISA: ManakaiDISPropertyAccessor
3037 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3038 wakaba 1.2
3039     @Attr:
3040     @@Name: uri
3041     @@Type: ResourceURI
3042     @@Description:
3043     @@@lang:en
3044     @@@@:
3045     The URI reference of this <QUOTE::dis> resource.
3046     @@Get:
3047     @@@PerlDef:
3048     $r = $self->{uri};
3049    
3050     @Attr:
3051     @@Name: nameURI
3052     @@Type: NameURI
3053     @@enDesc:
3054     The URI reference of this <QUOTE::dis> resource, without
3055     <QUOTE::for> identifier.
3056     @@Get:
3057     @@@nullCase:
3058     @@@@enDesc:
3059     This resource does not have its name URI reference.
3060 wakaba 1.3 @@@PerlDef:
3061 wakaba 1.4 $r = $self->{nameURI};
3062 wakaba 1.2
3063     @Attr:
3064     @@Name: localName
3065     @@enDesc:
3066     The local name of this resource.
3067     @@Type:
3068 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3069 wakaba 1.2 @@Get:
3070     @@@nullCase:
3071     @@@@enDesc:
3072     This resource does not have its local name.
3073     @@@PerlDef:
3074     $r = $self->{localName};
3075    
3076     @Attr:
3077     @@Name: namespaceURI
3078     @@Type: AnyURI
3079     @@enDesc:
3080     The namespace URI of the name of this resource.
3081     @@Get:
3082     @@@nullCase:
3083     The name of this resource does not have its namespace
3084     or this resource does not have its name.
3085     @@@PerlDef:
3086     $r = $self->{namespaceURI};
3087    
3088     @Attr:
3089     @@Name: isAnonymous
3090     @@enDesc:
3091     Whether this <QUOTE::dis> resource has name or not.
3092     @@Type:
3093     DOMMain:boolean
3094     @@Get:
3095     @@@TrueCase:
3096     This resource does not have any global unique name.
3097     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
3098     @@@FalseCase:
3099     This resource does have its formal name.
3100     <A::ManakaiDISResourceDefinition.uri> is a URI reference
3101     generated from the name and the <QUOTE::for> URI reference
3102     of this resource.
3103     @@@PerlDef:
3104     $r = $self->{<Q::isAnon>};
3105    
3106     @Attr:
3107     @@Name: forURI
3108     @@enDesc:
3109     The <QUOTE::for> URI reference for which this resource is defined.
3110     @@Type:ForURI
3111     @@Get:
3112     @@@PerlDef:
3113     $r = $self->{for};
3114    
3115     @Attr:
3116     @@Name: forpURI
3117     @@enDesc:
3118     The <QUOTE::for+> URI references for which this resource is defined.
3119     @@Type: ForURIList
3120     @@Get:
3121 wakaba 1.3 @@@PerlDef:
3122 wakaba 1.2 $r = $self->{forp};
3123    
3124     @Method:
3125 wakaba 1.7 @@Name: isSubsetOfURI
3126 wakaba 1.2 @@Description:
3127     @@@lang:en
3128     @@@@:
3129     Whether this resource is a subset of another resource or not.
3130     @@Param:
3131     @@@Name: superURI
3132     @@@Type: ResourceURI
3133     @@@Description:
3134     @@@@lang:en
3135     @@@@@:
3136     Another resource URI reference to test.
3137     @@Return:
3138     @@@Type:
3139     DOMMain:boolean
3140     @@@TrueCase:
3141     @@@@enDesc:
3142     <P::superURI> is a super-resource of this resource.
3143     @@@FalseCase:
3144     @@@@enDesc:
3145     <P::superURI> is not a super-resource of this resource.
3146     @@@PerlDef:
3147 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
3148 wakaba 1.2
3149 wakaba 1.7 @Method:
3150     @@Name: addSuperResource
3151     @@enDesc:
3152     Adds a <QUOTE::dis> resource to the list of super-resource
3153     of this <QUOTE::dis> resource.
3154     @@Param:
3155     @@@Name: superRes
3156     @@@Type: ManakaiDISResourceDefinition
3157     @@@enDesc:
3158     A <QUOTE::dis> resource definition object.
3159     @@Return:
3160     @@@PerlDef:
3161     my @from = ($self->{uri},
3162     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
3163     my @to = ($superRes->{uri},
3164     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
3165     __DEEP{
3166     for my $from (@from) {
3167     for my $to (@to) {
3168     $self->{db}-><M::ManakaiDISDatabase.getResource>
3169     ($from)->{subOf}->{$to} = true;
3170     $self->{db}-><M::ManakaiDISDatabase.getResource>
3171     ($to)->{supOf}->{$from} = true;
3172     }
3173     }
3174     }__;
3175    
3176 wakaba 1.2 @Attr:
3177     @@Name: isDefined
3178     @@Description:
3179     @@@lang:en
3180     @@@@:
3181     Whether this resource is already defined or not.
3182     @@Type:
3183     DOMMain:boolean
3184     @@Get:
3185     @@@TrueCase:
3186     This resource is already defined.
3187     @@@FalseCase:
3188     This resource is not defined.
3189     @@@PerlDef:
3190     $r = $self->{<Q::isDefined>};
3191    
3192     @Attr:
3193     @@Name: isReferred
3194     @@Description:
3195     @@@lang:en
3196     @@@@:
3197     Whether this resource is referred or not.
3198 wakaba 1.7 @@Type: ManakaiDISElement
3199 wakaba 1.2 @@Get:
3200 wakaba 1.7 @@@enDesc:
3201 wakaba 1.9 An element that referres this resource.
3202 wakaba 1.2 @@@nullCase:
3203     This resource is not referred.
3204     @@@PerlDef:
3205     $r = $self->{<Q::isReferred>};
3206     @@Set:
3207 wakaba 1.7 @@@enDesc:
3208 wakaba 1.9 An element that referres this resource.
3209 wakaba 1.2 @@@PerlDef:
3210 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3211 wakaba 1.2
3212     @Attr:
3213     @@Name: definingModule
3214     @@Description:
3215     @@@lang:en
3216     @@@@:
3217     The <QUOTE::dis> module in which this resource is defined.
3218 wakaba 1.8 \
3219     {NOTE:: Method name should have been <CODE::ownerModule> or some.
3220     \
3221     }
3222 wakaba 1.2 @@Type: ManakaiDISModuleDefinition
3223     @@Get:
3224     @@@Description:
3225     @@@@lang:en
3226     @@@@@:
3227     The module object.
3228 wakaba 1.3 @@@nullCase:
3229 wakaba 1.2 @@@@Description:
3230     @@@@@lang:en
3231     @@@@@@:
3232     This resource is not associated to any module.
3233     @@@PerlDef:
3234     $r = $self->{db}
3235     -><M::ManakaiDISDatabase.getModule>
3236     ($self->{<Q::definingModule>})
3237     if defined $self->{<Q::definingModule>};
3238     @@Set:
3239     @@@Description:
3240     @@@@lang:en
3241     @@@@@:
3242     The module object to which the <QUOTE::defining module> is set.
3243     @@@PerlDef:
3244     $self->{<Q::defininingModule>}
3245     = $given-><AG::ManakaiDISModuleDefinition.uri>;
3246    
3247 wakaba 1.6 @Method:
3248     @@Name: mergeAsAlias
3249     @@enDesc:
3250     Merges another resource definition as an alias of this resource.
3251     @@Param:
3252     @@@Name: aliasResource
3253     @@@Type: ManakaiDISResourceDefinition
3254     @@@enDesc:
3255     A resource to merge.
3256     \
3257     {NOTE:: After merging all references to <P::aliasResource>
3258     should be discarded.
3259     \
3260     }
3261     @@Return:
3262     @@@PerlDef:
3263     for my $uri ($aliasResource->{uri},
3264     grep {$aliasResource->{aliasURI}->{$_}}
3265     keys %{$aliasResource->{aliasURI}}) {
3266     $self->{aliasURI}->{$uri} = true;
3267     $self->{db}->{resDef}->{$uri} = $self;
3268     $self->{subOf}->{$uri} = true;
3269     $self->{supOf}->{$uri} = true;
3270     }
3271     for my $uri (grep {$aliasResource->{subOf}->{$_}}
3272     keys %{$aliasResource->{subOf}}) {
3273     $self->{subOf}->{$uri} = true;
3274     }
3275     for my $uri (grep {$aliasResource->{supOf}->{$_}}
3276     keys %{$aliasResource->{supOf}}) {
3277     $self->{supOf}->{$uri} = true;
3278     }
3279     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
3280     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
3281     __DEEP{
3282     for my $from (@from) {
3283     for my $to (@to) {
3284     $self->{db}-><M::ManakaiDISDatabase.getResource>
3285     ($from)->{subOf}->{$to} = true;
3286     $self->{db}-><M::ManakaiDISDatabase.getResource>
3287     ($to)->{supOf}->{$from} = true;
3288     }
3289     }
3290     }__;
3291 wakaba 1.7
3292     @Method:
3293     @@Name: isTypeURI
3294     @@enDesc:
3295     Tests whether this resource is of a type or not.
3296     @@Param:
3297     @@@Name: typeURI
3298     @@@Type: ResourceURI
3299     @@@enDesc:
3300     A type URI reference to test.
3301     @@Return:
3302     @@@Type:
3303     DOMMain:boolean
3304     @@@TrueCase:
3305     @@@@enDesc:
3306     This is a <P::typeURI> resource.
3307     @@@FalseCase:
3308     @@@@enDesc:
3309     This is not a <P::typeURI> resource.
3310     @@@PerlDef:
3311 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
3312     $r = $self->{<Q::rdf:type>}->{$typeURI};
3313     } else {
3314     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
3315     keys %{$self->{<Q::rdf:type>}}) {
3316     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
3317     ($t_type_uri);
3318     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3319     ($typeURI)) {
3320     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
3321     last;
3322     }
3323 wakaba 1.7 }
3324     }
3325 wakaba 1.8
3326     @Attr:
3327     @@Name: plName
3328     @@enDesc:
3329     The Perl name of this resource.
3330     @@Get:
3331     @@@Type:
3332     DISLang:String
3333     @@@enDesc:
3334     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
3335     \
3336     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
3337     <CHAR::COLON> prefix).
3338     \
3339     - <Q::DISLang:Attribute>::: Method name.
3340     \
3341     - <Q::DISLang:Method>::: Method name.
3342     @@@nullCase:
3343     @@@@enDesc:
3344     Either the type of this resource is not listed above
3345     or this Perl constructure is anonymous.
3346     @@@RaiseException:
3347     @@@@@: NO_LOCAL_NAME_ERR
3348     @@@@enDesc:
3349     The type of this resource is either
3350     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
3351     the local name of this resource is not defined.
3352     @@@RaiseException:
3353     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
3354     @@@@enDesc:
3355     The Perl method name constructed from the source
3356     result in a reserved name.
3357     @@@PerlDef:
3358     __DEEP{
3359     if (exists $self->{<Q::dis2pm:name>}) {
3360     $r = $self->{<Q::dis2pm:name>};
3361     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3362     (<Q::ManakaiDOM:Const>) or
3363     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3364     (<Q::ManakaiDOM:ConstGroup>)) {
3365     $r = $self->{localName};
3366     unless (defined $r) {
3367     __UNDEEP{
3368     __EXCEPTION{NO_LOCAL_NAME_ERR::
3369     DIS:sourceNode => {$self->{src}},
3370     }__;
3371     }__;
3372     }
3373     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3374     (<Q::DISLang:Method>) or
3375     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3376     (<Q::DISLang:Attribute>)) {
3377     if (defined $self->{localName}) {
3378     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
3379     ($self->{localName});
3380     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
3381     (<Q::ManakaiDOM:isForInternal>, false)) {
3382     $r = '_' . $r;
3383     }
3384     if ({
3385     import => 1,
3386     unimport => 1,
3387     isa => 1,
3388     can => 1,
3389     new => 1,
3390     as_string => 1,
3391     stringify => 1,
3392     clone => 1,
3393     }->{$r} or $r =~ /^___/) {
3394     __UNDEEP{
3395     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
3396     DIS:uri => {$self->{uri}},
3397     DIS:soruceNode => {$self->{src}},
3398     DIS:generatedName => {$r},
3399     }__;
3400     }__;
3401     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
3402     .plMethodOperator>) {
3403     $r = {
3404     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
3405     <Q::DISPerl:AsStringMethod> => 'as_string',
3406     <Q::DISPerl:AsNewMethod> => 'new',
3407     <Q::DISPerl:AsCloneMethod> => 'clone',
3408     }->{$op_uri};
3409     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
3410     }
3411     } else {
3412     $r = null;
3413     }
3414     } else {
3415     $r = null;
3416     }
3417     $self->{<Q::dis2pm:name>} = $r;
3418     }__;
3419    
3420     @Attr:
3421     @@Name: plFullyQualifiedName
3422     @@enDesc:
3423     The fully-qualified Perl name of this resource.
3424     @@Type:
3425     DISLang:String::ManakaiDOM:all
3426     @@Get:
3427     @@@enDesc:
3428     Fully-qualified name.
3429     \
3430     - <Q::ManakaiDOM:Class>::: Class package name.
3431     \
3432     - <Q::ManakaiDOM:IF>::: Interface package name.
3433     \
3434     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
3435     type symbol such as <CODE::$>).
3436     @@@nullCase:
3437     @@@@enDesc:
3438     Otherwise.
3439     @@@NoPerlModuleNameException:
3440     @@@RaiseException:
3441     @@@@@: NO_LOCAL_NAME_ERR
3442     @@@@enDesc:
3443     The local name of this resource is not defined.
3444     @@@PerlDef:
3445     __DEEP{
3446     if (exists $self->{<Q::dis2pm:name>}) {
3447     $r = $self->{<Q::dis2pm:name>};
3448     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3449     (<Q::ManakaiDOM:Class>) or
3450     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3451     (<Q::ManakaiDOM:IF>) or
3452     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3453     (<Q::DISPerl:ScalarVariable>)) {
3454     my $an_node = $self->{src}-><AG::ManakaiDISElement.disGetAttribute>
3455     (<Q::dis:AppName>, for_arg => $self->{for},
3456     forp_arg => $self->{forp},
3457     media_type => <Q::lang:Perl>);
3458     if ($an_node) {
3459     ## NOTE: "lang:Perl" is fully-qualified name by definition
3460     $r = $an_node-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3461     } else {
3462 wakaba 1.10 unless (defined $self->{localName}) {
3463     __UNDEEP{
3464     __EXCEPTION{NO_LOCAL_NAME_ERR::
3465     DIS:sourceNode => {$self->{src}},
3466     }__;
3467     }__;
3468     }
3469 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3470     (<Q::ManakaiDOM:IF>)) {
3471     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3472     -><M::ManakaiDISModuleDefinition.plInterfaceName>
3473     . '::' . $self->{localName};
3474     } else {
3475     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3476     -><M::ManakaiDISModuleDefinition.plFullyQualifiedName>
3477     . '::' . $self->{localName};
3478     }
3479     }
3480     } else {
3481     $r = null;
3482     }
3483     $self->{<Q::dis2pm:name>} = $r;
3484     }__;
3485    
3486     @Attr:
3487     @@Name: plMethodOperator
3488     @@enDesc:
3489     The operator to overload by this method.
3490     @@Type:
3491     DISLang:String::ManakaiDOM:all
3492     @@Get:
3493     @@@enDesc:
3494     The operator, either Perl <CODE::use operator> operator name
3495     of manakai operator URI reference.
3496     @@@nullCase:
3497     @@@@enDesc:
3498     Either this resource does not define a Perl method or
3499     this method does not overload any operator.
3500     @@@UndeclaredPrefixException:
3501     @@@RaiseException:
3502     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
3503     @@@@enDesc:
3504     Media type of the <Q::dis:Operator> node is not supported.
3505     @@@PerlDef:
3506     __DEEP{
3507     if (exists $self->{<Q::dis:Operator>}) {
3508     $r = $self->{<Q::dis:Operator>};
3509     } else {
3510     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3511     (<Q::dis:Operator>, for_arg => $self->{for},
3512     forp_arg => $self->{forp});
3513     if ($op_node) {
3514     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3515     (<Q::lang:Perl>)) {
3516     $r = $op_node-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3517     } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3518     (<Q::dis:TypeQName>)) {
3519     $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
3520     } else {
3521 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
3522     (for_arg => $self->{for},
3523     forp_arg => $self->{forp});
3524 wakaba 1.8 __UNDEEP{
3525     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3526     DIS:uri => {$ct_uri},
3527 wakaba 1.10 DIS:sourceNode => {$op_node},
3528 wakaba 1.8 }__;
3529     }__;
3530     }
3531     } else {
3532     $r = null;
3533     }
3534     $self->{<Q::dis:Operator>} = $r;
3535     }
3536     }__;
3537    
3538     @Attr:
3539     @@Name: disDataTypeResource
3540     @@enDesc:
3541     <Q::dis:Type> attribute value of this resource.
3542     @@Type: ManakaiDISResourceDefinition
3543     @@Get:
3544     @@@RaiseException:
3545     @@@@@:NO_DIS_TYPE_ERR
3546     @@@@enDesc:
3547     <Q::dis:Type> attribute is not specified.
3548     @@@PerlDef:
3549     __DEEP{
3550     if (defined $self->{<Q::dis:Type>}) {
3551     $r = $self->{<Q::dis:Type>};
3552     } else {
3553     $self->{<Q::dis2pm:TypeNode>}
3554     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3555     (<Q::dis:Type>, for_arg => $self->{for},
3556     forp_arg => $self->{forp});
3557     if ($self->{<Q::dis2pm:TypeNode>}) {
3558     $r = $self->{<Q::dis:Type>}
3559     = $self->{<Q::dis2pm:TypeNode>}
3560     -><AG::ManakaiDISElement.qnameValueURI>;
3561     } else {
3562     my $pr = $self-><M::ManakaiDISPropertyAccessor
3563     .getPropertyResource>
3564     (<Q::DIS:dynamicParentResource>);
3565     if ($pr) {
3566     $r = $pr-><AG::ManakaiDISResourceDefinition
3567     .disDataTypeResource>;
3568     $self->{<Q::dis2pm:TypeNode>}
3569     = $pr->{<Q::dis2pm:TypeNode>};
3570     } else { ## No parent
3571     __UNDEEP{
3572     __EXCEPTION{NO_DIS_TYPE_ERR::
3573     DIS:sourceNode => {$self->{src}},
3574     }__;
3575     }__;
3576     }
3577     }
3578     }
3579     }__;
3580    
3581     @Attr:
3582     @@Name: disDataTypeNode
3583     @@enDesc:
3584     <Q::dis:Type> node for this resource.
3585     @@Get:
3586     @@@Type: ManakaiDISElement
3587     @@@RaiseException:
3588     @@@@@:NO_DIS_TYPE_ERR
3589     @@@@enDesc:
3590     <Q::dis:Type> attribute is not specified.
3591     @@@PerlDef:
3592     __DEEP{
3593     $self-><AG::ManakaiDISResourceDefinition.disDataTypeNode>;
3594     }__;
3595     $r = $self->{<Q::dis2pm:TypeNode>};
3596    
3597     @Attr:
3598     @@Name: disActualDataTypeResource
3599     @@enDesc:
3600     <Q::dis:actualType> attribute value of this resource.
3601     @@Type: ManakaiDISResourceDefinition
3602     @@Get:
3603     @@@RaiseException:
3604     @@@@@:NO_DIS_TYPE_ERR
3605     @@@@enDesc:
3606     <Q::dis:actualType> attribute is not specified,
3607     and <Q::dis:Type> attribute, neigher.
3608     @@@PerlDef:
3609     __DEEP{
3610     if (defined $self->{<Q::dis:actualType>}) {
3611     $r = $self->{<Q::dis:actualType>};
3612     } else {
3613     $self->{<Q::dis2pm:actualTypeNode>}
3614     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3615     (<Q::dis:actualType>, for_arg => $self->{for},
3616     forp_arg => $self->{forp});
3617     if ($self->{<Q::dis2pm:actualTypeNode>}) {
3618     $r = $self->{<Q::dis:actualType>}
3619     = $self->{<Q::dis2pm:actualTypeNode>}
3620     -><AG::ManakaiDISElement.qnameValueURI>;
3621     } elsif (defined $self->{<Q::dis:Type>}) {
3622     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
3623     $self->{<Q::dis2pm:actualTypeNode>}
3624     = $self->{<Q::dis2pm:TypeNode>};
3625     } else {
3626     $self->{<Q::dis2pm:actualTypeNode>}
3627     = $self->{<Q::dis2pm:TypeNode>}
3628     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3629     (<Q::dis:Type>, for_arg => $self->{for},
3630     forp_arg => $self->{forp});
3631     if ($self->{<Q::dis2pm:TypeNode>}) {
3632     $r = $self->{<Q::dis:actualType>}
3633     = $self->{<Q::dis:Type>}
3634     = $self->{<Q::dis2pm:TypeNode>}
3635     -><AG::ManakaiDISElement.qnameValueURI>;
3636     } else {
3637     my $pr = $self-><M::ManakaiDISPropertyAccessor
3638     .getPropertyResource>
3639     (<Q::DIS:dynamicParentResource>);
3640     if ($pr) {
3641     $r = $self->{<Q::dis:actualType>}
3642     = $pr-><AG::ManakaiDISResourceDefinition
3643     .disActualDataTypeResource>;
3644     $self->{<Q::dis2pm:actualTypeNode>}
3645     = $pr->{<Q::dis2pm:actualTypeNode>};
3646     } else { ## No parent
3647     __UNDEEP{
3648     __EXCEPTION{NO_DIS_TYPE_ERR::
3649     DIS:sourceNode => {$self->{src}},
3650     }__;
3651     }__;
3652     }
3653     }
3654     }
3655     }
3656     }__;
3657    
3658     @Attr:
3659     @@Name: disActualDataTypeNode
3660     @@enDesc:
3661     <Q::dis:actualType> node for this resource.
3662     @@Get:
3663     @@@Type: ManakaiDISElement
3664     @@@RaiseException:
3665     @@@@@:NO_DIS_TYPE_ERR
3666     @@@@enDesc:
3667     <Q::dis:actualType> attribute is not specified,
3668     and <Q::dis:Type> attribute, neigher.
3669     @@@PerlDef:
3670     __DEEP{
3671     $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeNode>;
3672     }__;
3673     $r = $self->{<Q::dis2pm:actualTypeNode>};
3674 wakaba 1.9
3675     @IntMethod:
3676     @@Operator:
3677     @@@@: <=>
3678     @@@ContentType:
3679     lang:Perl
3680     @@enDesc:
3681     Which is greater (i.e. the spaceship operator).
3682     A resource is less than another if it is loaded by
3683     <M::ManakaiDISDatabase.loadResource> before another is loaded.
3684     Order for non-loaded resource definitions are not defined.
3685     \
3686     {NOTE:: In the current implementation, non-loaded resources
3687     are less than any loaded resource and the order in
3688     non-loaded resources is unknown.
3689     \
3690     }
3691     @@Param:
3692     @@@Name: anotherResource
3693     @@@Type: ManakaiDISResourceDefinition
3694     @@@enDesc: Another resource to compare.
3695     @@Return:
3696     @@@Type:
3697     DOMMain:unsigned-long
3698     @@@PerlDef:
3699     if (UNIVERSAL::isa ($anotherResource,
3700     <ClassName::ManakaiDISResourceDefinition>)) {
3701     $r = $self->{seq} <=> $anotherResource->{seq};
3702     } else {
3703     $r = overload::Overloaded ($self) <=> $anotherResource;
3704     }
3705 wakaba 1.2 ##DISResourceDefinition
3706    
3707 wakaba 1.8 XParamDef:
3708     @QName: generatedName
3709     @enDesc:
3710     A generated name.
3711    
3712 wakaba 1.2 ClsDef:
3713     @ClsQName: ManakaiDISPropertyAccessor
3714 wakaba 1.3 @enDesc:
3715 wakaba 1.2 Accessor methods for resource or module properties.
3716    
3717     @Method:
3718 wakaba 1.8 @@Name: getPropertyBoolean
3719     @@enDesc:
3720     Gets boolean property value.
3721     @@PropNameParam:
3722     @@Param:
3723     @@@Name:default
3724     @@@Type:
3725     DOMMain:boolean::ManakaiDOM:all
3726     @@@enDesc:
3727     The default value that is returned if no explicit property
3728     value specification found for this resource.
3729     @@Return:
3730     @@@Type:
3731     DOMMain:boolean::ManakaiDOM:all
3732     @@@enDesc:
3733     The property value.
3734     @@@PerlDef:
3735     if (exists $self->{$propName}) {
3736     $r = defined $self->{$propName} ? $self->{$propName} : $default;
3737     } elsif ($self->{src}) {
3738     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3739     ($propName, for_arg => $self->{for},
3740     forp_arg => $self->{forp});
3741     $self->{$propName} = $r;
3742     $r = $default unless defined $r;
3743     } else {
3744     $r = $default;
3745     }
3746    
3747     @Method:
3748 wakaba 1.2 @@Name: getPropertyText
3749     @@enDesc:
3750     Gets property value text.
3751     @@PropNameParam:
3752     @@Param:
3753     @@@Name:default
3754     @@@Type:
3755 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
3756 wakaba 1.2 @@@enDesc:
3757     The default value that is returned if no explicit property
3758     value specification found for this resource.
3759     @@@nullCase:
3760     @@@@enDesc:
3761     No default value supplied; <DOM::null> is returned if
3762     no value specified.
3763     @@Return:
3764     @@@Type:
3765 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
3766 wakaba 1.2 @@@enDesc:
3767     The property value string.
3768     @@@nullCase:
3769     @@@@enDesc:
3770     No value nor default value has specified.
3771     @@@PerlDef:
3772     if (exists $self->{$propName}) {
3773     $r = defined $self->{$propName} ? $self->{$propName} : $default;
3774     } elsif ($self->{src}) {
3775     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3776     ($propName, for_arg => $self->{for},
3777     forp_arg => $self->{forp});
3778 wakaba 1.8 if ($r) {
3779     $r = $self->{$propName}
3780     = $r-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3781     $r = $default unless defined $r;
3782     } else {
3783     $r = $default;
3784     $self->{$propName} = null;
3785     }
3786 wakaba 1.2 } else {
3787     $r = $default;
3788     }
3789    
3790     @Method:
3791     @@Name: getPropertyResource
3792     @@enDesc:
3793     Gets property value resource.
3794     @@PropNameParam:
3795 wakaba 1.10 @@NamedParam:
3796     @@@Name: defaultMediaType
3797     @@@Type: ResourceURI
3798     @@@enDesc:
3799     The URI reference of the default media type which is used
3800     when the property value is retrieved from the source tree
3801     and the source tree element does not have its <Q::dis:ContentType>
3802     attribute specified.
3803     @@@nullCase:
3804     @@@@enDesc:
3805     Defaulted to <Q::dis:TypeQName>.
3806 wakaba 1.2 @@Return:
3807     @@@Type: ManakaiDISResourceDefinition
3808     @@@enDesc:
3809     The property value resource.
3810     @@@nullCase:
3811     @@@@enDesc:
3812     No value has specified.
3813 wakaba 1.8 @@@UndeclaredPrefixException:
3814 wakaba 1.2 @@@PerlDef:
3815     if (defined $self->{$propName}) {
3816 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
3817     ($self->{$propName});
3818 wakaba 1.8 } elsif ($self->{src}) {
3819     __DEEP{
3820     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3821     ($propName, for_arg => $self->{for},
3822     forp_arg => $self->{forp});
3823     if ($r) {
3824 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
3825     unless defined $defaultMediaType;
3826     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
3827     (<Q::dis:TypeQName>, $defaultMediaType)) {
3828     $self->{$propName}
3829     = $r-><AG::ManakaiDISElement.qnameValueURI>;
3830     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
3831     (<Q::dis:TFQNames>, $defaultMediaType)) {
3832     $self->{$propName}
3833     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
3834     ($self->{src}-><AG::swcfg21:SWCFGNode
3835     ::swcfg21:ForLatest.nodeID>,
3836     $self->{for});
3837     } else {
3838     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
3839     (for_arg => $self->{for},
3840     forp_arg => $self->{forp});
3841     __UNDEEP{
3842     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3843     DIS:uri => {$mt},
3844     DIS:sourceNode => {$r},
3845     }__;
3846     }__;
3847     }
3848 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
3849     ($self->{$propName});
3850     $r-><M::ManakaiDISResourceDefinition.isReferred> ($self->{src});
3851 wakaba 1.8 }
3852     }__;
3853 wakaba 1.2 }
3854    
3855     @Method:
3856 wakaba 1.10 @@Name: getPropertyResourceList
3857     @@enDesc:
3858     Gets property value resource list.
3859     @@PropNameParam:
3860     @@NamedParam:
3861     @@@Name: recursiveISA
3862     @@@Type:
3863     DOMMain:boolean
3864     @@@enDesc:
3865     Whether property resource values of <Q::dis:ISA> resources
3866     of this resource should also be included to the returned list or not.
3867     @@NamedParam:
3868     @@@Name: defaultMediaType
3869     @@@Type: ResourceURI
3870     @@@enDesc:
3871     The URI reference of the default media type which is used
3872     when the property value is retrieved from the source tree
3873     and the source tree element does not have its <Q::dis:ContentType>
3874     attribute specified.
3875     @@@nullCase:
3876     @@@@enDesc:
3877     Defaulted to <Q::dis:TypeQName>.
3878     @@Return:
3879     @@@Type: ResourceList
3880     @@@enDesc:
3881     An array reference of the property value resources.
3882     \
3883     {NOTE:: This list is <QUOTE::dead>.
3884     \
3885     }
3886     @@@UndeclaredPrefixException:
3887     @@@PerlDef:
3888     $r = [];
3889     if (defined $self->{$propName}) {
3890     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
3891     ? $self->{$propName} : []}) {
3892     push @$r,
3893     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
3894     }
3895     } elsif ($self->{src}) {
3896     __DEEP{
3897     $self->{$propName} = [];
3898     $defaultMediaType = <Q::dis:TypeQName>
3899     unless defined $defaultMediaType;
3900     for my $res_name_node
3901     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
3902     ($propName, for_arg => $self->{for},
3903     forp_arg => $self->{forp})}) {
3904     my $res_uri;
3905     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
3906     (<Q::dis:TypeQName>, $defaultMediaType)) {
3907     $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
3908     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
3909     (<Q::dis:TFQNames>, $defaultMediaType)) {
3910     $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
3911     ($self->{src}-><AG::swcfg21:SWCFGNode
3912     ::swcfg21:ForLatest.nodeID>,
3913     $self->{for});
3914     } else {
3915     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
3916     (for_arg => $self->{for},
3917     forp_arg => $self->{forp});
3918     __UNDEEP{
3919     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3920     DIS:uri => {$mt},
3921     DIS:sourceNode => {$res_name_node},
3922     }__;
3923     }__;
3924     }
3925     push @{$self->{$propName}}, $res_uri;
3926     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
3927     ($res_uri);
3928     push @$r, $res;
3929     $res-><M::ManakaiDISResourceDefinition.isReferred>
3930     ($res_name_node);
3931     }
3932     }__;
3933     }
3934     if ($recursiveISA) {
3935     __DEEP{
3936     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
3937     my @p_res = @$r;
3938     for my $p_res (@p_res) {
3939     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
3940     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
3941     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
3942     .getPropertyResourceList>
3943     (<Q::dis:ISA>, recursive_isa => true,
3944     ___recursive_isa_done => $opt{___recursive_isa_done},
3945     default_media_type => $defaultMediaType)};
3946     }
3947     }__;
3948     }
3949    
3950     @Method:
3951 wakaba 1.2 @@Name: addPropertyResourceList
3952     @@enDesc:
3953     Adds a resource to a resource-list property value.
3954     \
3955     {ISSUE:: Should an exception be thrown if the property is
3956     not of list?
3957     \
3958     }
3959 wakaba 1.10 \
3960     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
3961     an item clears the list --- i.e. the property values
3962     in the source tree will be ignored. Call
3963     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
3964     before adding to avoid this behavior.
3965     \
3966     }
3967 wakaba 1.2 @@PropNameParam:
3968     @@Param:
3969     @@@Name: res
3970     @@@Type: ManakaiDISResourceDefinition
3971     @@@enDesc:
3972     A resource to add.
3973     @@Return:
3974     @@@PerlDef:
3975     if (ref $self->{$propName} eq 'ARRAY') {
3976     push @{$self->{$propName}}, $res->{uri};
3977     } elsif (not defined $self->{$propName}) {
3978     $self->{$propName} = [$res->{uri}];
3979     }
3980    
3981 wakaba 1.3 ElementTypeBinding:
3982     @Name: PropNameParam
3983     @ElementType:
3984     dis:ResourceDef
3985     @ShadowContent:
3986     @@rdf:type:
3987     DISLang:MethodParameter
3988     @@Name: propName
3989     @@Type: ResourceURI
3990     @@Description:
3991     @@@lang:en
3992     @@@@:
3993     The name of the property.
3994    
3995 wakaba 1.2 ##DISPropertyAccessor
3996    
3997     PropDef:
3998     @QName:isAnon
3999     @Description:
4000     @@lang:en
4001     @@@:
4002     Whether the subject resource is anonymous or not.
4003     @Type:
4004     DOMMain:boolean
4005    
4006     PropDef:
4007     @QName:isDefined
4008     @Description:
4009     @@lang:en
4010     @@@:
4011     Whether the subject resource is defined or not.
4012    
4013     PropDef:
4014 wakaba 1.3 @QName:isReferred
4015 wakaba 1.2 @Description:
4016     @@lang:en
4017     @@@:
4018     Whether the subject resource is referred or not.
4019     @Type:
4020     DOMMain:any
4021    
4022     PropDef:
4023     @QName:definingModule
4024     @Description:
4025     @@lang:en
4026     @@@:
4027     The <QUOTE::dis> module in which the subject resource is defined.
4028     @rdfs:domain:
4029     DISCore:Module
4030 wakaba 1.1
4031     ## -- Datatypes
4032    
4033     URITypeDef:
4034 wakaba 1.3 @QName: AnyURI
4035     @Description:
4036     @@lang:en
4037     @@@:
4038     Any URI references.
4039    
4040     URITypeDef:
4041     @QName: FileURI
4042     @enDesc:
4043     URI references identifying file.
4044    
4045     URITypeDef:
4046 wakaba 1.1 @QName: ForURI
4047     @Description:
4048     @@lang:en
4049     @@@:
4050     <QUOTE::For> URI references.
4051    
4052     DataTypeDef:
4053     @QName: ForURIList
4054     @Description:
4055     @@lang:en
4056     @@@:
4057     References to the array containing <QUOTE::for> URI references.
4058    
4059     URITypeDef:
4060 wakaba 1.3 @QName: ResourceURI
4061     @Description:
4062     @@lang:en
4063     @@@:
4064     A URI reference for a <QUOTE::dis> resource.
4065    
4066     URITypeDef:
4067 wakaba 1.1 @QName: MediaTypeURI
4068     @Description:
4069     @@lang:en
4070     @@@:
4071     Media type URI references.
4072 wakaba 1.3 @rdfs:subClassOf: ResourceURI
4073    
4074     URITypeDef:
4075     @QName: ModuleURI
4076     @enDesc:
4077     URI references for <QUOET::dis> modules.
4078     @rdfs:subClassOf: ResourceURI
4079    
4080     URITypeDef:
4081     @QName: NameURI
4082     @enDesc:
4083     URI references identifying a resource.
4084     @rdfs:subClassOf: ResourceURI
4085 wakaba 1.10
4086     DataTypeDef:
4087     @QName: ResourceList
4088     @enDesc:
4089     References to array containing resource definition objects.
4090     @rdfs:subClassOf:
4091     Perl:ARRAY::ManakaiDOM:all
4092 wakaba 1.3
4093     ElementTypeBinding:
4094     @Name: DataTypeDef
4095     @ElementType:
4096     dis:ResourceDef
4097     @ShadowContent:
4098     @@rdf:type:
4099     ManakaiDOM:DataType
4100    
4101     ElementTypeBinding:
4102     @Name: URITypeDef
4103     @ElementType:
4104     dis:ResourceDef
4105     @ShadowContent:
4106     @@rdf:type:
4107     ManakaiDOM:DataType
4108     @@rdfs:subClassOf: AnyURI
4109 wakaba 1.1
4110     ## -- Exceptions
4111    
4112     XParamDef:
4113     @QName: sourceNode
4114     @Description:
4115     @@lang:en
4116     @@@:
4117 wakaba 1.4 The node in which an error has occurred.
4118 wakaba 1.5 @Type: ManakaiDISNode
4119    
4120     XParamDef:
4121     @QName: anotherSourceNode
4122     @enDesc:
4123     Another source node in which an error has occurred. In cases
4124     of <QUOTE::already defined> errors, it is the node that
4125     defines the resource first.
4126     @Type: ManakaiDISNode
4127 wakaba 1.3
4128     ExceptionDef:
4129     @ClsQName: ManakaiDISException
4130     @enDesc:
4131     Exceptions for the <QUOTE::dis> operations.
4132 wakaba 1.4 @ClsISA:
4133     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
4134 wakaba 1.3 @XConstGroupDef:
4135     @@ClsQName: ManakaiDISExceptionCode
4136     @@enDesc:
4137     Exception codes for <Class::ManakaiDISException>.
4138     @@XConstDef:
4139 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
4140     @@@Value:9
4141     @@@enDesc:
4142     An attempt is made to do something the implementation does not support.
4143     @@@XSubTypeDef:
4144     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
4145     @@@@enDesc:
4146     The implementation does not support the media type.
4147     @@@@XParam:
4148     @@@@@QName: uri
4149     @@@@@enDesc:
4150     The URI reference of the media type that is not supported.
4151     @@@@XSourceNodeParam:
4152     @@XConstDef:
4153 wakaba 1.3 @@@Name: NAMESPACE_ERR
4154     @@@Value:14
4155     @@@enDesc:
4156     An error related to namespaces has occurred.
4157     @@@XSubTypeDef:
4158     @@@@QName: UNDECLARED_NS_PREFIX_ERR
4159     @@@@enDesc:
4160     The implementation has encounted an undeclared namespace
4161     prefix.
4162 wakaba 1.7 @@@@XParam:
4163     @@@@@QName:
4164     infoset:prefix
4165     @@@@@enDesc:
4166     The namespace prefix.
4167     @@@@enMufDef:
4168     Namespace prefix "%p (name => {<Q::infoset:prefix>});" is
4169     not declared
4170 wakaba 1.3 @@XConstDef:
4171     @@@Name: INVALID_STATE_ERR
4172     @@@Value:11
4173     @@@enDesc:
4174     An attempt is made to use an object that is not (or no longer) usable.
4175     @@@XSubTypeDef:
4176     @@@@QName: NO_ASSOCIATED_DB_ERR
4177     @@@@enDesc:
4178     No <QUOTE::dis> database has been associated with this document.
4179 wakaba 1.4 @@XConstDef:
4180     @@@Name: INVALID_SOURCE_ERR
4181     @@@Value: 200
4182     @@@enDesc:
4183     The source input is well-formed but invalid.
4184     @@@XSubTypeDef:
4185     @@@@QName: NO_MODULE_QNAME_ERR
4186     @@@@enDesc:
4187     The <Q::dis:Module> element must have its <Q::dis:QName>
4188     attribute.
4189 wakaba 1.8 @@@@XSourceNodeParam:
4190     @@@XSubTypeDef:
4191     @@@@QName: NO_LOCAL_NAME_ERR
4192     @@@@enDesc:
4193     The resource does not have a local name.
4194     @@@@XSourceNodeParam:
4195 wakaba 1.4 @@@XSubTypeDef:
4196     @@@@QName: UNABLE_TO_GET_MODULE_ERR
4197     @@@@enDesc:
4198     The implementation is unable to get the module source.
4199     @@@@Def:
4200     @@@@@ContentType:
4201     lang:muf
4202     @@@@@lang:en
4203     @@@@@@:
4204     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
4205     @@@@XParam:
4206     @@@@@QName: uri
4207     @@@@@enDesc:
4208     The URI reference of the module.
4209     @@@@XParam:
4210     @@@@@QName: namespaceURI
4211     @@@@@enDesc:
4212     The namespace URI of the module name.
4213     @@@@XParam:
4214     @@@@@QName: localName
4215     @@@@@enDesc:
4216     The local name of the module name.
4217     @@@@XParam:
4218     @@@@@QName: for
4219     @@@@@enDesc:
4220     The <QUOTE::for> of the module.
4221 wakaba 1.5 @@@XSubTypeDef:
4222     @@@@QName: NO_FOR_QNAME_ERR
4223     @@@@enDesc:
4224     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
4225     @@@@XSourceNodeParam:
4226     @@@XSubTypeDef:
4227     @@@@QName: FOR_ALREADY_DEFINED_ERR
4228     @@@@enDesc:
4229     The <QUOTE::for> named as the same URI reference has
4230     already defined.
4231     @@@@XSourceNodeParam:
4232     @@@@XParam:
4233     @@@@@QName: anotherSourceNode
4234     @@@@@enDesc:
4235     The node that defines the <QUOTE::for> URI reference before.
4236 wakaba 1.7 @@@@XParam:
4237     @@@@@Name: uri
4238     @@@@@enDesc:
4239     The URI reference of the <QUOTE::for> attempted to define.
4240     @@@@enMufDef:
4241     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
4242 wakaba 1.5 @@@XSubTypeDef:
4243     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
4244     @@@@enDesc:
4245     The <QUOTE::dis> resource named as the same URI reference has
4246     already defined.
4247     @@@@XSourceNodeParam:
4248     @@@@XParam:
4249     @@@@@QName: anotherSourceNode
4250     @@@@@enDesc:
4251     The node that defines the <QUOTE::for> URI reference before.
4252 wakaba 1.7 @@@@XParam:
4253     @@@@@Name: uri
4254     @@@@@enDesc:
4255     The URI reference of the resource attempted to define.
4256     @@@@enMufDef:
4257     Resource <%p (name => {<Q::DIS:uri>});> is already defined
4258 wakaba 1.5 @@@XSubTypeDef:
4259     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
4260     @@@@enDesc:
4261     An element has occured where it is not allowed.
4262     @@@@enMufDef:
4263     Module <%p (name => {<Q::DIS:uri>});>:
4264     Element of type <%p (name => {<Q::DIS:elementType>});>
4265     is not allowed here
4266     @@@@XSourceNodeParam:
4267     @@@@XParam:
4268     @@@@@QName: elementType
4269     @@@@@enDesc:
4270     The expanded element type name of the element.
4271     @@@@XParam:
4272     @@@@@QName: uri
4273     @@@@@enDesc:
4274     The URI reference of the module.
4275 wakaba 1.7 @@@XSubTypeDef:
4276     @@@@QName: NO_REQUIRED_ATTR_ERR
4277     @@@@enDesc:
4278     A required attribute is not specified.
4279     @@@@XSourceNodeParam:
4280     @@@@XParam:
4281     @@@@@QName: elementType
4282     @@@@@enDesc:
4283     The expanded URI reference of the attribute name.
4284     @@@@enMufDef:
4285     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
4286 wakaba 1.8 @@@XSubTypeDef:
4287     @@@@QName: FOR_NOT_DEFINED_ERR
4288     @@@@enDesc:
4289     A <QUOTE::for> is referred but not defined.
4290     @@@@XSourceNodeParam:
4291     @@@@XParam:
4292     @@@@@QName: uri
4293     @@@@@enDesc:
4294     The URI reference of the <QUOTE::for> that is not defined.
4295     @@@@enMufDef:
4296     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
4297     @@@XSubTypeDef:
4298     @@@@QName: RESOURCE_NOT_DEFINED_ERR
4299     @@@@enDesc:
4300     A <QUOTE::dis> resource is referred but not defined.
4301     @@@@XSourceNodeParam:
4302     @@@@XParam:
4303     @@@@@QName: uri
4304     @@@@@enDesc:
4305     The URI reference of the resource that is not defined.
4306     @@@@enMufDef:
4307     Resource <%p (name => {<Q::DIS:uri>});> is not defined
4308     @@@XSubTypeDef:
4309     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
4310     @@@@enDesc:
4311     A reserved Perl method name is used.
4312     @@@@XParam:
4313     @@@@@QName:uri
4314     @@@@@enDesc:
4315     The URI reference of the method resource.
4316     @@@@XSourceNodeParam:
4317     @@@@XParam:
4318     @@@@@QName: generatedName
4319     @@@@@enDesc:
4320     A reserved method name.
4321     @@@XSubTypeDef:
4322     @@@@QName: NO_DIS_TYPE_ERR
4323     @@@@enDesc:
4324     <Q::dis:Type> attribute is not found.
4325     @@@@XSourceNodeParam:
4326 wakaba 1.4 ##DISException
4327 wakaba 1.5
4328     XParamDef:
4329     @QName: elementType
4330     @Type: ResourceURI
4331     @enDesc:
4332     The name of the element type.
4333    
4334     XParamDef:
4335     @QName: uri
4336     @Type: ResourceURI
4337     @enDesc:
4338     The name of the resource, composed from <Q::namespaceURI>,
4339     <Q::localName> and <Q::for>.
4340    
4341     XParamDef:
4342     @QName: localName
4343     @Type:
4344     DISCore:LocalName
4345     @enDesc:
4346     The local name of the resource, unique in <Q::namespaceURI> namespace.
4347    
4348     XParamDef:
4349     @QName: namespaceURI
4350     @Type: AnyURI
4351     @enDesc:
4352     The namespace URI reference of the resource name.
4353    
4354     XParamDef:
4355     @QName: for
4356     @Type: ForURI
4357     @enDesc:
4358     The <QUOTE::for> URI reference of the resource.
4359    
4360     ElementTypeBinding:
4361     @Name: XSourceNodeParam
4362     @ElementType:
4363     ManakaiDOM:exceptionOrWarningParameter
4364     @ShadowContent:
4365     @@QName: sourceNode
4366     @@Description:
4367     @@@lang:en
4368     @@@@:
4369     The node in which an error has occurred.
4370 wakaba 1.4
4371     ClsDef:
4372     @ClsQName: ManakaiDISExceptionTarget
4373     @enDesc:
4374     Objects that is able to be the target of an exception.
4375     @IntMethod:
4376     @@Operator:
4377     @@@@:
4378     ManakaiDOM:MUErrorHandler
4379     @@@ContentType:
4380     dis:TypeQName
4381     @@Description:
4382     @@@lang:en
4383     @@@@:
4384     This method is a generic error handler; all manakai exceptions
4385     and warnings associated to an object are once reported to this method
4386     and then delivered to appropriate entities.
4387     \
4388     If the error is an exception (such as <X::DOMCore:DOMException> or
4389     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
4390     simply thrown. If the error is only a warning, it is reported
4391     via the <IF::DOMCore:DOMError> interface.
4392     \
4393     See <PerlModule::Message::Util::Error> documentation for more
4394     information on the error reporting mechanism.
4395     \
4396     {NOTE:: This kind of methods are named as <Perl::___report_error>
4397     in the convention of <PerlModule::Message::Util::Error>.
4398     \
4399     }
4400     @@Param:
4401     @@@Name:err
4402     @@@Type:
4403     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
4404     @@@Description:
4405     @@@@lang:en
4406     @@@@@:
4407     An exception object that describes what kind of error it is
4408     and how it should be recovered.
4409     \
4410     {NOTE:: Exception objects in manakai implementation
4411     inherit the class <PerlModule::Message::Util::Error>,
4412     that in turn inherits <PerlModule::Error>.
4413     \
4414     }
4415     @@Return:
4416     @@@PerlDef:
4417     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
4418     ::ManakaiDOM:Perl>)) {
4419     $err->throw;
4420     } else {
4421     \## TODO: Implement warning reporting
4422     warn $err->stringify;
4423     }
4424     ##DISExceptionTarget
4425    
4426     ForDef:
4427     @QName:
4428     DIS:ForIF
4429     ForDef:
4430     @QName:
4431     DIS:ForClass
4432    
4433     ElementTypeBinding:
4434     @Name: IFClsDef
4435     @ElementType:
4436     dis:ResourceDef
4437     @ShadowContent:
4438     @@rdf:type:
4439     @@@@:
4440     dis:MultipleResource
4441     @@@ForCheck: !ForClass !ForIF
4442     @@rdf:type:
4443     @@@@:
4444     ManakaiDOM:IF
4445     @@@ForCheck: ForIF
4446     @@rdf:type:
4447     @@@@:
4448     ManakaiDOM:Class
4449     @@@ForCheck: ForClass
4450     @@resourceFor: ForIF
4451     @@resourceFor:
4452     @@@@: ForClass
4453     @@@ForCheck: ForLatest
4454     @@DOMMain:implementFeature:
4455     @@@@:CoreFeature10
4456     @@@ForCheck: ForClass
4457     @@ForCheck:
4458     ManakaiDOM:Perl
4459 wakaba 1.3
4460     ElementTypeBinding:
4461     @Name: ClsDef
4462     @ElementType:
4463     dis:ResourceDef
4464     @ShadowContent:
4465     @@rdf:type:
4466     ManakaiDOM:Class
4467     @@AliasFor:
4468     @@@@:
4469     ::ForLatest
4470     @@@For:
4471     !=ForLatest
4472     @@ForCheck:
4473     ManakaiDOM:Perl
4474     @@DOMMain:implementFeature: CoreFeature10
4475    
4476     ElementTypeBinding:
4477     @Name: ExceptionDef
4478     @ElementType:
4479     dis:ResourceDef
4480     @ShadowContent:
4481     @@rdf:type:
4482     ManakaiDOM:ExceptionClass
4483     @@AliasFor:
4484     @@@@:
4485     ::ForLatest
4486     @@@For:
4487     !=ForLatest
4488     @@ForCheck:
4489     ManakaiDOM:Perl
4490     @@DOMMain:implementFeature: CoreFeature10
4491    
4492     ElementTypeBinding:
4493     @Name: ClsQName
4494     @ElementType:
4495     dis:QName
4496    
4497     ElementTypeBinding:
4498     @Name: ClsISA
4499     @ElementType:
4500     dis:ISA
4501    
4502     ElementTypeBinding:
4503     @Name: Method
4504     @ElementType:
4505     dis:ResourceDef
4506     @ShadowContent:
4507     @@rdf:type:
4508     DISLang:Method
4509    
4510     ElementTypeBinding:
4511     @Name: IntMethod
4512     @ElementType:
4513     dis:ResourceDef
4514     @ShadowContent:
4515     @@rdf:type:
4516     DISLang:Method
4517     @@ManakaiDOM:isForInternal:1
4518    
4519     ElementTypeBinding:
4520     @Name: Attr
4521     @ElementType:
4522     dis:ResourceDef
4523     @ShadowContent:
4524     @@rdf:type:
4525     DISLang:Attribute
4526    
4527     ElementTypeBinding:
4528     @Name: Return
4529     @ElementType:
4530     dis:ResourceDef
4531     @ShadowContent:
4532     @@rdf:type:
4533     DISLang:MethodReturn
4534    
4535     ElementTypeBinding:
4536     @Name: Get
4537     @ElementType:
4538     dis:ResourceDef
4539     @ShadowContent:
4540     @@rdf:type:
4541     DISLang:AttributeGet
4542    
4543     ElementTypeBinding:
4544     @Name: Set
4545     @ElementType:
4546     dis:ResourceDef
4547     @ShadowContent:
4548     @@rdf:type:
4549     DISLang:AttributeSet
4550    
4551     ElementTypeBinding:
4552     @Name: Param
4553     @ElementType:
4554     dis:ResourceDef
4555     @ShadowContent:
4556     @@rdf:type:
4557     DISLang:MethodParameter
4558    
4559     ElementTypeBinding:
4560     @Name: PerlDef
4561     @ElementType:
4562     dis:Def
4563     @ShadowContent:
4564     @@ContentType:
4565     lang:Perl
4566    
4567     ElementTypeBinding:
4568     @Name: disDef
4569     @ElementType:
4570     dis:Def
4571     @ShadowContent:
4572     @@ContentType:
4573     lang:dis
4574    
4575     ElementTypeBinding:
4576     @Name: InCase
4577     @ElementType:
4578     dis:ResourceDef
4579     @ShadowContent:
4580     @@rdf:type:
4581     ManakaiDOM:InCase
4582    
4583     ElementTypeBinding:
4584     @Name: nullCase
4585     @ElementType:
4586     dis:ResourceDef
4587     @ShadowContent:
4588     @@rdf:type:
4589     ManakaiDOM:InCase
4590     @@Value:
4591     @@@is-null:1
4592    
4593     ElementTypeBinding:
4594     @Name: TrueCase
4595     @ElementType:
4596     dis:ResourceDef
4597     @ShadowContent:
4598     @@rdf:type:
4599     ManakaiDOM:InCase
4600     @@Value:true
4601     @@Type:
4602     DOMMain:boolean
4603    
4604    
4605     ElementTypeBinding:
4606     @Name: FalseCase
4607     @ElementType:
4608     dis:ResourceDef
4609     @ShadowContent:
4610     @@rdf:type:
4611     ManakaiDOM:InCase
4612     @@Value:false
4613     @@Type:
4614     DOMMain:boolean
4615    
4616     ElementTypeBinding:
4617     @Name: enDesc
4618     @ElementType:
4619     dis:Description
4620     @ShadowContent:
4621     @@lang:en
4622    
4623     ElementTypeBinding:
4624     @Name: PropDef
4625     @ElementType:
4626     dis:ResourceDef
4627     @ShadowContent:
4628     @@rdf:type:
4629     rdf:Property
4630     @@AliasFor:
4631     @@@@:
4632     ::ManakaiDOM:all
4633     @@@For:
4634     !=ManakaiDOM:all
4635    
4636     ElementTypeBinding:
4637     @Name: MethodRedef
4638     @ElementType:
4639     dis:ResourceDef
4640     @ShadowContent:
4641     @@rdf:type:
4642     DISLang:Method
4643     @@ManakaiDOM:isRedefining:1
4644    
4645     ElementTypeBinding:
4646     @Name: NamedParam
4647     @ElementType:
4648     dis:ResourceDef
4649     @ShadowContent:
4650     @@rdf:type:
4651     DISLang:MethodParameter
4652     @@DISPerl:isNamedParameter:1
4653    
4654     ElementTypeBinding:
4655     @Name: NodeParam
4656     @ElementType:
4657     dis:ResourceDef
4658     @ShadowContent:
4659     @@rdf:type:
4660     DISLang:MethodParameter
4661     @@DISPerl:isNamedParameter:1
4662     @@Name: node
4663     @@Type: ManakaiDISNode
4664     @@Description:
4665     @@@lang:en
4666     @@@@:
4667     The node in which the name has occurred. It is intended
4668     to be reported when an exception had been raised.
4669     @@ResourceDef:
4670     @@@rdf:type:
4671     ManakaiDOM:InCase
4672     @@@Value:
4673     @@@@is-null:1
4674     @@@Description:
4675     @@@@lang:en
4676     @@@@@:
4677     The source of the name is not a node.
4678    
4679     ElementTypeBinding:
4680     @Name: ForParam
4681     @ElementType:
4682     dis:ResourceDef
4683     @ShadowContent:
4684     @@rdf:type:
4685     DISLang:MethodParameter
4686     @@DISPerl:isNamedParameter:1
4687     @@Name: forArg
4688     @@Type: ForURI
4689     @@Description:
4690     @@@lang:en
4691     @@@@:
4692     The <QUOTE::for> URI reference.
4693     @@ResourceDef:
4694     @@@rdf:type:
4695     ManakaiDOM:InCase
4696     @@@Value:
4697     @@@@is-null:1
4698     @@@Description:
4699     @@@@lang:en
4700     @@@@@:
4701     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
4702    
4703     ElementTypeBinding:
4704     @Name: ForpParam
4705     @ElementType:
4706     dis:ResourceDef
4707     @ShadowContent:
4708     @@rdf:type:
4709     DISLang:MethodParameter
4710     @@DISPerl:isNamedParameter:1
4711     @@Name: forpArg
4712     @@Type: ForURIList
4713     @@Description:
4714     @@@lang:en
4715     @@@@:
4716     An array reference containing additional <QUOTE::for>
4717     constraints (<QUOTE::For+> list).
4718     @@ResourceDef:
4719     @@@rdf:type:
4720     ManakaiDOM:InCase
4721     @@@Value:
4722     @@@@is-null:1
4723     @@@Description:
4724     @@@@lang:en
4725     @@@@@:
4726     Equivalent to the empty array reference.
4727    
4728     ElementTypeBinding:
4729     @Name: MediaTypeParam
4730     @ElementType:
4731     dis:ResourceDef
4732     @ShadowContent:
4733     @@rdf:type:
4734     DISLang:MethodParameter
4735     @@DISPerl:isNamedParameter:1
4736     @@Name: mediaType
4737     @@Type: MediaTypeURI
4738     @@Description:
4739     @@@lang:en
4740     @@@@:
4741     The URI reference identifying a media type.
4742     @@ResourceDef:
4743     @@@rdf:type:
4744     ManakaiDOM:InCase
4745     @@@Value:
4746     @@@@is-null:1
4747     @@@Description:
4748     @@@@lang:en
4749     @@@@@:
4750     No media type specified.
4751    
4752     ElementTypeBinding:
4753     @Name: MediaTypeDefaultParam
4754     @ElementType:
4755     dis:ResourceDef
4756     @ShadowContent:
4757     @@rdf:type:
4758     DISLang:MethodParameter
4759     @@DISPerl:isNamedParameter:1
4760     @@Name: defaultMediaType
4761     @@Type: MediaTypeURI
4762     @@Description:
4763     @@@lang:en
4764     @@@@:
4765     The default media type, i.e. the type used when no explicit
4766     specification is not found in the source tree.
4767     @@ResourceDef:
4768     @@@rdf:type:
4769     ManakaiDOM:InCase
4770     @@@Value:
4771     @@@@is-null:1
4772     @@@Description:
4773     @@@@lang:en
4774     @@@@@:
4775     Defaulted to <Q::DOMMain:any>.
4776    
4777     ElementTypeBinding:
4778     @Name: RaiseException
4779     @ElementType:
4780     ManakaiDOM:raises
4781    
4782     ElementTypeBinding:
4783     @Name: UndeclaredPrefixException
4784     @ElementType:
4785     ManakaiDOM:raises
4786     @ShadowContent:
4787     @@@: UNDECLARED_NS_PREFIX_ERR
4788     @@Description:
4789     @@@lang:en
4790     @@@@:
4791     The implementation has encounted an undeclared namespace prefix.
4792    
4793     ElementTypeBinding:
4794     @Name: NoDBException
4795     @ElementType:
4796     ManakaiDOM:raises
4797     @ShadowContent:
4798     @@@: NO_DB_ASSOCIATED_ERR
4799     @@Description:
4800     @@@lang:en
4801     @@@@:
4802     No <QUOTE::dis> database is associated to this document.
4803    
4804     ElementTypeBinding:
4805     @Name: XConstGroupDef
4806     @ElementType:
4807     dis:ResourceDef
4808     @ShadowContent:
4809     @@rdf:type:
4810     ManakaiDOM:ConstGroup
4811     @@Type:
4812     DOMMain:unsigned-short::ManakaiDOM:all
4813     @@rdfs:subClassOf:
4814     DOMMain:unsigned-short::ManakaiDOM:all
4815    
4816     ElementTypeBinding:
4817     @Name: XConstDef
4818     @ElementType:
4819     dis:ResourceDef
4820     @ShadowContent:
4821     @@rdf:type:
4822     ManakaiDOM:Const
4823    
4824     ElementTypeBinding:
4825     @Name: XSubTypeDef
4826     @ElementType:
4827     dis:ResourceDef
4828     @ShadowContent:
4829     @@rdf:type:
4830     ManakaiDOM:ExceptionOrWarningSubType
4831    
4832     ElementTypeBinding:
4833     @Name: XParam
4834     @ElementType:
4835     ManakaiDOM:exceptionOrWarningParameter
4836    
4837     ElementTypeBinding:
4838     @Name: XParamDef
4839     @ElementType:
4840     dis:ResourceDef
4841     @ShadowContent:
4842     @@rdf:type:
4843     DOMMain:XWParameter
4844     @@AliasFor:
4845     @@@For:
4846     !=ManakaiDOM:all
4847     @@@@:
4848     ::ManakaiDOM:all
4849    
4850     ElementTypeBinding:
4851     @Name: enMufDef
4852     @ElementType:
4853     dis:Def
4854     @ShadowContent:
4855     @@ContentType:
4856     lang:muf
4857     @@lang:en
4858    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24