/[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.11 - (hide annotations) (download)
Sat Mar 5 12:00:44 2005 UTC (20 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.10: +61 -13 lines
lib/Message/Util/DIS.dis: forMatch bug fixed; lib/Message/Util/PerlCode.dis: Methods for use overload added

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.11 $Date: 2005/03/05 08:09:29 $
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.11 if ($ce-><AG::swcfg21:SWCFGElement::swcfg21:ForLatest
911 wakaba 1.3 .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.11 if ($el-><AG::ManakaiDISElement.isResourceElement>) {
2159 wakaba 1.7 $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 wakaba 1.11 my $ln = $n_node-><AG::swcfg21:SWCFGNode
2355     ::swcfg21:ForLatest.value>;
2356 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
2357     $localName => $ln,
2358     $result => $ru}__;
2359 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2360     ($ru, for_arg => $forArg);
2361 wakaba 1.5 $res->{nameURI} = $ru;
2362 wakaba 1.6 $res->{localName} = $n_node-><AG::swcfg21:SWCFGNode
2363     ::swcfg21:ForLatest.value>;
2364 wakaba 1.5 $res->{<Q::isAnon>} = true;
2365     } else { ## Root local name resource
2366 wakaba 1.7 my $ln = $n_node-><AG::swcfg21:SWCFGNode
2367     ::swcfg21:ForLatest.value>;
2368     my $ns_uri = $mod-><M::ManakaiDISPropertyAccessor
2369     .getPropertyText>
2370     (<Q::dis:Namespace>, null);
2371     my $qn_uri = $ns_uri . $ln;
2372 wakaba 1.9 $res = $self-><M::ManakaiDISDatabase.getResource>
2373     ($qn_uri, for_arg => $forArg);
2374 wakaba 1.6 if ($res-><M::ManakaiDISForDefinition.isDefined>) {
2375     __UNDEEP{
2376     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
2377 wakaba 1.9 DIS:uri => {$res->{uri}},
2378 wakaba 1.6 DIS:sourceNode => {$n_node},
2379     DIS:anotherSourceNode => {$res->{src}},
2380     }__;
2381     }__;
2382     }
2383     $res->{nameURI} = $qn_uri;
2384 wakaba 1.7 $res->{namespaceURI} = $ns_uri;
2385     $res->{localName} = $ln;
2386 wakaba 1.5 }
2387     } else {
2388 wakaba 1.6 $res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2389 wakaba 1.5 $res->{<Q::isAnon>} = true;
2390     }
2391 wakaba 1.6 } # anon
2392 wakaba 1.5 $res->{for} = $forArg;
2393     $res->{forp} = $forpArg;
2394     $res->{src} = $el;
2395     $res->{<Q::definingModule>} = $mod->{uri};
2396 wakaba 1.9 $mod-><M::ManakaiDISPropertyAccessor.addPropertyResourceList>
2397     (<Q::DIS:resource>, $res);
2398 wakaba 1.8 $res->{<Q::dis2pm:parentResource>}
2399     = $parentResource ? $parentResource->{uri} : null;
2400     $res->{<Q::dynamicParentResource>}
2401 wakaba 1.9 = $dynParent ? $dynParent->{uri} : null;
2402     unless ($res->{uri} eq $node_uri) {
2403     my $nu_res = $self-><M::ManakaiDISDatabase.getResource> ($node_uri);
2404     $res-><M::ManakaiDISResourceDefinition.mergeAsAlias> ($nu_res);
2405     }
2406 wakaba 1.7 $res->{<Q::isDefined>} = true;
2407 wakaba 1.9 $res->{seq} = $self->{seq}++;
2408    
2409 wakaba 1.6 ## -- Alias
2410     my $al_node = $el-><M::ManakaiDISElement.disGetAttribute>
2411     (<Q::dis:AliasFor>, for_arg => $forArg,
2412     forp_arg => $forpArg);
2413     if ($al_node) {
2414     my $canon_uri = $al_node-><M::ManakaiDISElement.tfqnamesValueURI>
2415     ($node_id, $forArg);
2416     my $canon_res = $self-><M::ManakaiDISDatabase.getResource>
2417     ($canon_uri);
2418     $canon_res-><M::ManakaiDISResourceDefinition.isReferred> ($al_node);
2419 wakaba 1.11 $canon_res-><M::ManakaiDISResourceDefinition.mergeAsAlias>
2420     ($res, node => $al_node);
2421 wakaba 1.6 $res = $canon_res;
2422     }
2423 wakaba 1.5
2424 wakaba 1.11 ## -- Registers as child
2425     $parentResource-><M::ManakaiDISPropertyAccessor
2426     .addPropertyResourceList>
2427     (<Q::DIS:childResource>, $res)
2428     if $parentResource;
2429     $dynParent-><M::ManakaiDISPropertyAccessor
2430     .addPropertyResourceList>
2431     (<Q::DIS:dynamicChildResource>, $res)
2432     if $dynParent;
2433    
2434 wakaba 1.7 my $is_multires = false;
2435     my @props;
2436     my @cres;
2437 wakaba 1.10 my @ce0 = @{$el-><M::ManakaiDISElement.disChildElements>
2438     (for_arg => $forArg, forp_arg => $forpArg)};
2439 wakaba 1.7 while (@ce0) {
2440     my $ce = shift @ce0;
2441     if ($ce-><M::ManakaiDISElement.elementTypeMatch> (<Q::rdf:type>)) {
2442     my $type_uri = $ce-><AG::ManakaiDISElement.qnameValueURI>;
2443     $res->{<Q::rdf:type>}->{$type_uri} = true;
2444     my $type = $self-><M::ManakaiDISDatabase.getResource> ($type_uri);
2445     $type-><M::ManakaiDISResourceDefinition.isReferred> ($ce);
2446     if ($type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
2447     (<Q::dis:MultipleResource>)) {
2448     $is_multires = true;
2449     }
2450     } elsif ($ce-><M::ManakaiDISElement.elementTypeMatch>
2451     (<Q::dis:subsetOf>)) {
2452     my $sres = $self-><M::ManakaiDISDatabase.getResource>
2453     ($ce-><M::ManakaiDISElement.tfqnamesValueURI>
2454     ($node_id, $forArg));
2455     $res-><M::ManakaiDISResourceDefinition.addSuperResource> ($sres);
2456 wakaba 1.11 } elsif ($ce-><AG::ManakaiDISElement.isResourceElement>) {
2457 wakaba 1.7 push @cres, $ce;
2458     } else {
2459     ## Property and invalid element is not checked, since not
2460     ## all property definitions has loaded at this stage.
2461     push @props, $ce;
2462     }
2463     } # @ce0
2464    
2465     ## -- Child resources
2466     unless ($is_multires) {
2467     for my $re (@cres) {
2468     unless ($al_node) {
2469     $self-><M::ManakaiDISDatabase.loadResource>
2470     ($mod, $res, $res, $re,
2471     for_arg => $forArg, forp_arg => $forpArg);
2472 wakaba 1.5 } else {
2473 wakaba 1.7 my $ac = $re-><M::ManakaiDISElement.disGetAttribute>
2474     (<Q::dis:aliasChild>, for_arg => $forArg,
2475     forp_arg => $forpArg);
2476     if ($ac and $ac-><M::swcfg21:SWCFGNode
2477     ::swcfg21:ForLatest.value>) {
2478     $self-><M::ManakaiDISDatabase.loadResource>
2479     ($mod, $res, $res, $re,
2480     for_arg => $forArg, forp_arg => $forpArg);
2481     }
2482 wakaba 1.4 }
2483     }
2484 wakaba 1.7 }
2485 wakaba 1.5
2486 wakaba 1.7 ## -- Multiple representations
2487     if ($is_multires) {
2488     for my $pe (@props) {
2489     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
2490 wakaba 1.10 (<Q::dis:resourceFor>)) {
2491 wakaba 1.7 my $for_uri = $pe-><M::ManakaiDISElement.qnameValueURI>;
2492     my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
2493     $for-><M::ManakaiDISForDefinition.isReferred> ($pe);
2494     $self-><M::ManakaiDISDatabase.loadResource>
2495     ($mod, $parentResource, $res, $el,
2496     for_arg => $forArg,
2497     forp_arg => [@{$forpArg}, $for_uri]);
2498     }
2499     }
2500     }
2501 wakaba 1.5 }__; # DEEP
2502 wakaba 1.8
2503     @Method:
2504     @@Name: checkUndefinedResource
2505     @@enDesc:
2506     Checks whether there is referred but undefined resource or not.
2507     @@Return:
2508     @@@RaiseException:
2509     @@@@@: FOR_NOT_DEFINED_ERR
2510     @@@@enDesc:
2511     There is a <QUOTE::for> that is referred but not defined.
2512     @@@RaiseException:
2513     @@@@@: RESOURCE_NOT_DEFINED_ERR
2514     @@@@enDesc:
2515     There is a resource that is referred but not defined.
2516     @@@PerlDef:
2517     for my $fd (values %{$self->{forDef}}) {
2518     if (my $ref = $fd-><AG::ManakaiDISForDefinition.isReferred> and
2519     not $fd-><AG::ManakaiDISForDefinition.isDefined>) {
2520     __EXCEPTION{FOR_NOT_DEFINED_ERR::
2521     DIS:uri => {$fd->{uri}},
2522     DIS:sourceNode => {$ref},
2523     }__;
2524     }
2525     }
2526     for my $fd (values %{$self->{resDef}}) {
2527     if (my $ref = $fd-><AG::ManakaiDISResourceDefinition.isReferred> and
2528     not $fd-><AG::ManakaiDISResourceDefinition.isDefined>) {
2529     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2530     DIS:uri => {$fd->{uri}},
2531     DIS:sourceNode => {$ref},
2532     }__;
2533     }
2534     }
2535 wakaba 1.5
2536 wakaba 1.9
2537     @Method:
2538     @@Name: plStore
2539     @@enDesc:
2540     Saves this database to an external file.
2541     \
2542     {NOTE:: Saved files can be loaded by
2543     <M::ManakaiDISImplementation.plLoadDISDatabase>.
2544     \
2545     }
2546     @@Param:
2547     @@@Name: fileName
2548     @@@Type:
2549     DISLang:String
2550     @@@enDesc:
2551     An environment-dependent file name of external database to save.
2552     \
2553     {NOTE:: If there is already a file named as <P::fileName>, then
2554     it is overwritten.
2555     \
2556     }
2557     @@Return:
2558     @@@SimpleException:
2559     @@@PerlDef:
2560     use Storable qw/nstore/;
2561     local $Carp::CarpLevel = $Carp::CarpLevel + 1;
2562     nstore $self, $fileName;
2563 wakaba 1.2 ##DISDatabase
2564    
2565 wakaba 1.8 PropDef:
2566 wakaba 1.9 @QName: resource
2567     @enDesc:
2568     Resources defined in a module.
2569     @rdfs:range: ManakaiDISResourceDefinition
2570     @rdfs:domain: ManakaiDISModuleDefinition
2571    
2572     PropDef:
2573 wakaba 1.8 @QName:
2574     dis2pm:parentResource
2575     @enDesc:
2576     Static parent resource. No parent for root resources.
2577    
2578     PropDef:
2579     @QName: dynamicParentResource
2580     @enDesc:
2581     Dynamic parent resource. No parent for root resources.
2582    
2583 wakaba 1.11 PropDef:
2584     @QName: childResource
2585     @enDesc:
2586     Static child resources.
2587    
2588     PropDef:
2589     @QName: dynamicChildResource
2590     @enDesc:
2591     Dynamic child resources.
2592    
2593 wakaba 1.5 ElementTypeBinding:
2594     @Name: ForDefDupException
2595     @ElementType:
2596     ManakaiDOM:raises
2597     @ShadowContent:
2598     @@@: FOR_ALREADY_DEFINED_ERR
2599     @@Description:
2600     @@@lang:en
2601     @@@@:
2602     The <QUOTE::for> is already defined elsewhere.
2603    
2604     ElementTypeBinding:
2605     @Name: ForDefNoQNameException
2606     @ElementType:
2607     ManakaiDOM:raises
2608     @ShadowContent:
2609     @@@: NO_FOR_QNAME_ERR
2610     @@Description:
2611     @@@lang:en
2612     @@@@:
2613     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
2614    
2615     ElementTypeBinding:
2616     @Name: ResDefDupException
2617     @ElementType:
2618     ManakaiDOM:raises
2619     @ShadowContent:
2620     @@@: RESOURCE_ALREADY_DEFINED_ERR
2621     @@Description:
2622     @@@lang:en
2623     @@@@:
2624     The <QUOTE::dis> resource is already defined elsewhere.
2625    
2626     ElementTypeBinding:
2627     @Name: ElementNotAllowedException
2628     @ElementType:
2629     ManakaiDOM:raises
2630     @ShadowContent:
2631     @@@: ELEMENT_NOT_ALLOWED_ERR
2632     @@Description:
2633     @@@lang:en
2634     @@@@:
2635     An element has found where it is not allowed.
2636    
2637 wakaba 1.4 IFClsDef:
2638     @QName:
2639     @@@: DISModuleResolver
2640     @@ForCheck: ForIF
2641     @QName:
2642     @@@: ManakaiDISModuleResolver
2643     @@ForCheck: ForClass
2644     @enDesc:
2645     Objects implementing <IF::DISModuleResolver> interface
2646     are used to convert module name into <QUOTE::dis> document object.
2647     \
2648     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
2649     as a method parameter where <IF::DISModuleResolver> is
2650     expected.
2651     \
2652     }
2653     @Method:
2654     @@Name: uriToDocument
2655     @@enDesc:
2656     Returns a <QUOTE::dis> document from module name information.
2657     @@Param:
2658     @@@Name: disDB
2659     @@@Type: ManakaiDISDatabase
2660     @@@enDesc:
2661     The <QUOTE::dis> database.
2662     @@Param:
2663     @@@Name: moduleURI
2664     @@@Type: ModuleURI
2665     @@@enDesc:
2666     The URI reference of the module.
2667     \
2668     {NOTE:: This parameter is redundant, since it can be
2669     composed from other three parameters.
2670     \
2671     }
2672     @@Param:
2673     @@@Name: moduleNamespaceURI
2674     @@@Type: AnyURI
2675     @@@enDesc:
2676     The namespace URI of the module name.
2677     @@Param:
2678     @@@Name: moduleLocalName
2679     @@@Type:
2680     DISCore:LocalName
2681     @@@enDesc:
2682     The local name of the module name.
2683     @@Param:
2684     @@@Name: moduleFor
2685     @@@Type: ForURI
2686     @@@enDesc:
2687     The <QUOTE::for> URI reference for which the module is defined.
2688     @@Return:
2689     @@@Type: ManakaiDISDocument
2690     @@@enDesc:
2691     The <QUOTE::dis> document. It don't have to be a newly created
2692     object.
2693     @@@nullCase:
2694     @@@@enDesc:
2695     The method is unable to resolve the reference.
2696     @@@PerlDef:
2697     $r = $self->(@_);
2698     @ManakaiDOM:inputNormalizer:
2699     @@ContentType:
2700     lang:Perl
2701     @@@:
2702     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
2703     if ref $INPUT eq 'CODE';
2704     @@ImplNote:
2705     @@@lang:en
2706     @@@@:
2707     <FILE::cdis2pm.pl> does not support non-datatype input normalizers yet.
2708     ##DISModuleResolver
2709    
2710 wakaba 1.3 PropDef:
2711     @QName: sourceFile
2712     @enDesc:
2713     Source <QUOTE::dis> documents.
2714     @rdfs:domain: ManakaiDISDatabase
2715     @rdfs:range: ManakaiDISDocument
2716    
2717 wakaba 1.2 ClsDef:
2718     @ClsQName: ManakaiDISModuleDefinition
2719     @enDesc:
2720     <QUOTE::dis> module definitions.
2721     @ClsISA: ManakaiDISPropertyAccessor
2722 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2723 wakaba 1.2
2724     @Attr:
2725     @@Name: uri
2726     @@Type: ModuleURI
2727     @@Description:
2728     @@@lang:en
2729     @@@@:
2730     The URI reference of this <QUOTE::dis> module.
2731     @@Get:
2732     @@@PerlDef:
2733     $r = $self->{uri};
2734    
2735     @Attr:
2736     @@Name: nameURI
2737     @@Type: NameURI
2738     @@enDesc:
2739     The URI reference of this module, without
2740     <QUOTE::for> identifier.
2741     @@Get:
2742 wakaba 1.3 @@@PerlDef:
2743 wakaba 1.4 $r = $self->{nameURI};
2744 wakaba 1.2
2745     @Attr:
2746     @@Name: localName
2747     @@enDesc:
2748     The local name of this module.
2749     @@Type:
2750 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
2751 wakaba 1.2 @@Get:
2752     @@@PerlDef:
2753     $r = $self->{localName};
2754    
2755     @Attr:
2756     @@Name: namespaceURI
2757     @@Type: AnyURI
2758     @@enDesc:
2759     The namespace URI of the name of this resource.
2760     @@Get:
2761     @@@PerlDef:
2762     $r = $self->{namespaceURI};
2763    
2764     @Attr:
2765     @@Name: forURI
2766     @@Type: ForURI
2767     @@enDesc:
2768     The <QUOTE::for> URI reference for which this module is defined.
2769     @@Get:
2770     @@@PerlDef:
2771     $r = $self->{for};
2772    
2773     @Attr:
2774     @@Name: isDefined
2775     @@Description:
2776     @@@lang:en
2777     @@@@:
2778     Whether this module is defined or not.
2779     @@Type:
2780     DOMMain:boolean
2781     @@Get:
2782     @@@PerlDef:
2783     $r = $self->{<Q::isDefined>};
2784 wakaba 1.8
2785     @Attr:
2786     @@Name: plFullyQualifiedName
2787     @@enDesc:
2788     The fully-qualified Perl class package name.
2789     @@Type:
2790     Perl:package-name::ManakaiDOM:all
2791     @@Get:
2792     @@@NoPerlModuleNameException:
2793     @@@PerlDef:
2794     __DEEP{
2795     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2796     ($self->{namespaceURI});
2797     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2798     __UNDEEP{
2799     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2800     DIS:uri => {$self->{namespaceURI}},
2801     DIS:sourceNode => {$self->{src}},
2802     }__;
2803     }__;
2804     }
2805     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2806     (<Q::dis:AppName>, for_arg => $self->{for},
2807 wakaba 1.10 media_type => <Q::lang:Perl>,
2808     default_media_type => <Q::lang:Perl>);
2809 wakaba 1.8 if ($an) {
2810     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2811     $r =~ s/::$//g;
2812     $r .= '::' . $self->{localName};
2813     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2814     (<Q::ManakaiDOM:moduleSuffix>,
2815     for_arg => $self->{for},
2816     media_type => <Q::lang:Perl>,
2817     default_media_type => <Q::lang:Perl>);
2818     if ($sf) {
2819     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2820     }
2821     } else {
2822 wakaba 1.10 $r = ($mg->{localName} || 'main') . '::' . $self->{localName};
2823 wakaba 1.8 }
2824     }__;
2825    
2826     @Attr:
2827     @@Name: plInterfaceName
2828     @@enDesc:
2829     The fully-qualified Perl interface package name.
2830     @@Type:
2831     Perl:package-name::ManakaiDOM:all
2832     @@Get:
2833     @@@NoPerlModuleNameException:
2834     @@@PerlDef:
2835     __DEEP{
2836     my $mg = $self->{db}-><M::ManakaiDISDatabase.getResource>
2837     ($self->{namespaceURI});
2838     unless ($self-><AG::ManakaiDISResourceDefinition.isDefined>) {
2839     __UNDEEP{
2840     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
2841     DIS:uri => {$self->{namespaceURI}},
2842     DIS:sourceNode => {$self->{src}},
2843     }__;
2844     }__;
2845     }
2846     my $an = $mg->{src}-><M::ManakaiDISElement.disGetAttribute>
2847     (<Q::dis:AppName>, for_arg => $self->{for},
2848     forp_arg => [<Q::ManakaiDOM:ForIF>],
2849 wakaba 1.10 media_type => <Q::lang:Perl>,
2850     default_media_type => <Q::lang:Perl>);
2851 wakaba 1.8 if ($an) {
2852     $r = $an-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2853     $r =~ s/::$//g;
2854     my $sf = $an-><M::ManakaiDISElement.disGetAttribute>
2855     (<Q::ManakaiDOM:moduleSuffix>,
2856     for_arg => $self->{for},
2857     forp_arg => [<Q::ManakaiDOM:ForIF>],
2858     media_type => <Q::lang:Perl>,
2859     default_media_type => <Q::lang:Perl>);
2860     if ($sf) {
2861     $r .= $sf-><M::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
2862     }
2863     } else {
2864     $r = $self-><M::ManakaiDISModuleDefinition.plFullyQualifiedName>;
2865     }
2866     }__;
2867 wakaba 1.2 ##DISModuleDefinition
2868    
2869 wakaba 1.8 ElementTypeBinding:
2870     @Name: NoPerlModuleNameException
2871     @ElementType:
2872     ManakaiDOM:raises
2873     @ShadowContent:
2874     @@@: RESOURCE_NOT_DEFINED_ERR
2875     @@Description:
2876     @@@lang:en
2877     @@@@:
2878     The module group corresponding to the namespace URI
2879     of this module is not defined.
2880    
2881 wakaba 1.2 ClsDef:
2882     @ClsQName: ManakaiDISForDefinition
2883     @Description:
2884     @@lang:en
2885     @@@:
2886     <QUOTE::dis> <QUOTE::for> definitions.
2887 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
2888 wakaba 1.2
2889     @Attr:
2890     @@Name: uri
2891     @@Type: ForURI
2892     @@Description:
2893     @@@lang:en
2894     @@@@:
2895     The URI reference of this <QUOTE::for>.
2896     @@Get:
2897     @@@PerlDef:
2898     $r = $self->{uri};
2899 wakaba 1.10
2900     @IntMethod:
2901     @@Operator:
2902     @@@@:eq
2903     @@@ContentType:
2904     lang:Perl
2905     @@enDesc:
2906     Whether two <QUOTE::for> definitions are equal or not.
2907     Two <QUOTE::for> definitions are equal iff one's URI reference
2908     is one of another's URI reference.
2909     \
2910     {NOTE:: Aliases for <QUOTE::for> is not allowed.
2911     \
2912     }
2913     @@ImplNote:
2914     @@@lang:en
2915     @@@@:
2916     In the current implementation, two are equal iff two are
2917     equal as reference.
2918     @@Param:
2919     @@@Name: anotherFor
2920     @@@Type: ManakaiDISForDefinition
2921     @@@enDesc:
2922     Another <QUOTE::for> definition to compare.
2923     @@Return:
2924     @@@Type:
2925     DOMMain:boolean
2926     @@@enDesc:
2927     Whether two resources are equal or not.
2928     @@@PerlDef:
2929     if (UNIVERSAL::isa ($anotherFor, <ClassName::ManakaiDISForDefinition>)) {
2930     $r = $self->{uri} eq $anotherFor->{uri};
2931     } else {
2932     $r = false;
2933     }
2934 wakaba 1.2
2935     @Method:
2936     @@Name: isaURI
2937     @@Description:
2938     @@@lang:en
2939     @@@@:
2940     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
2941     @@Param:
2942     @@@Name: superURI
2943     @@@Type: ForURI
2944     @@@Description:
2945     @@@@lang:en
2946     @@@@@:
2947     Another <QUOTE::for> URI reference to test.
2948     @@Return:
2949     @@@Type:
2950     DOMMain:boolean
2951     @@@TrueCase:
2952     @@@@enDesc:
2953     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
2954     @@@FalseCase:
2955     @@@@enDesc:
2956     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
2957     @@@PerlDef:
2958     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
2959    
2960     @Attr:
2961     @@Name: isDefined
2962     @@Description:
2963     @@@lang:en
2964     @@@@:
2965     Whether this <QUOTE::for> is already defined or not.
2966     @@Type:
2967     DOMMain:boolean
2968     @@Get:
2969     @@@TrueCase:
2970     This <QUOTE::for> is already defined.
2971     @@@FalseCase:
2972     This <QUOTE::for> is not defined.
2973     @@@PerlDef:
2974     $r = $self->{<Q::isDefined>};
2975    
2976     @Attr:
2977     @@Name: isReferred
2978     @@Description:
2979     @@@lang:en
2980     @@@@:
2981     Whether this <QUOTE::for> is referred somewhere or not.
2982 wakaba 1.9 @@Type: ManakaiDISElement
2983 wakaba 1.2 @@Get:
2984     @@@InCase:
2985     @@@@Type:ManakaiDISElement
2986     @@@@enDesc:
2987     This <QUOTE::for> is referred by the element.
2988     @@@nullCase:
2989     This <QUOTE::for> is not referred.
2990     @@@PerlDef:
2991     $r = $self->{<Q::isReferred>};
2992     @@Set:
2993     @@@InCase:
2994     @@@@Type:ManakaiDISElement
2995     @@@@enDesc:
2996     This <QUOTE::for> is referred by the element.
2997     @@@PerlDef:
2998 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
2999 wakaba 1.2
3000     @Attr:
3001     @@Name: definingModule
3002     @@Description:
3003     @@@lang:en
3004     @@@@:
3005     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
3006     @@Type: ManakaiDISModuleDefinition
3007     @@Get:
3008     @@@Description:
3009     @@@@lang:en
3010     @@@@@:
3011     The module object.
3012 wakaba 1.3 @@@nullCase:
3013 wakaba 1.2 @@@@Description:
3014     @@@@@lang:en
3015     @@@@@@:
3016     This <QUOTE::for> is not associated to any module.
3017     @@@PerlDef:
3018     $r = $self->{db}
3019     -><M::ManakaiDISDatabase.getResource>
3020     ($self->{<Q::definingModule>})
3021     if defined $self->{<Q::definingModule>};
3022 wakaba 1.5
3023 wakaba 1.2 @Method:
3024 wakaba 1.5 @@Name: addISA
3025 wakaba 1.2 @@enDesc:
3026 wakaba 1.5 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
3027     <QUOTE::for>.
3028 wakaba 1.2 @@Param:
3029 wakaba 1.5 @@@Name: superFor
3030     @@@Type: ManakaiDISForDefinition
3031     @@@enDesc:
3032     A <QUOTE::for> definition object.
3033 wakaba 1.2 @@Return:
3034     @@@PerlDef:
3035 wakaba 1.5 my @from = ($self->{uri},
3036     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
3037     my @to = ($superFor->{uri},
3038     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
3039 wakaba 1.7 __DEEP{
3040     for my $from (@from) {
3041     for my $to (@to) {
3042     $self->{db}-><M::ManakaiDISDatabase.getFor>
3043     ($from)->{isa}->{$to} = true;
3044     $self->{db}-><M::ManakaiDISDatabase.getFor>
3045     ($to)->{revISA}->{$from} = true;
3046     }
3047 wakaba 1.5 }
3048 wakaba 1.7 }__;
3049 wakaba 1.5
3050 wakaba 1.2 ##DISForDefinition
3051    
3052     ClsDef:
3053     @ClsQName: ManakaiDISResourceDefinition
3054     @enDesc:
3055     <QUOTE::dis> resource definitions.
3056     @ClsISA: ManakaiDISPropertyAccessor
3057 wakaba 1.4 @ClsISA: ManakaiDISExceptionTarget
3058 wakaba 1.2
3059     @Attr:
3060     @@Name: uri
3061     @@Type: ResourceURI
3062     @@Description:
3063     @@@lang:en
3064     @@@@:
3065     The URI reference of this <QUOTE::dis> resource.
3066     @@Get:
3067     @@@PerlDef:
3068     $r = $self->{uri};
3069    
3070     @Attr:
3071     @@Name: nameURI
3072     @@Type: NameURI
3073     @@enDesc:
3074     The URI reference of this <QUOTE::dis> resource, without
3075     <QUOTE::for> identifier.
3076     @@Get:
3077     @@@nullCase:
3078     @@@@enDesc:
3079     This resource does not have its name URI reference.
3080 wakaba 1.3 @@@PerlDef:
3081 wakaba 1.4 $r = $self->{nameURI};
3082 wakaba 1.2
3083     @Attr:
3084     @@Name: localName
3085     @@enDesc:
3086     The local name of this resource.
3087     @@Type:
3088 wakaba 1.3 DISCore:LocalName::ManakaiDOM:all
3089 wakaba 1.2 @@Get:
3090     @@@nullCase:
3091     @@@@enDesc:
3092     This resource does not have its local name.
3093     @@@PerlDef:
3094     $r = $self->{localName};
3095    
3096     @Attr:
3097     @@Name: namespaceURI
3098     @@Type: AnyURI
3099     @@enDesc:
3100     The namespace URI of the name of this resource.
3101     @@Get:
3102     @@@nullCase:
3103     The name of this resource does not have its namespace
3104     or this resource does not have its name.
3105     @@@PerlDef:
3106     $r = $self->{namespaceURI};
3107    
3108     @Attr:
3109     @@Name: isAnonymous
3110     @@enDesc:
3111     Whether this <QUOTE::dis> resource has name or not.
3112     @@Type:
3113     DOMMain:boolean
3114     @@Get:
3115     @@@TrueCase:
3116     This resource does not have any global unique name.
3117     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
3118     @@@FalseCase:
3119     This resource does have its formal name.
3120     <A::ManakaiDISResourceDefinition.uri> is a URI reference
3121     generated from the name and the <QUOTE::for> URI reference
3122     of this resource.
3123     @@@PerlDef:
3124     $r = $self->{<Q::isAnon>};
3125    
3126     @Attr:
3127     @@Name: forURI
3128     @@enDesc:
3129     The <QUOTE::for> URI reference for which this resource is defined.
3130     @@Type:ForURI
3131     @@Get:
3132     @@@PerlDef:
3133     $r = $self->{for};
3134    
3135     @Attr:
3136     @@Name: forpURI
3137     @@enDesc:
3138     The <QUOTE::for+> URI references for which this resource is defined.
3139     @@Type: ForURIList
3140     @@Get:
3141 wakaba 1.3 @@@PerlDef:
3142 wakaba 1.2 $r = $self->{forp};
3143    
3144     @Method:
3145 wakaba 1.7 @@Name: isSubsetOfURI
3146 wakaba 1.2 @@Description:
3147     @@@lang:en
3148     @@@@:
3149     Whether this resource is a subset of another resource or not.
3150     @@Param:
3151     @@@Name: superURI
3152     @@@Type: ResourceURI
3153     @@@Description:
3154     @@@@lang:en
3155     @@@@@:
3156     Another resource URI reference to test.
3157     @@Return:
3158     @@@Type:
3159     DOMMain:boolean
3160     @@@TrueCase:
3161     @@@@enDesc:
3162     <P::superURI> is a super-resource of this resource.
3163     @@@FalseCase:
3164     @@@@enDesc:
3165     <P::superURI> is not a super-resource of this resource.
3166     @@@PerlDef:
3167 wakaba 1.6 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
3168 wakaba 1.2
3169 wakaba 1.7 @Method:
3170     @@Name: addSuperResource
3171     @@enDesc:
3172     Adds a <QUOTE::dis> resource to the list of super-resource
3173     of this <QUOTE::dis> resource.
3174     @@Param:
3175     @@@Name: superRes
3176     @@@Type: ManakaiDISResourceDefinition
3177     @@@enDesc:
3178     A <QUOTE::dis> resource definition object.
3179     @@Return:
3180     @@@PerlDef:
3181     my @from = ($self->{uri},
3182     grep {$self->{supOf}->{$_}} keys %{$self->{supOf}});
3183     my @to = ($superRes->{uri},
3184     grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}});
3185     __DEEP{
3186     for my $from (@from) {
3187     for my $to (@to) {
3188     $self->{db}-><M::ManakaiDISDatabase.getResource>
3189     ($from)->{subOf}->{$to} = true;
3190     $self->{db}-><M::ManakaiDISDatabase.getResource>
3191     ($to)->{supOf}->{$from} = true;
3192     }
3193     }
3194     }__;
3195    
3196 wakaba 1.2 @Attr:
3197     @@Name: isDefined
3198     @@Description:
3199     @@@lang:en
3200     @@@@:
3201     Whether this resource is already defined or not.
3202     @@Type:
3203     DOMMain:boolean
3204     @@Get:
3205     @@@TrueCase:
3206     This resource is already defined.
3207     @@@FalseCase:
3208     This resource is not defined.
3209     @@@PerlDef:
3210     $r = $self->{<Q::isDefined>};
3211    
3212     @Attr:
3213     @@Name: isReferred
3214     @@Description:
3215     @@@lang:en
3216     @@@@:
3217     Whether this resource is referred or not.
3218 wakaba 1.7 @@Type: ManakaiDISElement
3219 wakaba 1.2 @@Get:
3220 wakaba 1.7 @@@enDesc:
3221 wakaba 1.9 An element that referres this resource.
3222 wakaba 1.2 @@@nullCase:
3223     This resource is not referred.
3224     @@@PerlDef:
3225     $r = $self->{<Q::isReferred>};
3226     @@Set:
3227 wakaba 1.7 @@@enDesc:
3228 wakaba 1.9 An element that referres this resource.
3229 wakaba 1.2 @@@PerlDef:
3230 wakaba 1.9 $self->{<Q::isReferred>} = $given if $given;
3231 wakaba 1.2
3232     @Attr:
3233     @@Name: definingModule
3234     @@Description:
3235     @@@lang:en
3236     @@@@:
3237     The <QUOTE::dis> module in which this resource is defined.
3238 wakaba 1.8 \
3239     {NOTE:: Method name should have been <CODE::ownerModule> or some.
3240     \
3241     }
3242 wakaba 1.2 @@Type: ManakaiDISModuleDefinition
3243     @@Get:
3244     @@@Description:
3245     @@@@lang:en
3246     @@@@@:
3247     The module object.
3248 wakaba 1.3 @@@nullCase:
3249 wakaba 1.2 @@@@Description:
3250     @@@@@lang:en
3251     @@@@@@:
3252     This resource is not associated to any module.
3253     @@@PerlDef:
3254     $r = $self->{db}
3255     -><M::ManakaiDISDatabase.getModule>
3256     ($self->{<Q::definingModule>})
3257     if defined $self->{<Q::definingModule>};
3258     @@Set:
3259     @@@Description:
3260     @@@@lang:en
3261     @@@@@:
3262     The module object to which the <QUOTE::defining module> is set.
3263     @@@PerlDef:
3264     $self->{<Q::defininingModule>}
3265     = $given-><AG::ManakaiDISModuleDefinition.uri>;
3266    
3267 wakaba 1.6 @Method:
3268     @@Name: mergeAsAlias
3269     @@enDesc:
3270     Merges another resource definition as an alias of this resource.
3271     @@Param:
3272     @@@Name: aliasResource
3273     @@@Type: ManakaiDISResourceDefinition
3274     @@@enDesc:
3275     A resource to merge.
3276     \
3277     {NOTE:: After merging all references to <P::aliasResource>
3278     should be discarded.
3279     \
3280     }
3281 wakaba 1.11 @@NodeParam:
3282 wakaba 1.6 @@Return:
3283 wakaba 1.11 @@@RaiseException:
3284     @@@@@:MERGE_ITSELF_ERR
3285     @@@@@@enDesc:
3286     An attempt is made to merge this resource itself.
3287     @@@PerlDef:
3288     if ($self eq $aliasResource) {
3289     __EXCEPTION{MERGE_ITSELF_ERR::
3290     DIS:uri => {$self->{uri}},
3291     DIS:sourceNode => {$node},
3292     }__;
3293     }
3294 wakaba 1.6 for my $uri ($aliasResource->{uri},
3295     grep {$aliasResource->{aliasURI}->{$_}}
3296     keys %{$aliasResource->{aliasURI}}) {
3297     $self->{aliasURI}->{$uri} = true;
3298     $self->{db}->{resDef}->{$uri} = $self;
3299     $self->{subOf}->{$uri} = true;
3300     $self->{supOf}->{$uri} = true;
3301     }
3302     for my $uri (grep {$aliasResource->{subOf}->{$_}}
3303     keys %{$aliasResource->{subOf}}) {
3304     $self->{subOf}->{$uri} = true;
3305     }
3306     for my $uri (grep {$aliasResource->{supOf}->{$_}}
3307     keys %{$aliasResource->{supOf}}) {
3308     $self->{supOf}->{$uri} = true;
3309     }
3310     my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}};
3311     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}};
3312     __DEEP{
3313     for my $from (@from) {
3314     for my $to (@to) {
3315     $self->{db}-><M::ManakaiDISDatabase.getResource>
3316     ($from)->{subOf}->{$to} = true;
3317     $self->{db}-><M::ManakaiDISDatabase.getResource>
3318     ($to)->{supOf}->{$from} = true;
3319     }
3320     }
3321     }__;
3322 wakaba 1.7
3323     @Method:
3324     @@Name: isTypeURI
3325     @@enDesc:
3326     Tests whether this resource is of a type or not.
3327     @@Param:
3328     @@@Name: typeURI
3329     @@@Type: ResourceURI
3330     @@@enDesc:
3331     A type URI reference to test.
3332     @@Return:
3333     @@@Type:
3334     DOMMain:boolean
3335     @@@TrueCase:
3336     @@@@enDesc:
3337     This is a <P::typeURI> resource.
3338     @@@FalseCase:
3339     @@@@enDesc:
3340     This is not a <P::typeURI> resource.
3341     @@@PerlDef:
3342 wakaba 1.8 if ($self->{<Q::rdf:type>}->{$typeURI}) {
3343     $r = $self->{<Q::rdf:type>}->{$typeURI};
3344     } else {
3345     for my $t_type_uri (grep {$self->{<Q::rdf:type>}->{$_}}
3346     keys %{$self->{<Q::rdf:type>}}) {
3347     my $t_type = $self->{db}-><M::ManakaiDISDatabase.getResource>
3348     ($t_type_uri);
3349     if ($t_type-><M::ManakaiDISResourceDefinition.isSubsetOfURI>
3350     ($typeURI)) {
3351     $self->{<Q::rdf:type>}->{$typeURI} = $r = true;
3352     last;
3353     }
3354 wakaba 1.7 }
3355     }
3356 wakaba 1.8
3357     @Attr:
3358     @@Name: plName
3359     @@enDesc:
3360     The Perl name of this resource.
3361     @@Get:
3362     @@@Type:
3363     DISLang:String
3364     @@@enDesc:
3365     - <Q::ManakaiDOM:Const>::: Constant function (local) name.
3366     \
3367     - <Q::ManakaiDOM:ConstGroup>::: Export group name (without
3368     <CHAR::COLON> prefix).
3369     \
3370     - <Q::DISLang:Attribute>::: Method name.
3371     \
3372     - <Q::DISLang:Method>::: Method name.
3373     @@@nullCase:
3374     @@@@enDesc:
3375     Either the type of this resource is not listed above
3376     or this Perl constructure is anonymous.
3377     @@@RaiseException:
3378     @@@@@: NO_LOCAL_NAME_ERR
3379     @@@@enDesc:
3380     The type of this resource is either
3381     <Q::ManakaiDOM:Const> or <Q::ManakaiDOM:ConstGroup> and
3382     the local name of this resource is not defined.
3383     @@@RaiseException:
3384     @@@@@: RESERVED_PERL_METHOD_NAME_ERR
3385     @@@@enDesc:
3386     The Perl method name constructed from the source
3387     result in a reserved name.
3388     @@@PerlDef:
3389     __DEEP{
3390     if (exists $self->{<Q::dis2pm:name>}) {
3391     $r = $self->{<Q::dis2pm:name>};
3392     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3393     (<Q::ManakaiDOM:Const>) or
3394     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3395     (<Q::ManakaiDOM:ConstGroup>)) {
3396     $r = $self->{localName};
3397     unless (defined $r) {
3398     __UNDEEP{
3399     __EXCEPTION{NO_LOCAL_NAME_ERR::
3400     DIS:sourceNode => {$self->{src}},
3401     }__;
3402     }__;
3403     }
3404     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3405     (<Q::DISLang:Method>) or
3406     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3407     (<Q::DISLang:Attribute>)) {
3408     if (defined $self->{localName}) {
3409     $r = <ClassM::ManakaiDISImplementation.camelCaseToUnderscoreName>
3410     ($self->{localName});
3411     if ($self-><M::ManakaiDISPropertyAccessor.getPropertyBoolean>
3412     (<Q::ManakaiDOM:isForInternal>, false)) {
3413     $r = '_' . $r;
3414     }
3415     if ({
3416     import => 1,
3417     unimport => 1,
3418     isa => 1,
3419     can => 1,
3420     new => 1,
3421     as_string => 1,
3422     stringify => 1,
3423     clone => 1,
3424     }->{$r} or $r =~ /^___/) {
3425     __UNDEEP{
3426     __EXCEPTION{RESERVED_PERL_METHOD_NAME_ERR::
3427     DIS:uri => {$self->{uri}},
3428     DIS:soruceNode => {$self->{src}},
3429     DIS:generatedName => {$r},
3430     }__;
3431     }__;
3432 wakaba 1.11 }
3433     } elsif (my $op_uri = $self-><AG::ManakaiDISResourceDefinition
3434 wakaba 1.8 .plMethodOperator>) {
3435     $r = {
3436     <Q::ManakaiDOM:MUErrorHandler> => '___report_error',
3437     <Q::DISPerl:AsStringMethod> => 'as_string',
3438     <Q::DISPerl:AsNewMethod> => 'new',
3439     <Q::DISPerl:AsCloneMethod> => 'clone',
3440     }->{$op_uri};
3441     $r = $op_uri if $op_uri =~ /^[A-Z]+$/;
3442     } else {
3443     $r = null;
3444     }
3445     } else {
3446     $r = null;
3447     }
3448     $self->{<Q::dis2pm:name>} = $r;
3449     }__;
3450    
3451     @Attr:
3452     @@Name: plFullyQualifiedName
3453     @@enDesc:
3454     The fully-qualified Perl name of this resource.
3455     @@Type:
3456     DISLang:String::ManakaiDOM:all
3457     @@Get:
3458     @@@enDesc:
3459     Fully-qualified name.
3460     \
3461     - <Q::ManakaiDOM:Class>::: Class package name.
3462     \
3463     - <Q::ManakaiDOM:IF>::: Interface package name.
3464     \
3465     - <Q::DISPerl:ScalarVariable>::: Variable name (without variable
3466     type symbol such as <CODE::$>).
3467     @@@nullCase:
3468     @@@@enDesc:
3469     Otherwise.
3470     @@@NoPerlModuleNameException:
3471     @@@RaiseException:
3472     @@@@@: NO_LOCAL_NAME_ERR
3473     @@@@enDesc:
3474     The local name of this resource is not defined.
3475     @@@PerlDef:
3476     __DEEP{
3477     if (exists $self->{<Q::dis2pm:name>}) {
3478     $r = $self->{<Q::dis2pm:name>};
3479     } elsif ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3480     (<Q::ManakaiDOM:Class>) or
3481     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3482     (<Q::ManakaiDOM:IF>) or
3483     $self-><M::ManakaiDISResourceDefinition.isTypeURI>
3484     (<Q::DISPerl:ScalarVariable>)) {
3485     my $an_node = $self->{src}-><AG::ManakaiDISElement.disGetAttribute>
3486     (<Q::dis:AppName>, for_arg => $self->{for},
3487     forp_arg => $self->{forp},
3488     media_type => <Q::lang:Perl>);
3489     if ($an_node) {
3490     ## NOTE: "lang:Perl" is fully-qualified name by definition
3491     $r = $an_node-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3492     } else {
3493 wakaba 1.10 unless (defined $self->{localName}) {
3494     __UNDEEP{
3495     __EXCEPTION{NO_LOCAL_NAME_ERR::
3496     DIS:sourceNode => {$self->{src}},
3497     }__;
3498     }__;
3499     }
3500 wakaba 1.8 if ($self-><M::ManakaiDISResourceDefinition.isTypeURI>
3501     (<Q::ManakaiDOM:IF>)) {
3502     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3503     -><M::ManakaiDISModuleDefinition.plInterfaceName>
3504     . '::' . $self->{localName};
3505     } else {
3506     $r = $self-><AG::ManakaiDISResourceDefinition.definingModule>
3507     -><M::ManakaiDISModuleDefinition.plFullyQualifiedName>
3508     . '::' . $self->{localName};
3509     }
3510     }
3511     } else {
3512     $r = null;
3513     }
3514     $self->{<Q::dis2pm:name>} = $r;
3515     }__;
3516    
3517     @Attr:
3518     @@Name: plMethodOperator
3519     @@enDesc:
3520     The operator to overload by this method.
3521     @@Type:
3522     DISLang:String::ManakaiDOM:all
3523     @@Get:
3524     @@@enDesc:
3525     The operator, either Perl <CODE::use operator> operator name
3526     of manakai operator URI reference.
3527     @@@nullCase:
3528     @@@@enDesc:
3529     Either this resource does not define a Perl method or
3530     this method does not overload any operator.
3531     @@@UndeclaredPrefixException:
3532     @@@RaiseException:
3533     @@@@@: UNSUPPORTED_MEDIA_TYPE_ERR
3534     @@@@enDesc:
3535     Media type of the <Q::dis:Operator> node is not supported.
3536     @@@PerlDef:
3537     __DEEP{
3538     if (exists $self->{<Q::dis:Operator>}) {
3539     $r = $self->{<Q::dis:Operator>};
3540     } else {
3541     my $op_node = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3542     (<Q::dis:Operator>, for_arg => $self->{for},
3543     forp_arg => $self->{forp});
3544     if ($op_node) {
3545     if ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3546     (<Q::lang:Perl>)) {
3547     $r = $op_node-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3548     } elsif ($op_node-><M::ManakaiDISElement.mediaTypeMatch>
3549     (<Q::dis:TypeQName>)) {
3550     $r = $op_node-><AG::ManakaiDISElement.qnameValueURI>;
3551     } else {
3552 wakaba 1.10 my $ct_uri = $op_node-><M::ManakaiDISElement.mediaTypeURI>
3553     (for_arg => $self->{for},
3554     forp_arg => $self->{forp});
3555 wakaba 1.8 __UNDEEP{
3556     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3557     DIS:uri => {$ct_uri},
3558 wakaba 1.10 DIS:sourceNode => {$op_node},
3559 wakaba 1.8 }__;
3560     }__;
3561     }
3562     } else {
3563     $r = null;
3564     }
3565     $self->{<Q::dis:Operator>} = $r;
3566     }
3567     }__;
3568    
3569     @Attr:
3570     @@Name: disDataTypeResource
3571     @@enDesc:
3572     <Q::dis:Type> attribute value of this resource.
3573     @@Type: ManakaiDISResourceDefinition
3574     @@Get:
3575     @@@RaiseException:
3576     @@@@@:NO_DIS_TYPE_ERR
3577     @@@@enDesc:
3578     <Q::dis:Type> attribute is not specified.
3579     @@@PerlDef:
3580     __DEEP{
3581     if (defined $self->{<Q::dis:Type>}) {
3582     $r = $self->{<Q::dis:Type>};
3583     } else {
3584     $self->{<Q::dis2pm:TypeNode>}
3585     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3586     (<Q::dis:Type>, for_arg => $self->{for},
3587     forp_arg => $self->{forp});
3588     if ($self->{<Q::dis2pm:TypeNode>}) {
3589     $r = $self->{<Q::dis:Type>}
3590     = $self->{<Q::dis2pm:TypeNode>}
3591     -><AG::ManakaiDISElement.qnameValueURI>;
3592     } else {
3593     my $pr = $self-><M::ManakaiDISPropertyAccessor
3594     .getPropertyResource>
3595     (<Q::DIS:dynamicParentResource>);
3596     if ($pr) {
3597     $r = $pr-><AG::ManakaiDISResourceDefinition
3598     .disDataTypeResource>;
3599     $self->{<Q::dis2pm:TypeNode>}
3600     = $pr->{<Q::dis2pm:TypeNode>};
3601     } else { ## No parent
3602     __UNDEEP{
3603     __EXCEPTION{NO_DIS_TYPE_ERR::
3604     DIS:sourceNode => {$self->{src}},
3605     }__;
3606     }__;
3607     }
3608     }
3609     }
3610     }__;
3611    
3612     @Attr:
3613     @@Name: disDataTypeNode
3614     @@enDesc:
3615     <Q::dis:Type> node for this resource.
3616     @@Get:
3617     @@@Type: ManakaiDISElement
3618     @@@RaiseException:
3619     @@@@@:NO_DIS_TYPE_ERR
3620     @@@@enDesc:
3621     <Q::dis:Type> attribute is not specified.
3622     @@@PerlDef:
3623     __DEEP{
3624     $self-><AG::ManakaiDISResourceDefinition.disDataTypeNode>;
3625     }__;
3626     $r = $self->{<Q::dis2pm:TypeNode>};
3627    
3628     @Attr:
3629     @@Name: disActualDataTypeResource
3630     @@enDesc:
3631     <Q::dis:actualType> attribute value of this resource.
3632     @@Type: ManakaiDISResourceDefinition
3633     @@Get:
3634     @@@RaiseException:
3635     @@@@@:NO_DIS_TYPE_ERR
3636     @@@@enDesc:
3637     <Q::dis:actualType> attribute is not specified,
3638     and <Q::dis:Type> attribute, neigher.
3639     @@@PerlDef:
3640     __DEEP{
3641     if (defined $self->{<Q::dis:actualType>}) {
3642     $r = $self->{<Q::dis:actualType>};
3643     } else {
3644     $self->{<Q::dis2pm:actualTypeNode>}
3645     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3646     (<Q::dis:actualType>, for_arg => $self->{for},
3647     forp_arg => $self->{forp});
3648     if ($self->{<Q::dis2pm:actualTypeNode>}) {
3649     $r = $self->{<Q::dis:actualType>}
3650     = $self->{<Q::dis2pm:actualTypeNode>}
3651     -><AG::ManakaiDISElement.qnameValueURI>;
3652     } elsif (defined $self->{<Q::dis:Type>}) {
3653     $r = $self->{<Q::dis:actualType>} = $self->{<Q::dis:Type>};
3654     $self->{<Q::dis2pm:actualTypeNode>}
3655     = $self->{<Q::dis2pm:TypeNode>};
3656     } else {
3657     $self->{<Q::dis2pm:actualTypeNode>}
3658     = $self->{<Q::dis2pm:TypeNode>}
3659     = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3660     (<Q::dis:Type>, for_arg => $self->{for},
3661     forp_arg => $self->{forp});
3662     if ($self->{<Q::dis2pm:TypeNode>}) {
3663     $r = $self->{<Q::dis:actualType>}
3664     = $self->{<Q::dis:Type>}
3665     = $self->{<Q::dis2pm:TypeNode>}
3666     -><AG::ManakaiDISElement.qnameValueURI>;
3667     } else {
3668     my $pr = $self-><M::ManakaiDISPropertyAccessor
3669     .getPropertyResource>
3670     (<Q::DIS:dynamicParentResource>);
3671     if ($pr) {
3672     $r = $self->{<Q::dis:actualType>}
3673     = $pr-><AG::ManakaiDISResourceDefinition
3674     .disActualDataTypeResource>;
3675     $self->{<Q::dis2pm:actualTypeNode>}
3676     = $pr->{<Q::dis2pm:actualTypeNode>};
3677     } else { ## No parent
3678     __UNDEEP{
3679     __EXCEPTION{NO_DIS_TYPE_ERR::
3680     DIS:sourceNode => {$self->{src}},
3681     }__;
3682     }__;
3683     }
3684     }
3685     }
3686     }
3687     }__;
3688    
3689     @Attr:
3690     @@Name: disActualDataTypeNode
3691     @@enDesc:
3692     <Q::dis:actualType> node for this resource.
3693     @@Get:
3694     @@@Type: ManakaiDISElement
3695     @@@RaiseException:
3696     @@@@@:NO_DIS_TYPE_ERR
3697     @@@@enDesc:
3698     <Q::dis:actualType> attribute is not specified,
3699     and <Q::dis:Type> attribute, neigher.
3700     @@@PerlDef:
3701     __DEEP{
3702     $self-><AG::ManakaiDISResourceDefinition.disActualDataTypeNode>;
3703     }__;
3704     $r = $self->{<Q::dis2pm:actualTypeNode>};
3705 wakaba 1.9
3706     @IntMethod:
3707     @@Operator:
3708     @@@@: <=>
3709     @@@ContentType:
3710     lang:Perl
3711     @@enDesc:
3712     Which is greater (i.e. the spaceship operator).
3713     A resource is less than another if it is loaded by
3714     <M::ManakaiDISDatabase.loadResource> before another is loaded.
3715     Order for non-loaded resource definitions are not defined.
3716     \
3717     {NOTE:: In the current implementation, non-loaded resources
3718     are less than any loaded resource and the order in
3719     non-loaded resources is unknown.
3720     \
3721     }
3722     @@Param:
3723     @@@Name: anotherResource
3724     @@@Type: ManakaiDISResourceDefinition
3725     @@@enDesc: Another resource to compare.
3726     @@Return:
3727     @@@Type:
3728     DOMMain:unsigned-long
3729     @@@PerlDef:
3730     if (UNIVERSAL::isa ($anotherResource,
3731     <ClassName::ManakaiDISResourceDefinition>)) {
3732     $r = $self->{seq} <=> $anotherResource->{seq};
3733     } else {
3734     $r = overload::Overloaded ($self) <=> $anotherResource;
3735     }
3736 wakaba 1.2 ##DISResourceDefinition
3737    
3738 wakaba 1.8 XParamDef:
3739     @QName: generatedName
3740     @enDesc:
3741     A generated name.
3742    
3743 wakaba 1.2 ClsDef:
3744     @ClsQName: ManakaiDISPropertyAccessor
3745 wakaba 1.3 @enDesc:
3746 wakaba 1.2 Accessor methods for resource or module properties.
3747    
3748     @Method:
3749 wakaba 1.8 @@Name: getPropertyBoolean
3750     @@enDesc:
3751     Gets boolean property value.
3752     @@PropNameParam:
3753     @@Param:
3754     @@@Name:default
3755     @@@Type:
3756     DOMMain:boolean::ManakaiDOM:all
3757     @@@enDesc:
3758     The default value that is returned if no explicit property
3759     value specification found for this resource.
3760     @@Return:
3761     @@@Type:
3762     DOMMain:boolean::ManakaiDOM:all
3763     @@@enDesc:
3764     The property value.
3765     @@@PerlDef:
3766     if (exists $self->{$propName}) {
3767     $r = defined $self->{$propName} ? $self->{$propName} : $default;
3768     } elsif ($self->{src}) {
3769     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3770     ($propName, for_arg => $self->{for},
3771     forp_arg => $self->{forp});
3772     $self->{$propName} = $r;
3773     $r = $default unless defined $r;
3774     } else {
3775     $r = $default;
3776     }
3777    
3778     @Method:
3779 wakaba 1.2 @@Name: getPropertyText
3780     @@enDesc:
3781     Gets property value text.
3782     @@PropNameParam:
3783     @@Param:
3784     @@@Name:default
3785     @@@Type:
3786 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
3787 wakaba 1.2 @@@enDesc:
3788     The default value that is returned if no explicit property
3789     value specification found for this resource.
3790     @@@nullCase:
3791     @@@@enDesc:
3792     No default value supplied; <DOM::null> is returned if
3793     no value specified.
3794     @@Return:
3795     @@@Type:
3796 wakaba 1.3 swcfg21:SWCFGString::swcfg21:ForLatest
3797 wakaba 1.2 @@@enDesc:
3798     The property value string.
3799     @@@nullCase:
3800     @@@@enDesc:
3801     No value nor default value has specified.
3802     @@@PerlDef:
3803     if (exists $self->{$propName}) {
3804     $r = defined $self->{$propName} ? $self->{$propName} : $default;
3805     } elsif ($self->{src}) {
3806     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3807     ($propName, for_arg => $self->{for},
3808     forp_arg => $self->{forp});
3809 wakaba 1.8 if ($r) {
3810     $r = $self->{$propName}
3811     = $r-><AG::swcfg21:SWCFGNode::swcfg21:ForLatest.value>;
3812     $r = $default unless defined $r;
3813     } else {
3814     $r = $default;
3815     $self->{$propName} = null;
3816     }
3817 wakaba 1.2 } else {
3818     $r = $default;
3819     }
3820    
3821     @Method:
3822     @@Name: getPropertyResource
3823     @@enDesc:
3824     Gets property value resource.
3825     @@PropNameParam:
3826 wakaba 1.10 @@NamedParam:
3827     @@@Name: defaultMediaType
3828     @@@Type: ResourceURI
3829     @@@enDesc:
3830     The URI reference of the default media type which is used
3831     when the property value is retrieved from the source tree
3832     and the source tree element does not have its <Q::dis:ContentType>
3833     attribute specified.
3834     @@@nullCase:
3835     @@@@enDesc:
3836     Defaulted to <Q::dis:TypeQName>.
3837 wakaba 1.2 @@Return:
3838     @@@Type: ManakaiDISResourceDefinition
3839     @@@enDesc:
3840     The property value resource.
3841     @@@nullCase:
3842     @@@@enDesc:
3843     No value has specified.
3844 wakaba 1.8 @@@UndeclaredPrefixException:
3845 wakaba 1.2 @@@PerlDef:
3846     if (defined $self->{$propName}) {
3847 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
3848     ($self->{$propName});
3849 wakaba 1.8 } elsif ($self->{src}) {
3850     __DEEP{
3851     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
3852     ($propName, for_arg => $self->{for},
3853     forp_arg => $self->{forp});
3854     if ($r) {
3855 wakaba 1.10 $defaultMediaType = <Q::dis:TypeQName>
3856     unless defined $defaultMediaType;
3857     if ($r-><M::ManakaiDISElement.mediaTypeMatch>
3858     (<Q::dis:TypeQName>, $defaultMediaType)) {
3859     $self->{$propName}
3860     = $r-><AG::ManakaiDISElement.qnameValueURI>;
3861     } elsif ($r-><M::ManakaiDISElement.mediaTypeMatch>
3862     (<Q::dis:TFQNames>, $defaultMediaType)) {
3863     $self->{$propName}
3864     = $r-><M::ManakaiDISElement.tfqnamesValueURI>
3865     ($self->{src}-><AG::swcfg21:SWCFGNode
3866     ::swcfg21:ForLatest.nodeID>,
3867     $self->{for});
3868     } else {
3869     my $mt = $r-><M::ManakaiDISElement.mediaTypeURI>
3870     (for_arg => $self->{for},
3871     forp_arg => $self->{forp});
3872     __UNDEEP{
3873     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3874     DIS:uri => {$mt},
3875     DIS:sourceNode => {$r},
3876     }__;
3877     }__;
3878     }
3879 wakaba 1.9 $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
3880     ($self->{$propName});
3881     $r-><M::ManakaiDISResourceDefinition.isReferred> ($self->{src});
3882 wakaba 1.8 }
3883     }__;
3884 wakaba 1.2 }
3885    
3886     @Method:
3887 wakaba 1.10 @@Name: getPropertyResourceList
3888     @@enDesc:
3889     Gets property value resource list.
3890     @@PropNameParam:
3891     @@NamedParam:
3892     @@@Name: recursiveISA
3893     @@@Type:
3894     DOMMain:boolean
3895     @@@enDesc:
3896     Whether property resource values of <Q::dis:ISA> resources
3897     of this resource should also be included to the returned list or not.
3898     @@NamedParam:
3899     @@@Name: defaultMediaType
3900     @@@Type: ResourceURI
3901     @@@enDesc:
3902     The URI reference of the default media type which is used
3903     when the property value is retrieved from the source tree
3904     and the source tree element does not have its <Q::dis:ContentType>
3905     attribute specified.
3906     @@@nullCase:
3907     @@@@enDesc:
3908     Defaulted to <Q::dis:TypeQName>.
3909     @@Return:
3910     @@@Type: ResourceList
3911     @@@enDesc:
3912     An array reference of the property value resources.
3913     \
3914     {NOTE:: This list is <QUOTE::dead>.
3915     \
3916     }
3917     @@@UndeclaredPrefixException:
3918     @@@PerlDef:
3919     $r = [];
3920     if (defined $self->{$propName}) {
3921     for my $res_uri (@{ref $self->{$propName} eq 'ARRAY'
3922     ? $self->{$propName} : []}) {
3923     push @$r,
3924     $self->{db}-><M::ManakaiDISDatabase.getResource> ($res_uri);
3925     }
3926     } elsif ($self->{src}) {
3927     __DEEP{
3928     $self->{$propName} = [];
3929     $defaultMediaType = <Q::dis:TypeQName>
3930     unless defined $defaultMediaType;
3931     for my $res_name_node
3932     (@{$self->{src}-><M::ManakaiDISElement.disGetAttributeList>
3933     ($propName, for_arg => $self->{for},
3934     forp_arg => $self->{forp})}) {
3935     my $res_uri;
3936     if ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
3937     (<Q::dis:TypeQName>, $defaultMediaType)) {
3938     $res_uri = $res_name_node-><AG::ManakaiDISElement.qnameValueURI>;
3939     } elsif ($res_name_node-><M::ManakaiDISElement.mediaTypeMatch>
3940     (<Q::dis:TFQNames>, $defaultMediaType)) {
3941     $res_uri =$res_name_node-><M::ManakaiDISElement.tfqnamesValueURI>
3942     ($self->{src}-><AG::swcfg21:SWCFGNode
3943     ::swcfg21:ForLatest.nodeID>,
3944     $self->{for});
3945     } else {
3946     my $mt = $res_name_node-><M::ManakaiDISElement.mediaTypeURI>
3947     (for_arg => $self->{for},
3948     forp_arg => $self->{forp});
3949     __UNDEEP{
3950     __EXCEPTION{UNSUPPORTED_MEDIA_TYPE_ERR::
3951     DIS:uri => {$mt},
3952     DIS:sourceNode => {$res_name_node},
3953     }__;
3954     }__;
3955     }
3956     push @{$self->{$propName}}, $res_uri;
3957     my $res = $self->{db}-><M::ManakaiDISDatabase.getResource>
3958     ($res_uri);
3959     push @$r, $res;
3960     $res-><M::ManakaiDISResourceDefinition.isReferred>
3961     ($res_name_node);
3962     }
3963     }__;
3964     }
3965     if ($recursiveISA) {
3966     __DEEP{
3967     $opt{___recursive_isa_done} ||= {$self->{uri} => true};
3968     my @p_res = @$r;
3969     for my $p_res (@p_res) {
3970     next if $opt{___recursive_isa_done}->{$p_res->{uri}};
3971     $opt{___recursive_isa_done}->{$p_res->{uri}} = true;
3972     push @$r, @{$p_res-><M::ManakaiDISPropertyAccessor
3973     .getPropertyResourceList>
3974     (<Q::dis:ISA>, recursive_isa => true,
3975     ___recursive_isa_done => $opt{___recursive_isa_done},
3976     default_media_type => $defaultMediaType)};
3977     }
3978     }__;
3979     }
3980    
3981     @Method:
3982 wakaba 1.2 @@Name: addPropertyResourceList
3983     @@enDesc:
3984     Adds a resource to a resource-list property value.
3985     \
3986     {ISSUE:: Should an exception be thrown if the property is
3987     not of list?
3988     \
3989     }
3990 wakaba 1.10 \
3991     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
3992     an item clears the list --- i.e. the property values
3993     in the source tree will be ignored. Call
3994     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
3995     before adding to avoid this behavior.
3996     \
3997     }
3998 wakaba 1.2 @@PropNameParam:
3999     @@Param:
4000     @@@Name: res
4001     @@@Type: ManakaiDISResourceDefinition
4002     @@@enDesc:
4003     A resource to add.
4004     @@Return:
4005     @@@PerlDef:
4006     if (ref $self->{$propName} eq 'ARRAY') {
4007     push @{$self->{$propName}}, $res->{uri};
4008     } elsif (not defined $self->{$propName}) {
4009     $self->{$propName} = [$res->{uri}];
4010     }
4011    
4012 wakaba 1.3 ElementTypeBinding:
4013     @Name: PropNameParam
4014     @ElementType:
4015     dis:ResourceDef
4016     @ShadowContent:
4017     @@rdf:type:
4018     DISLang:MethodParameter
4019     @@Name: propName
4020     @@Type: ResourceURI
4021     @@Description:
4022     @@@lang:en
4023     @@@@:
4024     The name of the property.
4025    
4026 wakaba 1.2 ##DISPropertyAccessor
4027    
4028     PropDef:
4029     @QName:isAnon
4030     @Description:
4031     @@lang:en
4032     @@@:
4033     Whether the subject resource is anonymous or not.
4034     @Type:
4035     DOMMain:boolean
4036    
4037     PropDef:
4038     @QName:isDefined
4039     @Description:
4040     @@lang:en
4041     @@@:
4042     Whether the subject resource is defined or not.
4043    
4044     PropDef:
4045 wakaba 1.3 @QName:isReferred
4046 wakaba 1.2 @Description:
4047     @@lang:en
4048     @@@:
4049     Whether the subject resource is referred or not.
4050     @Type:
4051     DOMMain:any
4052    
4053     PropDef:
4054     @QName:definingModule
4055     @Description:
4056     @@lang:en
4057     @@@:
4058     The <QUOTE::dis> module in which the subject resource is defined.
4059     @rdfs:domain:
4060     DISCore:Module
4061 wakaba 1.1
4062     ## -- Datatypes
4063    
4064     URITypeDef:
4065 wakaba 1.3 @QName: AnyURI
4066     @Description:
4067     @@lang:en
4068     @@@:
4069     Any URI references.
4070    
4071     URITypeDef:
4072     @QName: FileURI
4073     @enDesc:
4074     URI references identifying file.
4075    
4076     URITypeDef:
4077 wakaba 1.1 @QName: ForURI
4078     @Description:
4079     @@lang:en
4080     @@@:
4081     <QUOTE::For> URI references.
4082    
4083     DataTypeDef:
4084     @QName: ForURIList
4085     @Description:
4086     @@lang:en
4087     @@@:
4088     References to the array containing <QUOTE::for> URI references.
4089    
4090     URITypeDef:
4091 wakaba 1.3 @QName: ResourceURI
4092     @Description:
4093     @@lang:en
4094     @@@:
4095     A URI reference for a <QUOTE::dis> resource.
4096    
4097     URITypeDef:
4098 wakaba 1.1 @QName: MediaTypeURI
4099     @Description:
4100     @@lang:en
4101     @@@:
4102     Media type URI references.
4103 wakaba 1.3 @rdfs:subClassOf: ResourceURI
4104    
4105     URITypeDef:
4106     @QName: ModuleURI
4107     @enDesc:
4108     URI references for <QUOET::dis> modules.
4109     @rdfs:subClassOf: ResourceURI
4110    
4111     URITypeDef:
4112     @QName: NameURI
4113     @enDesc:
4114     URI references identifying a resource.
4115     @rdfs:subClassOf: ResourceURI
4116 wakaba 1.10
4117     DataTypeDef:
4118     @QName: ResourceList
4119     @enDesc:
4120     References to array containing resource definition objects.
4121     @rdfs:subClassOf:
4122     Perl:ARRAY::ManakaiDOM:all
4123 wakaba 1.3
4124     ElementTypeBinding:
4125     @Name: DataTypeDef
4126     @ElementType:
4127     dis:ResourceDef
4128     @ShadowContent:
4129     @@rdf:type:
4130     ManakaiDOM:DataType
4131    
4132     ElementTypeBinding:
4133     @Name: URITypeDef
4134     @ElementType:
4135     dis:ResourceDef
4136     @ShadowContent:
4137     @@rdf:type:
4138     ManakaiDOM:DataType
4139     @@rdfs:subClassOf: AnyURI
4140 wakaba 1.1
4141     ## -- Exceptions
4142    
4143     XParamDef:
4144     @QName: sourceNode
4145     @Description:
4146     @@lang:en
4147     @@@:
4148 wakaba 1.4 The node in which an error has occurred.
4149 wakaba 1.5 @Type: ManakaiDISNode
4150    
4151     XParamDef:
4152     @QName: anotherSourceNode
4153     @enDesc:
4154     Another source node in which an error has occurred. In cases
4155     of <QUOTE::already defined> errors, it is the node that
4156     defines the resource first.
4157     @Type: ManakaiDISNode
4158 wakaba 1.3
4159     ExceptionDef:
4160     @ClsQName: ManakaiDISException
4161     @enDesc:
4162     Exceptions for the <QUOTE::dis> operations.
4163 wakaba 1.4 @ClsISA:
4164     ManakaiDOM:ManakaiDOMException::ManakaiDOM:Perl
4165 wakaba 1.3 @XConstGroupDef:
4166     @@ClsQName: ManakaiDISExceptionCode
4167     @@enDesc:
4168     Exception codes for <Class::ManakaiDISException>.
4169     @@XConstDef:
4170 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
4171     @@@Value:3
4172     @@@enDesc:
4173     An attempt is made to break the hierarchy.
4174     @@@XSubTypeDef:
4175     @@@@QName: MERGE_ITSELF_ERR
4176     @@@@enDesc:
4177     An attempt is made to merge the resource to itself.
4178     @@@@XSourceNodeParam:
4179     @@@@XParam:
4180     @@@@@QName:uri
4181     @@@@@enDesc:
4182     The URI reference of the resource to merge.
4183     @@@@enMufDef:
4184     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
4185     );> to itself
4186     @@XConstDef:
4187 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
4188     @@@Value:9
4189     @@@enDesc:
4190     An attempt is made to do something the implementation does not support.
4191     @@@XSubTypeDef:
4192     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
4193     @@@@enDesc:
4194     The implementation does not support the media type.
4195     @@@@XParam:
4196     @@@@@QName: uri
4197     @@@@@enDesc:
4198     The URI reference of the media type that is not supported.
4199     @@@@XSourceNodeParam:
4200     @@XConstDef:
4201 wakaba 1.3 @@@Name: NAMESPACE_ERR
4202     @@@Value:14
4203     @@@enDesc:
4204     An error related to namespaces has occurred.
4205     @@@XSubTypeDef:
4206     @@@@QName: UNDECLARED_NS_PREFIX_ERR
4207     @@@@enDesc:
4208     The implementation has encounted an undeclared namespace
4209     prefix.
4210 wakaba 1.7 @@@@XParam:
4211     @@@@@QName:
4212     infoset:prefix
4213     @@@@@enDesc:
4214     The namespace prefix.
4215     @@@@enMufDef:
4216     Namespace prefix "%p (name => {<Q::infoset:prefix>});" is
4217     not declared
4218 wakaba 1.3 @@XConstDef:
4219     @@@Name: INVALID_STATE_ERR
4220     @@@Value:11
4221     @@@enDesc:
4222     An attempt is made to use an object that is not (or no longer) usable.
4223     @@@XSubTypeDef:
4224     @@@@QName: NO_ASSOCIATED_DB_ERR
4225     @@@@enDesc:
4226     No <QUOTE::dis> database has been associated with this document.
4227 wakaba 1.4 @@XConstDef:
4228     @@@Name: INVALID_SOURCE_ERR
4229     @@@Value: 200
4230     @@@enDesc:
4231     The source input is well-formed but invalid.
4232     @@@XSubTypeDef:
4233     @@@@QName: NO_MODULE_QNAME_ERR
4234     @@@@enDesc:
4235     The <Q::dis:Module> element must have its <Q::dis:QName>
4236     attribute.
4237 wakaba 1.8 @@@@XSourceNodeParam:
4238     @@@XSubTypeDef:
4239     @@@@QName: NO_LOCAL_NAME_ERR
4240     @@@@enDesc:
4241     The resource does not have a local name.
4242     @@@@XSourceNodeParam:
4243 wakaba 1.4 @@@XSubTypeDef:
4244     @@@@QName: UNABLE_TO_GET_MODULE_ERR
4245     @@@@enDesc:
4246     The implementation is unable to get the module source.
4247     @@@@Def:
4248     @@@@@ContentType:
4249     lang:muf
4250     @@@@@lang:en
4251     @@@@@@:
4252     Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
4253     @@@@XParam:
4254     @@@@@QName: uri
4255     @@@@@enDesc:
4256     The URI reference of the module.
4257     @@@@XParam:
4258     @@@@@QName: namespaceURI
4259     @@@@@enDesc:
4260     The namespace URI of the module name.
4261     @@@@XParam:
4262     @@@@@QName: localName
4263     @@@@@enDesc:
4264     The local name of the module name.
4265     @@@@XParam:
4266     @@@@@QName: for
4267     @@@@@enDesc:
4268     The <QUOTE::for> of the module.
4269 wakaba 1.5 @@@XSubTypeDef:
4270     @@@@QName: NO_FOR_QNAME_ERR
4271     @@@@enDesc:
4272     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
4273     @@@@XSourceNodeParam:
4274     @@@XSubTypeDef:
4275     @@@@QName: FOR_ALREADY_DEFINED_ERR
4276     @@@@enDesc:
4277     The <QUOTE::for> named as the same URI reference has
4278     already defined.
4279     @@@@XSourceNodeParam:
4280     @@@@XParam:
4281     @@@@@QName: anotherSourceNode
4282     @@@@@enDesc:
4283     The node that defines the <QUOTE::for> URI reference before.
4284 wakaba 1.7 @@@@XParam:
4285     @@@@@Name: uri
4286     @@@@@enDesc:
4287     The URI reference of the <QUOTE::for> attempted to define.
4288     @@@@enMufDef:
4289     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
4290 wakaba 1.5 @@@XSubTypeDef:
4291     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
4292     @@@@enDesc:
4293     The <QUOTE::dis> resource named as the same URI reference has
4294     already defined.
4295     @@@@XSourceNodeParam:
4296     @@@@XParam:
4297     @@@@@QName: anotherSourceNode
4298     @@@@@enDesc:
4299     The node that defines the <QUOTE::for> URI reference before.
4300 wakaba 1.7 @@@@XParam:
4301     @@@@@Name: uri
4302     @@@@@enDesc:
4303     The URI reference of the resource attempted to define.
4304     @@@@enMufDef:
4305     Resource <%p (name => {<Q::DIS:uri>});> is already defined
4306 wakaba 1.5 @@@XSubTypeDef:
4307     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
4308     @@@@enDesc:
4309     An element has occured where it is not allowed.
4310     @@@@enMufDef:
4311     Module <%p (name => {<Q::DIS:uri>});>:
4312     Element of type <%p (name => {<Q::DIS:elementType>});>
4313     is not allowed here
4314     @@@@XSourceNodeParam:
4315     @@@@XParam:
4316     @@@@@QName: elementType
4317     @@@@@enDesc:
4318     The expanded element type name of the element.
4319     @@@@XParam:
4320     @@@@@QName: uri
4321     @@@@@enDesc:
4322     The URI reference of the module.
4323 wakaba 1.7 @@@XSubTypeDef:
4324     @@@@QName: NO_REQUIRED_ATTR_ERR
4325     @@@@enDesc:
4326     A required attribute is not specified.
4327     @@@@XSourceNodeParam:
4328     @@@@XParam:
4329     @@@@@QName: elementType
4330     @@@@@enDesc:
4331     The expanded URI reference of the attribute name.
4332     @@@@enMufDef:
4333     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
4334 wakaba 1.8 @@@XSubTypeDef:
4335     @@@@QName: FOR_NOT_DEFINED_ERR
4336     @@@@enDesc:
4337     A <QUOTE::for> is referred but not defined.
4338     @@@@XSourceNodeParam:
4339     @@@@XParam:
4340     @@@@@QName: uri
4341     @@@@@enDesc:
4342     The URI reference of the <QUOTE::for> that is not defined.
4343     @@@@enMufDef:
4344     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
4345     @@@XSubTypeDef:
4346     @@@@QName: RESOURCE_NOT_DEFINED_ERR
4347     @@@@enDesc:
4348     A <QUOTE::dis> resource is referred but not defined.
4349     @@@@XSourceNodeParam:
4350     @@@@XParam:
4351     @@@@@QName: uri
4352     @@@@@enDesc:
4353     The URI reference of the resource that is not defined.
4354     @@@@enMufDef:
4355     Resource <%p (name => {<Q::DIS:uri>});> is not defined
4356     @@@XSubTypeDef:
4357     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
4358     @@@@enDesc:
4359     A reserved Perl method name is used.
4360     @@@@XParam:
4361     @@@@@QName:uri
4362     @@@@@enDesc:
4363     The URI reference of the method resource.
4364     @@@@XSourceNodeParam:
4365     @@@@XParam:
4366     @@@@@QName: generatedName
4367     @@@@@enDesc:
4368     A reserved method name.
4369     @@@XSubTypeDef:
4370     @@@@QName: NO_DIS_TYPE_ERR
4371     @@@@enDesc:
4372     <Q::dis:Type> attribute is not found.
4373     @@@@XSourceNodeParam:
4374 wakaba 1.4 ##DISException
4375 wakaba 1.5
4376     XParamDef:
4377     @QName: elementType
4378     @Type: ResourceURI
4379     @enDesc:
4380     The name of the element type.
4381    
4382     XParamDef:
4383     @QName: uri
4384     @Type: ResourceURI
4385     @enDesc:
4386     The name of the resource, composed from <Q::namespaceURI>,
4387     <Q::localName> and <Q::for>.
4388    
4389     XParamDef:
4390     @QName: localName
4391     @Type:
4392     DISCore:LocalName
4393     @enDesc:
4394     The local name of the resource, unique in <Q::namespaceURI> namespace.
4395    
4396     XParamDef:
4397     @QName: namespaceURI
4398     @Type: AnyURI
4399     @enDesc:
4400     The namespace URI reference of the resource name.
4401    
4402     XParamDef:
4403     @QName: for
4404     @Type: ForURI
4405     @enDesc:
4406     The <QUOTE::for> URI reference of the resource.
4407    
4408     ElementTypeBinding:
4409     @Name: XSourceNodeParam
4410     @ElementType:
4411     ManakaiDOM:exceptionOrWarningParameter
4412     @ShadowContent:
4413     @@QName: sourceNode
4414     @@Description:
4415     @@@lang:en
4416     @@@@:
4417     The node in which an error has occurred.
4418 wakaba 1.4
4419     ClsDef:
4420     @ClsQName: ManakaiDISExceptionTarget
4421     @enDesc:
4422     Objects that is able to be the target of an exception.
4423     @IntMethod:
4424     @@Operator:
4425     @@@@:
4426     ManakaiDOM:MUErrorHandler
4427     @@@ContentType:
4428     dis:TypeQName
4429     @@Description:
4430     @@@lang:en
4431     @@@@:
4432     This method is a generic error handler; all manakai exceptions
4433     and warnings associated to an object are once reported to this method
4434     and then delivered to appropriate entities.
4435     \
4436     If the error is an exception (such as <X::DOMCore:DOMException> or
4437     <X::ManakaiDOM:ManakaiDOMImplementationException>), it is
4438     simply thrown. If the error is only a warning, it is reported
4439     via the <IF::DOMCore:DOMError> interface.
4440     \
4441     See <PerlModule::Message::Util::Error> documentation for more
4442     information on the error reporting mechanism.
4443     \
4444     {NOTE:: This kind of methods are named as <Perl::___report_error>
4445     in the convention of <PerlModule::Message::Util::Error>.
4446     \
4447     }
4448     @@Param:
4449     @@@Name:err
4450     @@@Type:
4451     ManakaiDOM:ManakaiDOMExceptionOrWarning::ManakaiDOM:Perl
4452     @@@Description:
4453     @@@@lang:en
4454     @@@@@:
4455     An exception object that describes what kind of error it is
4456     and how it should be recovered.
4457     \
4458     {NOTE:: Exception objects in manakai implementation
4459     inherit the class <PerlModule::Message::Util::Error>,
4460     that in turn inherits <PerlModule::Error>.
4461     \
4462     }
4463     @@Return:
4464     @@@PerlDef:
4465     if ($err->isa (<ClassName::ManakaiDOM:ManakaiDOMException
4466     ::ManakaiDOM:Perl>)) {
4467     $err->throw;
4468     } else {
4469     \## TODO: Implement warning reporting
4470     warn $err->stringify;
4471     }
4472     ##DISExceptionTarget
4473    
4474     ForDef:
4475     @QName:
4476     DIS:ForIF
4477     ForDef:
4478     @QName:
4479     DIS:ForClass
4480    
4481     ElementTypeBinding:
4482     @Name: IFClsDef
4483     @ElementType:
4484     dis:ResourceDef
4485     @ShadowContent:
4486     @@rdf:type:
4487     @@@@:
4488     dis:MultipleResource
4489     @@@ForCheck: !ForClass !ForIF
4490     @@rdf:type:
4491     @@@@:
4492     ManakaiDOM:IF
4493     @@@ForCheck: ForIF
4494     @@rdf:type:
4495     @@@@:
4496     ManakaiDOM:Class
4497     @@@ForCheck: ForClass
4498     @@resourceFor: ForIF
4499     @@resourceFor:
4500     @@@@: ForClass
4501     @@@ForCheck: ForLatest
4502     @@DOMMain:implementFeature:
4503     @@@@:CoreFeature10
4504     @@@ForCheck: ForClass
4505     @@ForCheck:
4506     ManakaiDOM:Perl
4507 wakaba 1.3
4508     ElementTypeBinding:
4509     @Name: ClsDef
4510     @ElementType:
4511     dis:ResourceDef
4512     @ShadowContent:
4513     @@rdf:type:
4514     ManakaiDOM:Class
4515     @@AliasFor:
4516     @@@@:
4517 wakaba 1.11 ::DIS:ForLatest
4518 wakaba 1.3 @@@For:
4519 wakaba 1.11 !=DIS:ForLatest
4520 wakaba 1.3 @@ForCheck:
4521     ManakaiDOM:Perl
4522     @@DOMMain:implementFeature: CoreFeature10
4523    
4524     ElementTypeBinding:
4525     @Name: ExceptionDef
4526     @ElementType:
4527     dis:ResourceDef
4528     @ShadowContent:
4529     @@rdf:type:
4530     ManakaiDOM:ExceptionClass
4531     @@AliasFor:
4532     @@@@:
4533     ::ForLatest
4534     @@@For:
4535     !=ForLatest
4536     @@ForCheck:
4537     ManakaiDOM:Perl
4538     @@DOMMain:implementFeature: CoreFeature10
4539    
4540     ElementTypeBinding:
4541     @Name: ClsQName
4542     @ElementType:
4543     dis:QName
4544    
4545     ElementTypeBinding:
4546     @Name: ClsISA
4547     @ElementType:
4548     dis:ISA
4549    
4550     ElementTypeBinding:
4551     @Name: Method
4552     @ElementType:
4553     dis:ResourceDef
4554     @ShadowContent:
4555     @@rdf:type:
4556     DISLang:Method
4557    
4558     ElementTypeBinding:
4559     @Name: IntMethod
4560     @ElementType:
4561     dis:ResourceDef
4562     @ShadowContent:
4563     @@rdf:type:
4564     DISLang:Method
4565     @@ManakaiDOM:isForInternal:1
4566    
4567     ElementTypeBinding:
4568     @Name: Attr
4569     @ElementType:
4570     dis:ResourceDef
4571     @ShadowContent:
4572     @@rdf:type:
4573     DISLang:Attribute
4574    
4575     ElementTypeBinding:
4576     @Name: Return
4577     @ElementType:
4578     dis:ResourceDef
4579     @ShadowContent:
4580     @@rdf:type:
4581     DISLang:MethodReturn
4582    
4583     ElementTypeBinding:
4584     @Name: Get
4585     @ElementType:
4586     dis:ResourceDef
4587     @ShadowContent:
4588     @@rdf:type:
4589     DISLang:AttributeGet
4590    
4591     ElementTypeBinding:
4592     @Name: Set
4593     @ElementType:
4594     dis:ResourceDef
4595     @ShadowContent:
4596     @@rdf:type:
4597     DISLang:AttributeSet
4598    
4599     ElementTypeBinding:
4600     @Name: Param
4601     @ElementType:
4602     dis:ResourceDef
4603     @ShadowContent:
4604     @@rdf:type:
4605     DISLang:MethodParameter
4606    
4607     ElementTypeBinding:
4608     @Name: PerlDef
4609     @ElementType:
4610     dis:Def
4611     @ShadowContent:
4612     @@ContentType:
4613     lang:Perl
4614    
4615     ElementTypeBinding:
4616     @Name: disDef
4617     @ElementType:
4618     dis:Def
4619     @ShadowContent:
4620     @@ContentType:
4621     lang:dis
4622    
4623     ElementTypeBinding:
4624     @Name: InCase
4625     @ElementType:
4626     dis:ResourceDef
4627     @ShadowContent:
4628     @@rdf:type:
4629     ManakaiDOM:InCase
4630    
4631     ElementTypeBinding:
4632     @Name: nullCase
4633     @ElementType:
4634     dis:ResourceDef
4635     @ShadowContent:
4636     @@rdf:type:
4637     ManakaiDOM:InCase
4638     @@Value:
4639     @@@is-null:1
4640    
4641     ElementTypeBinding:
4642     @Name: TrueCase
4643     @ElementType:
4644     dis:ResourceDef
4645     @ShadowContent:
4646     @@rdf:type:
4647     ManakaiDOM:InCase
4648     @@Value:true
4649     @@Type:
4650     DOMMain:boolean
4651    
4652    
4653     ElementTypeBinding:
4654     @Name: FalseCase
4655     @ElementType:
4656     dis:ResourceDef
4657     @ShadowContent:
4658     @@rdf:type:
4659     ManakaiDOM:InCase
4660     @@Value:false
4661     @@Type:
4662     DOMMain:boolean
4663    
4664     ElementTypeBinding:
4665     @Name: enDesc
4666     @ElementType:
4667     dis:Description
4668     @ShadowContent:
4669     @@lang:en
4670    
4671     ElementTypeBinding:
4672     @Name: PropDef
4673     @ElementType:
4674     dis:ResourceDef
4675     @ShadowContent:
4676     @@rdf:type:
4677     rdf:Property
4678     @@AliasFor:
4679     @@@@:
4680     ::ManakaiDOM:all
4681     @@@For:
4682     !=ManakaiDOM:all
4683    
4684     ElementTypeBinding:
4685     @Name: MethodRedef
4686     @ElementType:
4687     dis:ResourceDef
4688     @ShadowContent:
4689     @@rdf:type:
4690     DISLang:Method
4691     @@ManakaiDOM:isRedefining:1
4692    
4693     ElementTypeBinding:
4694     @Name: NamedParam
4695     @ElementType:
4696     dis:ResourceDef
4697     @ShadowContent:
4698     @@rdf:type:
4699     DISLang:MethodParameter
4700     @@DISPerl:isNamedParameter:1
4701    
4702     ElementTypeBinding:
4703     @Name: NodeParam
4704     @ElementType:
4705     dis:ResourceDef
4706     @ShadowContent:
4707     @@rdf:type:
4708     DISLang:MethodParameter
4709     @@DISPerl:isNamedParameter:1
4710     @@Name: node
4711     @@Type: ManakaiDISNode
4712     @@Description:
4713     @@@lang:en
4714     @@@@:
4715     The node in which the name has occurred. It is intended
4716     to be reported when an exception had been raised.
4717     @@ResourceDef:
4718     @@@rdf:type:
4719     ManakaiDOM:InCase
4720     @@@Value:
4721     @@@@is-null:1
4722     @@@Description:
4723     @@@@lang:en
4724     @@@@@:
4725     The source of the name is not a node.
4726    
4727     ElementTypeBinding:
4728     @Name: ForParam
4729     @ElementType:
4730     dis:ResourceDef
4731     @ShadowContent:
4732     @@rdf:type:
4733     DISLang:MethodParameter
4734     @@DISPerl:isNamedParameter:1
4735     @@Name: forArg
4736     @@Type: ForURI
4737     @@Description:
4738     @@@lang:en
4739     @@@@:
4740     The <QUOTE::for> URI reference.
4741     @@ResourceDef:
4742     @@@rdf:type:
4743     ManakaiDOM:InCase
4744     @@@Value:
4745     @@@@is-null:1
4746     @@@Description:
4747     @@@@lang:en
4748     @@@@@:
4749     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
4750    
4751     ElementTypeBinding:
4752     @Name: ForpParam
4753     @ElementType:
4754     dis:ResourceDef
4755     @ShadowContent:
4756     @@rdf:type:
4757     DISLang:MethodParameter
4758     @@DISPerl:isNamedParameter:1
4759     @@Name: forpArg
4760     @@Type: ForURIList
4761     @@Description:
4762     @@@lang:en
4763     @@@@:
4764     An array reference containing additional <QUOTE::for>
4765     constraints (<QUOTE::For+> list).
4766     @@ResourceDef:
4767     @@@rdf:type:
4768     ManakaiDOM:InCase
4769     @@@Value:
4770     @@@@is-null:1
4771     @@@Description:
4772     @@@@lang:en
4773     @@@@@:
4774     Equivalent to the empty array reference.
4775    
4776     ElementTypeBinding:
4777     @Name: MediaTypeParam
4778     @ElementType:
4779     dis:ResourceDef
4780     @ShadowContent:
4781     @@rdf:type:
4782     DISLang:MethodParameter
4783     @@DISPerl:isNamedParameter:1
4784     @@Name: mediaType
4785     @@Type: MediaTypeURI
4786     @@Description:
4787     @@@lang:en
4788     @@@@:
4789     The URI reference identifying a media type.
4790     @@ResourceDef:
4791     @@@rdf:type:
4792     ManakaiDOM:InCase
4793     @@@Value:
4794     @@@@is-null:1
4795     @@@Description:
4796     @@@@lang:en
4797     @@@@@:
4798     No media type specified.
4799    
4800     ElementTypeBinding:
4801     @Name: MediaTypeDefaultParam
4802     @ElementType:
4803     dis:ResourceDef
4804     @ShadowContent:
4805     @@rdf:type:
4806     DISLang:MethodParameter
4807     @@DISPerl:isNamedParameter:1
4808     @@Name: defaultMediaType
4809     @@Type: MediaTypeURI
4810     @@Description:
4811     @@@lang:en
4812     @@@@:
4813     The default media type, i.e. the type used when no explicit
4814     specification is not found in the source tree.
4815     @@ResourceDef:
4816     @@@rdf:type:
4817     ManakaiDOM:InCase
4818     @@@Value:
4819     @@@@is-null:1
4820     @@@Description:
4821     @@@@lang:en
4822     @@@@@:
4823     Defaulted to <Q::DOMMain:any>.
4824    
4825     ElementTypeBinding:
4826     @Name: RaiseException
4827     @ElementType:
4828     ManakaiDOM:raises
4829    
4830     ElementTypeBinding:
4831     @Name: UndeclaredPrefixException
4832     @ElementType:
4833     ManakaiDOM:raises
4834     @ShadowContent:
4835     @@@: UNDECLARED_NS_PREFIX_ERR
4836     @@Description:
4837     @@@lang:en
4838     @@@@:
4839     The implementation has encounted an undeclared namespace prefix.
4840    
4841     ElementTypeBinding:
4842     @Name: NoDBException
4843     @ElementType:
4844     ManakaiDOM:raises
4845     @ShadowContent:
4846     @@@: NO_DB_ASSOCIATED_ERR
4847     @@Description:
4848     @@@lang:en
4849     @@@@:
4850     No <QUOTE::dis> database is associated to this document.
4851    
4852     ElementTypeBinding:
4853     @Name: XConstGroupDef
4854     @ElementType:
4855     dis:ResourceDef
4856     @ShadowContent:
4857     @@rdf:type:
4858     ManakaiDOM:ConstGroup
4859     @@Type:
4860     DOMMain:unsigned-short::ManakaiDOM:all
4861     @@rdfs:subClassOf:
4862     DOMMain:unsigned-short::ManakaiDOM:all
4863    
4864     ElementTypeBinding:
4865     @Name: XConstDef
4866     @ElementType:
4867     dis:ResourceDef
4868     @ShadowContent:
4869     @@rdf:type:
4870     ManakaiDOM:Const
4871    
4872     ElementTypeBinding:
4873     @Name: XSubTypeDef
4874     @ElementType:
4875     dis:ResourceDef
4876     @ShadowContent:
4877     @@rdf:type:
4878     ManakaiDOM:ExceptionOrWarningSubType
4879    
4880     ElementTypeBinding:
4881     @Name: XParam
4882     @ElementType:
4883     ManakaiDOM:exceptionOrWarningParameter
4884    
4885     ElementTypeBinding:
4886     @Name: XParamDef
4887     @ElementType:
4888     dis:ResourceDef
4889     @ShadowContent:
4890     @@rdf:type:
4891     DOMMain:XWParameter
4892     @@AliasFor:
4893     @@@For:
4894     !=ManakaiDOM:all
4895     @@@@:
4896     ::ManakaiDOM:all
4897    
4898     ElementTypeBinding:
4899     @Name: enMufDef
4900     @ElementType:
4901     dis:Def
4902     @ShadowContent:
4903     @@ContentType:
4904     lang:muf
4905     @@lang:en
4906    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24