/[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.111 - (hide annotations) (download)
Sat Dec 30 12:49:58 2006 UTC (18 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.110: +1 -30 lines
++ manakai/bin/ChangeLog	30 Dec 2006 12:47:09 -0000
	* daf.pl (--create-perl-module, --create-perl-test): These
	options will ignore |for| parameter.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/Util/ChangeLog	30 Dec 2006 12:47:27 -0000
	* DIS.dis (defaultForURI): Removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/Util/DIS/ChangeLog	30 Dec 2006 12:49:03 -0000
	* DNLite.dis (defaultForURI): Removed.

	* Perl.dis (plUpdateModule): The parameter
	is now a reference to an array
	whose items are only module name URIs (but |for| URIs).
	Support for the |DefaultFor| property is removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/manakai/ChangeLog	30 Dec 2006 12:49:52 -0000
	* daf-dtd-modules.pl: Unused references to |DefaultFor|
	properties are removed.

	* daf-perl-pm.pl, daf-perl-t.pl: Support
	for module |for| URIs are removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 Module:
2 wakaba 1.51 @QName: Util|DIS
3 wakaba 1.1 @FullName:
4     @@lang: en
5     @@@:
6     <QUOTE::DIS> Object Model
7     @Namespace:
8     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
9    
10     @Description:
11     @@lang:en
12     @@@:
13 wakaba 1.14 This module provides an object model for <QUOTE::dis> document format.
14 wakaba 1.1
15 wakaba 1.53 @DISCore:author: DISCore|Wakaba
16 wakaba 1.1 @License:
17     @@@:
18     license:Perl+MPL
19     @@Original:
20     @@@FullName:
21 wakaba 1.19 manakai <CODE::lib/manakai/dis.pl> and <CODE::bin/cdis2pm.pl>
22 wakaba 1.1 @@@Year:2004
23 wakaba 1.53 @@@DISCore:author: DISCore|Wakaba
24 wakaba 1.1 @Date:
25 wakaba 1.111 $Date: 2006/12/30 12:00:42 $
26 wakaba 1.1
27     @Require:
28     @@Module:
29 wakaba 1.110 @@@QName: Util|common
30     @@Module:
31 wakaba 1.51 @@@QName: Markup|SuikaWikiConfig21
32 wakaba 1.47 @@Module:
33     @@@QName: MDOM|DOMFeature
34 wakaba 1.48 @@Module:
35     @@@QName: DIS|Perl
36     @@Module:
37     @@@QName: DIS|Value
38 wakaba 1.99 @@Module:
39 wakaba 1.100 @@@QName: MDOM|DOMCore
40     @@Module:
41 wakaba 1.99 @@@QName: MDOM|TreeStore
42 wakaba 1.1
43     Namespace:
44 wakaba 1.81 @c:
45     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
46 wakaba 1.1 @DIS:
47     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
48     @dis:
49     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
50 wakaba 1.3 @DOMCore:
51     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
52     @DOMLS:
53     http://suika.fam.cx/~wakaba/archive/2004/dom/ls#
54     @DOMMain:
55     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
56 wakaba 1.104 @domperl:
57     http://suika.fam.cx/~wakaba/archive/2006/dom/perl/
58 wakaba 1.48 @dp:
59     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#Perl/
60     @dv:
61     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#Value/
62 wakaba 1.52 @dx:
63     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#
64 wakaba 1.47 @ecore:
65     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/Core/
66 wakaba 1.84 @Err:
67     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/
68 wakaba 1.63 @f:
69     http://suika.fam.cx/~wakaba/archive/2004/dom/feature#
70 wakaba 1.99 @fe:
71     http://suika.fam.cx/www/2006/feature/
72 wakaba 1.63 @idl:
73     http://suika.fam.cx/~wakaba/archive/2004/dis/IDL#
74 wakaba 1.3 @infoset:
75     http://www.w3.org/2001/04/infoset#
76 wakaba 1.47 @kwd:
77     http://suika.fam.cx/~wakaba/archive/2005/rfc2119/
78 wakaba 1.1 @lang:
79     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
80     @license:
81     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
82     @ManakaiDOM:
83     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
84 wakaba 1.5 @Markup:
85     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
86 wakaba 1.47 @MDOM:
87     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.
88 wakaba 1.3 @MDOMX:
89     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
90 wakaba 1.53 @mn:
91     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/ManakaiNode#
92 wakaba 1.1 @rdf:
93     http://www.w3.org/1999/02/22-rdf-syntax-ns#
94     @rdfs:
95     http://www.w3.org/2000/01/rdf-schema#
96 wakaba 1.32 @s:
97     http://suika.fam.cx/~wakaba/archive/2004/dis/Markup#
98 wakaba 1.3 @swcfg21:
99     http://suika.fam.cx/~wakaba/archive/2005/swcfg21#
100 wakaba 1.99 @tc:
101     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/
102     @td:
103     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/Document/
104     @te:
105     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/Element/
106 wakaba 1.79 @test:
107     http://suika.fam.cx/~wakaba/archive/2004/dis/Test#
108 wakaba 1.99 @tst:
109     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeStore/
110 wakaba 1.1 @Util:
111     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
112    
113     ## -- Features
114    
115     ElementTypeBinding:
116     @Name: FeatureDef
117     @ElementType:
118     dis:ResourceDef
119     @ShadowContent:
120 wakaba 1.52 @@rdf:type: DOMFeature|Feature
121 wakaba 1.1
122     ElementTypeBinding:
123     @Name: FeatureVerDef
124     @ElementType:
125     dis:ResourceDef
126     @ShadowContent:
127 wakaba 1.52 @@rdf:type: DOMFeature|Feature
128 wakaba 1.1
129     ElementTypeBinding:
130     @Name: featureQName
131     @ElementType:
132 wakaba 1.52 DOMFeature:name
133 wakaba 1.1 @ShadowContent:
134 wakaba 1.52 @@ContentType: DISCore|QName
135 wakaba 1.1
136     FeatureDef:
137     @QName: Core
138     @FeatureVerDef:
139     @@QName: CoreFeature10
140     @@Version: 1.0
141 wakaba 1.60 @@DOMFeature:instanceOf: Core
142 wakaba 1.1 @@FullName:
143     @@@lang:en
144     @@@@:
145     The <QUOTE::dis> object model, version 1.0
146     @@Description:
147     @@@lang:en
148     @@@@:
149     The <QUOTE::dis> object model, version 1.0.
150 wakaba 1.106 @@f:requires:
151 wakaba 1.1 swcfg21:CoreFeature21
152    
153 wakaba 1.47 ElementTypeBinding:
154     @Name: IFQName
155     @ElementType:
156     dis:QName
157     @ShadowContent:
158     @@ForCheck: ManakaiDOM|ForIF
159    
160     ElementTypeBinding:
161     @Name: ClsQName
162     @ElementType:
163     dis:QName
164     @ShadowContent:
165     @@ForCheck: ManakaiDOM|ForClass
166    
167     ElementTypeBinding:
168     @Name: IFISA
169     @ElementType:
170     dis:ISA
171     @ShadowContent:
172     @@ForCheck: ManakaiDOM|ForIF
173    
174     ElementTypeBinding:
175     @Name: ClsISA
176     @ElementType:
177     dis:ISA
178     @ShadowContent:
179     @@ForCheck: ManakaiDOM|ForClass
180    
181     ElementTypeBinding:
182     @Name: IFClsDef
183     @ElementType:
184     dis:ResourceDef
185     @ShadowContent:
186     @@rdf:type:
187     @@@@: dis|MultipleResource
188     @@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass
189     @@resourceFor: ManakaiDOM|ForIF
190     @@resourceFor:
191     @@@@: ManakaiDOM|ForClass
192    
193     @@rdf:type:
194     @@@@: ManakaiDOM|IF
195     @@@ForCheck: ManakaiDOM|ForIF
196    
197     @@rdf:type:
198     @@@@: ManakaiDOM|Class
199     @@@ForCheck: ManakaiDOM|ForClass
200 wakaba 1.110
201 wakaba 1.47 @@Implement:
202 wakaba 1.110 @@@@: ||+||ManakaiDOM|ForIF
203 wakaba 1.47 @@@ContentType: DISCore|TFPQNames
204 wakaba 1.110 @@@ForCheck: ManakaiDOM|ForClass
205 wakaba 1.47
206     @@DOMMain:implementFeature:
207     @@@@: CoreFeature10
208    
209     ElementTypeBinding:
210     @Name: ClsDef
211     @ElementType:
212     dis:ResourceDef
213     @ShadowContent:
214     @@rdf:type:
215     @@@@: dis|MultipleResource
216     @@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass
217    
218     @@resourceFor:
219     @@@@: ManakaiDOM|ForClass
220    
221     @@rdf:type:
222     @@@@: ManakaiDOM|Class
223     @@@ForCheck: ManakaiDOM|ForClass
224    
225     @@DOMMain:implementFeature:
226     @@@@: CoreFeature10
227    
228     ElementTypeBinding:
229     @Name: clsActualType
230     @ElementType:
231     dis:actualType
232     @ShadowContent:
233     @@ForCheck: ManakaiDOM|ForClass
234    
235 wakaba 1.1 ## -- SuikaWikiConfig/2.1 extended classes
236    
237 wakaba 1.47 IFClsDef:
238     @IFQName: DISImplementation
239 wakaba 1.1 @ClsQName: ManakaiDISImplementation
240 wakaba 1.47
241 wakaba 1.104 @domperl:implementedByObjectsOf: DOMImpl
242     @domperl:classImplementedByObjectsOf:
243 wakaba 1.110 c|ManakaiDOMImplementation
244 wakaba 1.48
245 wakaba 1.1 @Description:
246     @@lang:en
247     @@@:
248     A <QUOTE::dis> implementation object.
249    
250     @Method:
251     @@Name: createDISDocument
252     @@Description:
253     @@@lang:en
254     @@@@:
255 wakaba 1.47 Creates an empty <IF::DISDocument> node.
256 wakaba 1.1 @@Return:
257 wakaba 1.47 @@@Type: DISDocument
258     @@@clsActualType: ManakaiDISDocument
259 wakaba 1.1 @@@Description:
260     @@@@lang:en
261     @@@@@:
262     The newly created <QUOTE::dis> document object.
263     @@@PerlDef:
264 wakaba 1.110 $r = bless $self-><M::swcfg21:SWCFGImplementation
265 wakaba 1.29 .createSWCFGDocument>,
266     <ClassName::ManakaiDISDocument>;
267 wakaba 1.110 $r-><AS::swcfg21:SWCFGDocument
268 wakaba 1.3 .defaultElementTypeNamespaceURI>
269 wakaba 1.1 (<Q::dis:>);
270    
271     @Method:
272 wakaba 1.2 @@Name: createDISParser
273     @@Description:
274     @@@lang:en
275     @@@@:
276 wakaba 1.47 Creates a <IF::DISParser> object.
277 wakaba 1.2 @@Return:
278 wakaba 1.47 @@@Type: DISParser
279     @@@clsActualType: ManakaiDISParser
280 wakaba 1.2 @@@Description:
281     @@@@lang:en
282     @@@@@:
283 wakaba 1.1 A newly created <QUOTE::dis> parser.
284 wakaba 1.2 @@@PerlDef:
285 wakaba 1.110 $r = bless $self-><M::swcfg21:SWCFGImplementation
286 wakaba 1.3 .createSWCFGParser>,
287 wakaba 1.1 <ClassName::ManakaiDISParser>;
288    
289     @Method:
290 wakaba 1.2 @@Name: createDISDatabase
291 wakaba 1.1 @@Description:
292     @@@lang:en
293     @@@@:
294 wakaba 1.2 Creates a new <QUOTE::dis> database.
295 wakaba 1.1 @@Return:
296 wakaba 1.47 @@@Type: DISDatabase
297     @@@clsActualType: ManakaiDISDatabase
298 wakaba 1.4 @@@Description:
299     @@@@lang:en
300     @@@@@:
301 wakaba 1.2 A newly created <QUOTE::dis> parser.
302 wakaba 1.4 @@@PerlDef:
303 wakaba 1.2 $r = bless {
304     forDef => {
305 wakaba 1.5 <Q::ManakaiDOM:all> => bless ({
306 wakaba 1.2 uri => <Q::ManakaiDOM:all>,
307     isa => {<Q::ManakaiDOM:all> => 1},
308     revISA => {},
309 wakaba 1.79 <H::revision> => 0,
310 wakaba 1.5 }, <ClassName::ManakaiDISForDefinition>),
311 wakaba 1.2 },
312     resDef => {},
313 wakaba 1.9 modDef => {},
314     seq => 0,
315 wakaba 1.3 }, <ClassName::ManakaiDISDatabase>;
316 wakaba 1.48 $r->{forDef}->{<Q::ManakaiDOM:all>}->{db} = $r;
317 wakaba 1.3
318 wakaba 1.79 @CODE:
319     @@QName: createDISDBForTest
320     @@PerlDef:
321     $db = <ClassM::ManakaiDISImplementation.createDISDatabase>;
322    
323     my $any = $db-><M::DISDatabase.getResource> (<Q::DISCore|AnyResource>);
324    
325     my $mod = $db-><M::DISDatabase.getResource> (<Q::DISCore|Module>);
326     $mod-><M::DISResource.addSuperResource> ($any);
327    
328     my $for = $db-><M::DISDatabase.getResource> (<Q::DISCore|For>);
329     $for-><M::DISResource.addSuperResource> ($any);
330    
331     my $res = $db-><M::DISDatabase.getResource> (<Q::DISCore|Resource>);
332     $res-><M::DISResource.addSuperResource> ($any);
333    
334 wakaba 1.3 @Method:
335     @@Name: tfurisToURI
336     @@Description:
337     @@@lang:en
338     @@@@:
339     Converts a pair of name URI reference and <QUOTE::for> URI reference
340 wakaba 1.47 into a <Q::dis:TFQNames>-expanded URI reference.
341 wakaba 1.3 @@Param:
342     @@@Name: typeURI
343     @@@Type: NameURI
344     @@@Description:
345     @@@@lang:en
346     @@@@@:
347     A URI reference to identify a resource.
348 wakaba 1.49 @@@nullCase:
349 wakaba 1.3 @@@@Description:
350     @@@@@lang:en
351     @@@@@@:
352     Equivalent to <Q::DOMMain:any> (for historical reason).
353     @@Param:
354     @@@Name: forURI
355     @@@Type: ForURI
356     @@@Description:
357     @@@@lang:en
358     @@@@@:
359     A <QUOTE::for> URI reference.
360 wakaba 1.49 @@@nullCase:
361 wakaba 1.3 @@@@Description:
362     @@@@@lang:en
363     @@@@@@:
364     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
365     @@Return:
366     @@@Type:
367 wakaba 1.110 DISCore:TFURI
368 wakaba 1.3 @@@Description:
369     @@@@lang:en
370     @@@@@:
371 wakaba 1.47 The <Q::dis:TFQNames>-expanded URI references.
372 wakaba 1.3 @@@PerlDef:
373     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
374     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
375 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
376    
377     @ResourceDef:
378 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
379 wakaba 1.4 @@QName: tfurisToURI
380 wakaba 1.60 @@rdf:type: DISPerl|BlockCode
381 wakaba 1.4 @@enDesc:
382     Converts a pair of name URI reference and <QUOTE::for> URI reference
383 wakaba 1.47 into a <Q::dis:TFQNames>-expanded URI reference.
384 wakaba 1.4 @@PerlDef:
385     if ($furi eq <Q::ManakaiDOM:all>) {
386     $uri = $turi;
387 wakaba 1.3 } else {
388     ## NOTE: [RFC 3986]
389     ## fragment := *(pchar / "/" / "?")
390     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
391     ## unreserved := ALPHA / DIGIT / [._~-]
392     ## sub-delims := [!$&'()*+,;=]
393     ## NOTE: [XPointer Framework]
394     ## SchemeData := *EscapedData
395     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
396     ## / "(" SchemeData ")"
397     ## NormalChar := UnicodeChar - [()^]
398 wakaba 1.5 my $__turi = $turi;
399     my $__furi = $furi;
400     for my $__uri ($__turi, $__furi) {
401 wakaba 1.58 $__uri =~ s{([^0-9A-Za-z!\$'()*,:;=?\@_./~-])}{sprintf '%%%02X', ord $1}ge;
402 wakaba 1.3 }
403 wakaba 1.58 $uri = qq<tag:suika.fam.cx,2005-09:$__turi+$__furi>;
404 wakaba 1.3 }
405 wakaba 1.2
406 wakaba 1.5 @ResourceDef:
407 wakaba 1.6 @@QName: tfpurisToURI
408 wakaba 1.60 @@rdf:type: DISPerl|BlockCode
409 wakaba 1.6 @@enDesc:
410     Converts a set of name URI reference and <QUOTE::for> URI reference
411     and <QUOTE::for+> URI references into a URi reference.
412 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
413 wakaba 1.6 @@PerlDef:
414     if ($furi eq <Q::ManakaiDOM:all> and @{$forp} == 0) {
415     $uri = $turi;
416     } elsif (@{$forp}) {
417     my $__turi = $turi;
418     my $__furi = $furi;
419     for my $__uri ($__turi, $__furi) {
420 wakaba 1.58 $__uri =~ s{([^0-9A-Za-z!\$'()*,:;=?\@_./~-])}{sprintf '%%%02X', ord $1}ge;
421 wakaba 1.6 }
422     my @__fp;
423     for my $__uri (@{$forp}) {
424     my $__fpuri = $__uri;
425 wakaba 1.58 $__fpuri =~ s{([^0-9A-Za-z!\$'()*,:;=?\@_./~-])}
426 wakaba 1.6 {sprintf '%%%02X', ord $1}ge;
427     push @__fp, $__fpuri;
428     }
429 wakaba 1.58 $uri = qq<tag:suika.fam.cx,2005-09:$__turi+$__furi+>.join ('+', @__fp);
430 wakaba 1.6 } else {
431     my $__turi = $turi;
432     my $__furi = $furi;
433     for my $__uri ($__turi, $__furi) {
434 wakaba 1.58 $__uri =~ s{([^0-9A-Za-z!\$'(),*:;=?\@_./~-])}{sprintf '%%%02X', ord $1}ge;
435 wakaba 1.6 }
436 wakaba 1.58 $uri = qq<tag:suika.fam.cx,2005-09:$__turi+$__furi>;
437 wakaba 1.6 }
438    
439 wakaba 1.80 @CODE:
440     @@QName: composeSubsetURI
441     @@PerlDef:
442     my $__uri1 = $input1;
443     my $__uri2 = $input2;
444     for my $__uri ($__uri1, $__uri2) {
445     $__uri =~ s{([^0-9A-Za-z!\$'()*,:;=?\@_./~-])}
446     {sprintf '%%%02X', ord $1}ge;
447     }
448     $output = qq<tag:suika.fam.cx,2006-02:$__uri1+$__uri2>;
449    
450 wakaba 1.43 @ImplNote:
451     @@lang:en
452     @@@:
453     {TODO:: IRI support.
454     }
455    
456 wakaba 1.6 @ResourceDef:
457 wakaba 1.5 @@QName: getChildResourceURI
458 wakaba 1.60 @@rdf:type: DISPerl|BlockCode
459 wakaba 1.5 @@enDesc:
460     Gets an anonymous URI reference of a child resource of another
461     resource.
462 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
463 wakaba 1.5 @@PerlDef:
464     my $__parent = $parentURI;
465     my $__ln = $localName;
466     for my $__uri ($__parent, $__ln) {
467 wakaba 1.58 $__uri =~ s{([^0-9A-Za-z!\$'(),*:;=?\@_./~-])}{sprintf '%%%02X', ord $1}ge;
468 wakaba 1.5 }
469 wakaba 1.58 $result = qq<data:suika.fam.cx,2005-09::$__parent+$__ln>;
470 wakaba 1.5
471 wakaba 1.8 @IntMethod:
472     @@Name: camelCaseToUnderscoreName
473     @@enDesc:
474     Converts a camelCase name to a underscored_name.
475     @@ManakaiDOM:isStatic:1
476 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
477 wakaba 1.8 @@Param:
478     @@@Name: camelName
479     @@@Type:
480 wakaba 1.110 DISLang:String
481 wakaba 1.8 @@@enDesc:
482     The source name.
483     @@Return:
484     @@@Type:
485 wakaba 1.110 DISLang:String
486 wakaba 1.8 @@@enDesc:
487     The result name.
488     @@@PerlDef:
489     $r = $camelName;
490     $r =~ s/^([A-Z0-9]+)$/lc $1/ge;
491     $r =~ s/([A-Z][A-Z0-9]*)$/"_".lc $1/ge;
492     $r =~ s/([A-Z0-9])([A-Z0-9]*)([A-Z0-9])/$1.lc ($2)."_".lc $3/ge;
493     $r =~ s/([A-Z])/"_".lc $1/ge;
494     $r =~ s/(?=[0-9](?!$))/_/g;
495 wakaba 1.75 $r =~ tr/-/_/;
496 wakaba 1.9
497 wakaba 1.60 @DOMFeature:provides: CoreFeature10
498 wakaba 1.1 ##DISImplementation
499    
500 wakaba 1.79 ElementTypeBinding:
501     @Name: CODE
502     @ElementType:
503     dis:ResourceDef
504     @ShadowContent:
505     @@rdf:type: DISPerl|BlockCode
506     @@ForCheck: ManakaiDOM|ForClass
507    
508 wakaba 1.47 IFClsDef:
509     @IFQName: DISParser
510 wakaba 1.1 @ClsQName: ManakaiDISParser
511 wakaba 1.47
512 wakaba 1.110 @IFISA: swcfg21|SWCFGParser
513 wakaba 1.1 @ClsISA:
514 wakaba 1.110 swcfg21:ManakaiSWCFGParser
515 wakaba 1.47
516 wakaba 1.1 @Description:
517     @@lang:en
518     @@@:
519     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
520     @Method:
521 wakaba 1.3 @@Name: parse
522     @@Description:
523     @@@lang:en
524     @@@@:
525 wakaba 1.1 Parses a <QUOTE::dis> document and returns it as an object tree.
526 wakaba 1.3 @@Param:
527     @@@Name: input
528 wakaba 1.110 @@@Type: DISPerl|HASH
529 wakaba 1.3 @@@Description:
530     @@@@lang:en
531     @@@@@:
532 wakaba 1.1 The input source.
533 wakaba 1.3 @@Return:
534 wakaba 1.47 @@@Type: DISDocument
535     @@@clsActualType: ManakaiDISDocument
536 wakaba 1.3 @@@Description:
537     @@@@lang:en
538     @@@@@:
539 wakaba 1.1 The <QUOTE::dis> document object created from the <P::input>.
540     @@@RaiseException:
541     @@@@@:
542 wakaba 1.110 swcfg21:SWCFG_PARSE_ERR
543 wakaba 1.1 @@@@Description:
544     @@@@@lang:en
545     @@@@@@:
546     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
547     document.
548     @@@PerlDef:
549     __DEEP{
550 wakaba 1.28 $r = $self->SUPER::parse ($input)
551 wakaba 1.1 }__;
552     if (defined $r) {
553     $r = bless $r, <ClassName::ManakaiDISDocument>;
554 wakaba 1.110 $r-><AS::swcfg21:SWCFGDocument
555 wakaba 1.4 .defaultElementTypeNamespaceURI>
556     (<Q::dis:>);
557 wakaba 1.1 }
558     ##DISParser
559    
560 wakaba 1.47 IFClsDef:
561     @IFQName: DISNode
562 wakaba 1.1 @ClsQName: ManakaiDISNode
563 wakaba 1.47
564 wakaba 1.1 @Description:
565     @@lang:en
566     @@@:
567     <QUOTE::dis> node objects.
568 wakaba 1.7 @ImplNote:
569     @@lang:en
570     @@@:
571     This class does not inherit
572 wakaba 1.110 <Class::swcfg21:ManakaiSWCFGNode>, since
573 wakaba 1.7 inheriting classes such as <Class::ManakaiDISElement> indirectly
574     inherit it.
575 wakaba 1.1
576     @MethodRedef:
577 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
578 wakaba 1.1 @@Name:lookupNamespacePrefix
579     @@Description:
580     @@@lang:en
581     @@@@:
582     Looks up the namespace prefix associated to the given
583     namespace URI. The default namespaces are ignored.
584     @@Param:
585     @@@Name:namespaceURI
586 wakaba 1.3 @@@Type: AnyURI
587 wakaba 1.1 @@@Description:
588     @@@@lang:en
589     @@@@@:
590     The namespace URI to look for.
591 wakaba 1.49 @@@nullCase:
592 wakaba 1.1 @@@@Description:
593     @@@@@lang:en
594     @@@@@@:
595     The <DOM::null> namespace.
596     @@NamedParam:
597     @@@Name: makeNewBinding
598     @@@Type:
599 wakaba 1.110 DOMMain:boolean
600 wakaba 1.1 @@@Description:
601     @@@@lang:en
602     @@@@@:
603     Whether a new namespace prefix should be bound when
604     no namespace URI has been associated yet.
605 wakaba 1.49 @@@TrueCase:
606 wakaba 1.1 @@@@Description:
607     @@@@@lang:en
608     @@@@@@:
609     New binding is made if no prefix associated.
610 wakaba 1.49 @@@FalseCase:
611 wakaba 1.1 @@@@Description:
612     @@@@@lang:en
613     @@@@@@:
614     Simply returns the <DOM::null> if no prefix associated.
615     @@Return:
616 wakaba 1.110 @@@Type: swcfg21|SWCFGString
617 wakaba 1.47 @@@actualType:
618 wakaba 1.110 DISCore:NamespacePrefix
619 wakaba 1.1 @@@Description:
620     @@@@lang:en
621     @@@@@:
622     An associated namespace prefix. If more than one prefix
623     are associated to the namespace URI, the returned prefix
624     is implementation dependent.
625 wakaba 1.49 @@@nullCase:
626 wakaba 1.1 @@@@Description:
627     @@@@@lang:en
628     @@@@@@:
629     No associated namespace prefix found.
630     @@@PerlDef:
631     $r = null;
632 wakaba 1.110 my $od = $self-><AG::swcfg21:SWCFGNode
633 wakaba 1.3 .ownerDocument> || $self;
634 wakaba 1.53 my $binds = $od->{<H::mn:node>}->{<H::swcfg21:nsBinding>};
635 wakaba 1.1 if (defined $namespaceURI) {
636     FIND: {
637     for my $prefix (keys %$binds) {
638     if (defined $binds->{$prefix} and
639     $binds->{$prefix} eq $namespaceURI) {
640     $r = $prefix;
641     last FIND;
642     }
643     }
644 wakaba 1.7
645     ## From module list
646     try {
647     my $db = $self-><AG::ManakaiDISNode.ownerDISDocument>
648     -><AG::ManakaiDISDocument.disDatabase>;
649     for my $mod_uri (keys %{$db->{modDef}}) {
650     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
651 wakaba 1.48 my $mod_ln = $mod-><AG::DISAnyResource.localName>;
652 wakaba 1.7 next if exists $binds->{$mod_ln};
653 wakaba 1.57 my $ns_uri = $mod-><AG::DIS|DISModule.targetNamespaceURI>;
654     $ns_uri = '' unless defined $ns_uri;
655 wakaba 1.7 if ($ns_uri eq $namespaceURI) {
656     $r = $mod_ln;
657     last FIND;
658     }
659     }
660 wakaba 1.48 } catch <IF::DISException> with {
661 wakaba 1.7 my $err = shift;
662     $err->throw
663 wakaba 1.47 unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_ASSOCIATED_DB_ERR>;
664 wakaba 1.7 };
665    
666 wakaba 1.1 last FIND unless $makeNewBinding;
667     ## Not found
668     if ($namespaceURI =~ /(\w+)$/) {
669     my $prefix = $1;
670     unless (exists $binds->{$prefix}) {
671     $binds->{$prefix} = $namespaceURI;
672     $r = $prefix;
673     last FIND;
674     }
675     }
676     my $i = 1;
677     {
678     unless (exists $binds->{'ns'.$i}) {
679     $binds->{$r = 'ns'.$i} = $namespaceURI;
680     last FIND;
681     }
682     $i++;
683     redo;
684     }
685     } # FIND
686     } else { ## Null namespace
687     FIND: {
688     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
689     $r = 'nu'.'ll';
690     last FIND;
691     }
692     for my $prefix (keys %$binds) {
693     if (not defined $prefix) {
694     $r = $prefix;
695     last FIND;
696     }
697     }
698     last FIND unless $makeNewBinding;
699     ## Not found
700     my $i = '';
701     {
702     unless (exists $binds->{'nu'.'ll'.$i}) {
703     $binds->{$r = 'nu'.'ll'.$i} = null;
704     last FIND;
705     }
706     $i++;
707     redo;
708     }
709     }
710     }
711    
712     @MethodRedef:
713 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
714 wakaba 1.1 @@Name:lookupNamespaceURI
715     @@Description:
716     @@@lang:en
717     @@@@:
718     Looks up the namespace URI associated to the given prefix.
719     @@Param:
720     @@@Name:prefix
721     @@@Type:
722 wakaba 1.110 DISCore:NamespacePrefix
723 wakaba 1.1 @@@Description:
724     @@@@lang:en
725     @@@@@:
726     The namespace URI to look for.
727     @@NamedParam:
728     @@@Name: makeNewBinding
729     @@@Type:
730 wakaba 1.110 DOMMain:boolean
731 wakaba 1.1 @@@Description:
732     @@@@lang:en
733     @@@@@:
734     Whether a new binding should be created if no namespace URI
735     is associated with the <P::prefix> or not.
736 wakaba 1.49 @@@TrueCase:
737 wakaba 1.1 @@@@Description:
738     @@@@@lang:en
739     @@@@@@:
740     A new binding to the temporary namespace URI
741     exactly same as <P::prefix> is created
742     if no binding found.
743 wakaba 1.49 @@@FalseCase:
744 wakaba 1.1 @@@@Description:
745     @@@@@lang:en
746     @@@@@@:
747     No new binding is created if no binding found. Note that
748     even if no association newly created, this method
749     returns the <DOM::null> value.
750 wakaba 1.12 @@NamedParam:
751     @@@Name: raisePrefixException
752     @@@Type:
753 wakaba 1.110 DOMMain:boolean
754 wakaba 1.12 @@@enDesc:
755     Whehter an exception should be thrown if <P::prefix>
756     is not declared or not.
757 wakaba 1.1 @@Return:
758 wakaba 1.3 @@@Type: AnyURI
759 wakaba 1.1 @@@Description:
760     @@@@lang:en
761     @@@@@:The associated namespace URI.
762 wakaba 1.49 @@@nullCase:
763 wakaba 1.1 @@@@Description:
764     @@@@@lang:en
765     @@@@@@:
766 wakaba 1.3 No namespace URI is associated to the prefix or
767 wakaba 1.1 the <DOM::null> namespace is associated.
768 wakaba 1.12 @@@UndeclaredPrefixException:
769 wakaba 1.1 @@@PerlDef:
770 wakaba 1.51 my $od = $self-><AG::DISNode.ownerDISDocument> || $self;
771 wakaba 1.53 my $binds = $od->{<H::mn:node>}->{<H::swcfg21:nsBinding>};
772 wakaba 1.1 if (exists $binds->{$prefix}) {
773     $r = $binds->{$prefix};
774     } else {
775 wakaba 1.7 ## From module list
776     FIND: {
777 wakaba 1.88 if ($od->{<H::mn:node>}->{<H::DIS|disNamespaceResolver>}) {
778     $r = $od->{<H::mn:node>}->{<H::DIS|disNamespaceResolver>}
779     ->($prefix);
780     last FIND if defined $r;
781     }
782 wakaba 1.7 try {
783 wakaba 1.51 my $db = $od-><AG::DISDocument.disDatabase>;
784 wakaba 1.7 for my $mod_uri (keys %{$db->{modDef}}) {
785     my $mod = $db-><M::ManakaiDISDatabase.getModule> ($mod_uri);
786 wakaba 1.48 if ($mod-><AG::DISAnyResource.localName>
787 wakaba 1.7 eq $prefix) {
788 wakaba 1.57 $r = $mod-><AG::DIS|DISModule.targetNamespaceURI>;
789 wakaba 1.7 last FIND;
790     }
791     }
792 wakaba 1.48 } catch <IF::DISException> with {
793 wakaba 1.7 my $err = shift;
794     $err->throw
795 wakaba 1.47 unless $err->{<Q::MDOMX:subtype>} eq <Q::NO_ASSOCIATED_DB_ERR>;
796 wakaba 1.7 };
797     if ($makeNewBinding) {
798     $r = $binds->{$prefix} = $prefix;
799 wakaba 1.12 } elsif ($raisePrefixException) {
800     __EXCEPTION{DIS:UNDECLARED_NS_PREFIX_ERR::
801     infoset:prefix => {$prefix},
802     MDOMX:param-name => 'prefix',
803     DIS:sourceNode => {$self},
804     }__;
805 wakaba 1.7 } else {
806     $r = null;
807     }
808     } # FIND
809 wakaba 1.1 }
810    
811     @IntMethod:
812 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
813 wakaba 1.1 @@Name:getNodeReference
814     @@Description:
815     @@@lang:en
816     @@@@:
817     Returns a new reference to the node object.
818     @@ManakaiDOM:isStatic:1
819     @@Param:
820     @@@Name:object
821 wakaba 1.110 @@@Type: ManakaiNode|NodeStem
822 wakaba 1.1 @@@Description:
823     @@@@lang:en
824     @@@@@:
825     The node object to be referred.
826     @@Return:
827     @@@Type: ManakaiDISNode
828     @@@Description:
829     @@@@lang:en
830     @@@@@:
831     A newly created reference.
832     @@@PerlDef:
833     my $class;
834 wakaba 1.53 if ($object->{<H::swcfg21:nodeType>} eq '#element') {
835 wakaba 1.1 $class = <ClassName::ManakaiDISElement>;
836 wakaba 1.53 } elsif ($object->{<H::swcfg21:nodeType>} eq '#comment') {
837 wakaba 1.1 $class = <ClassName::ManakaiDISComment>;
838 wakaba 1.53 } elsif ($object->{<H::swcfg21:nodeType>} eq '#document') {
839 wakaba 1.1 $class = <ClassName::ManakaiDISDocument>;
840 wakaba 1.53 } elsif ($object->{<H::swcfg21:nodeType>} eq '#fragment') {
841 wakaba 1.1 $class = <ClassName::ManakaiDISDocumentFragment>;
842     } else {
843     __ASSERT{DISPerl:invariant::
844 wakaba 1.53 msg => {qq[Node type: "$object->{<H::swcfg21:nodeType>}" ].
845 wakaba 1.1 qq[(ref: "@{[ref $object]}")]},
846     }__;
847     }
848 wakaba 1.110 __CODE{ManakaiNode|getNewReference::
849 wakaba 1.47 $object => $object,
850     $ref => $r,
851     $class => $class,
852     }__;
853 wakaba 1.1
854 wakaba 1.2 @Attr:
855     @@Name:ownerDISDocument
856     @@Description:
857     @@@lang:en
858     @@@@:
859     The <QUOTE::dis> document object associated with this node.
860     @@Get:
861 wakaba 1.47 @@@Type: DISDocument
862     @@@clsActualType: ManakaiDISDocument
863 wakaba 1.2 @@@Description:
864     @@@@lang:en
865     @@@@@:
866     The document object associated with this node.
867 wakaba 1.49 @@@nullCase:
868 wakaba 1.2 @@@@Description:
869     @@@@@lang:en
870     @@@@@@:
871     This node is a document node.
872     @@@PerlDef:
873     $r = <ClassM::ManakaiDISNode.getNodeReference>
874 wakaba 1.53 ($self->{<H::mn:node>}->{<H::swcfg21:ownerDocument>})
875     if $self->{<H::mn:node>}->{<H::swcfg21:ownerDocument>};
876 wakaba 1.1 ##DISNode
877    
878 wakaba 1.47 IFClsDef:
879 wakaba 1.48 @IFQName: NSResolverDIS
880     @ClsQName: ManakaiNSResolverDIS
881 wakaba 1.1
882     @Method:
883 wakaba 1.48 @@Name: prefixToURI
884 wakaba 1.1 @@Description:
885     @@@lang:en
886     @@@@:
887 wakaba 1.48 Converts a namespace prefix into associated URI reference.
888 wakaba 1.1 @@Param:
889 wakaba 1.48 @@@Name: prefix
890     @@@Type:
891 wakaba 1.110 DISCore:NamespacePrefix
892 wakaba 1.1 @@@Description:
893     @@@@lang:en
894     @@@@@:
895 wakaba 1.48 A namespace prefix to look for.
896 wakaba 1.49 @@@nullCase:
897 wakaba 1.1 @@@@Description:
898     @@@@@lang:en
899     @@@@@@:
900 wakaba 1.48 Returns the default namespace URI.
901     @@NodeParam:
902 wakaba 1.1 @@Return:
903 wakaba 1.48 @@@Type: AnyURI
904 wakaba 1.1 @@@Description:
905     @@@@lang:en
906 wakaba 1.48 @@@@@: The URI references associated.
907 wakaba 1.2 @@@UndeclaredPrefixException:
908     @@@PerlDef:
909 wakaba 1.48 if (defined $prefix) {
910     __DEEP{
911     $r = $self-><M::SWCFGNode.lookupNamespaceURI> ($prefix);
912     }__;
913     unless (defined $r) {
914     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
915     infoset:prefix => {$prefix},
916     MDOMX:param-name => 'prefix',
917     DIS:sourceNode => {$node},
918     }__;
919     }
920 wakaba 1.53 } elsif (defined $self->{<H::mn:node>}
921     ->{<H::DIS|defaultNamespaceURI>}) {
922     $r = $self->{<H::mn:node>}->{<H::DIS|defaultNamespaceURI>};
923 wakaba 1.48 } else { ## Default namespace
924 wakaba 1.2 __DEEP{
925 wakaba 1.48 $r = ($self-><AG::ManakaiDISNode.ownerDISDocument> || $self)
926     -><AG::ManakaiDISDocument.moduleElement>
927     -><AG::ManakaiDISModuleElement.definingNamespaceURI>;
928 wakaba 1.2 }__;
929 wakaba 1.48 }
930 wakaba 1.1
931     @Method:
932 wakaba 1.48 @@Name: qnameToURI
933 wakaba 1.1 @@Description:
934     @@@lang:en
935     @@@@:
936 wakaba 1.68 Converts a qualified name (<Q::DISCore:QName>) to
937 wakaba 1.48 an expanded URI reference.
938 wakaba 1.1 @@Param:
939 wakaba 1.48 @@@Name: qname
940 wakaba 1.110 @@@Type: DISCore|QName
941 wakaba 1.1 @@@Description:
942     @@@@lang:en
943     @@@@@:
944 wakaba 1.48 A qualified name.
945     @@NodeParam:
946     @@NamedParam:
947     @@@Name: defaultNamespaceURI
948     @@@Type: AnyURI
949     @@@enDesc:
950     Default namespace URI reference.
951     @@@nullCase:
952     @@@@enDesc:
953     The default namespace is the namespace defined by the module
954     to which this resource belongs.
955 wakaba 1.1 @@Return:
956 wakaba 1.48 @@@Type: AnyURI
957 wakaba 1.1 @@@Description:
958     @@@@lang:en
959     @@@@@:
960 wakaba 1.48 The expanded URI reference.
961     @@@UndeclaredPrefixException:
962 wakaba 1.2 @@@PerlDef:
963 wakaba 1.48 $qname =~ s/^\s+//; $qname =~ s/\s+$//;
964     my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
965     __DEEP{
966     if (defined $lname) {
967     $r = $self-><M::NSResolverDIS.prefixToURI> ($prefix) . $lname;
968     } else { ## In default namespace
969 wakaba 1.13 if (defined $defaultNamespaceURI) {
970     $r = $defaultNamespaceURI . $prefix;
971     } else {
972 wakaba 1.48 $r = $self-><M::NSResolverDIS.prefixToURI> (null) . $prefix;
973 wakaba 1.13 }
974 wakaba 1.1 }
975 wakaba 1.4 }__;
976 wakaba 1.1
977     @Method:
978 wakaba 1.47 @@Name: qnameToPair
979 wakaba 1.1 @@Description:
980     @@@lang:en
981     @@@@:
982 wakaba 1.68 Converts a qualified name (<Q::DISCore:QName>) to
983 wakaba 1.1 a pair of namespace URI and local name.
984     @@Param:
985     @@@Name: qname
986 wakaba 1.110 @@@Type: DISCore|QName
987 wakaba 1.1 @@@Description:
988     @@@@lang:en
989     @@@@@:
990     A qualified name.
991     @@NodeParam:
992     @@Return:
993     @@@Type:
994 wakaba 1.110 DISPerl:ARRAY
995 wakaba 1.1 @@@Description:
996     @@@@lang:en
997     @@@@@:
998     A list of namespace URI and local name.
999     @@@UndeclaredPrefixException:
1000     @@@PerlDef:
1001     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
1002 wakaba 1.15 my ($prefix, $lname) = split /\s*[:|]\s*/, $qname, 2;
1003 wakaba 1.1 __DEEP{
1004     if (defined $lname) {
1005 wakaba 1.48 $r = [$self-><M::NSResolverDIS.prefixToURI> ($prefix), $lname];
1006 wakaba 1.1 } else { ## In default namespace
1007 wakaba 1.48 $r = [$self-><M::NSResolverDIS.prefixToURI> (null), $prefix];
1008 wakaba 1.1 }
1009 wakaba 1.4 }__;
1010 wakaba 1.1
1011     @Method:
1012 wakaba 1.3 @@Name: tfqnamesToURI
1013 wakaba 1.1 @@Description:
1014     @@@lang:en
1015     @@@@:
1016 wakaba 1.47 Converts a <Q::dis:TFQNames>
1017 wakaba 1.1 into an expanded URI reference.
1018     @@Param:
1019     @@@Name: tfqnames
1020     @@@Type:
1021 wakaba 1.110 dis:TFQNames
1022 wakaba 1.1 @@@Description:
1023     @@@@lang:en
1024     @@@@@:
1025 wakaba 1.47 A <Q::dis:TFQNames> to identify a resource.
1026 wakaba 1.1 @@Param:
1027     @@@Name: defaultTypeURI
1028     @@@Type: NameURI
1029     @@@Description:
1030     @@@@lang:en
1031     @@@@@:
1032     A name URI reference used if it is missing from
1033     <P::tfqnames>.
1034 wakaba 1.49 @@@nullCase:
1035 wakaba 1.1 @@@@Description:
1036     @@@@@lang:en
1037     @@@@@@:
1038     Equivalent to <Q::DOMMain:any>.
1039     @@Param:
1040     @@@Name: defaultForURI
1041     @@@Type: ForURI
1042     @@@Description:
1043     @@@@lang:en
1044     @@@@@:
1045     A <QUOTE::for> URI reference used if it is missing from
1046     <P::tfqnames>.
1047 wakaba 1.49 @@@nullCase:
1048 wakaba 1.1 @@@@Description:
1049     @@@@@lang:en
1050     @@@@@@:
1051     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1052     @@NodeParam:
1053     @@Return:
1054     @@@Type:
1055 wakaba 1.110 DISCore:TFURI
1056 wakaba 1.1 @@@Description:
1057     @@@@lang:en
1058     @@@@@:
1059 wakaba 1.47 The <Q::dis:TFQNames>-expanded URI references.
1060 wakaba 1.1 @@@UndeclaredPrefixException:
1061     @@@PerlDef:
1062 wakaba 1.15 my ($typeq, $forq) = split /\s*[:|][:|]\s*/, $tfqnames, 2;
1063 wakaba 1.1 my ($typeURI, $forURI);
1064     if (defined $forq) {
1065     __DEEP{
1066     $typeURI = $typeq eq ''
1067     ? defined $defaultTypeURI ? $defaultTypeURI
1068     : <Q::DOMMain:any>
1069 wakaba 1.48 : $self-><M::NSResolverDIS.qnameToURI> ($typeq, %opt);
1070 wakaba 1.1 }__;
1071     if (length $forq) {
1072 wakaba 1.48 $forURI = $self-><M::NSResolverDIS.qnameToURI> ($forq, %opt);
1073 wakaba 1.1 } else {
1074     $forURI = <Q::ManakaiDOM:all>;
1075     }
1076     } else { ## "For" omitted
1077     __DEEP{
1078     $typeURI = $typeq eq ''
1079     ? defined $defaultTypeURI ? $defaultTypeURI
1080     : <Q::DOMMain:any>
1081 wakaba 1.48 : $self-><M::NSResolverDIS.qnameToURI> ($typeq, %opt);
1082 wakaba 1.1 }__;
1083 wakaba 1.3 $forURI = defined $defaultForURI ? $defaultForURI
1084     : <Q::ManakaiDOM:all>;
1085 wakaba 1.1 }
1086 wakaba 1.4 __CODE{tfurisToURI:: $turi => $typeURI, $furi => $forURI, $uri => $r}__;
1087 wakaba 1.2
1088     @Method:
1089 wakaba 1.33 @@Name: tfpqnamesToURI
1090     @@Description:
1091     @@@lang:en
1092     @@@@:
1093 wakaba 1.47 Converts a <Q::DISCore:TFPQNames>
1094 wakaba 1.33 into an expanded URI reference.
1095     @@Param:
1096     @@@Name: tfpqnames
1097     @@@Type:
1098 wakaba 1.110 DISCore:TFPQNames
1099 wakaba 1.33 @@@Description:
1100     @@@@lang:en
1101     @@@@@:
1102 wakaba 1.47 A <Q::DISCore:TFPQNames> to identify a resource.
1103 wakaba 1.33 @@Param:
1104     @@@Name: defaultTypeURI
1105     @@@Type: NameURI
1106     @@@Description:
1107     @@@@lang:en
1108     @@@@@:
1109     A name URI reference used if it is missing from
1110     <P::tfqnames>.
1111 wakaba 1.49 @@@nullCase:
1112 wakaba 1.33 @@@@Description:
1113     @@@@@lang:en
1114     @@@@@@:
1115     Equivalent to <Q::DOMMain:any>.
1116     @@Param:
1117     @@@Name: defaultForURI
1118     @@@Type: ForURI
1119     @@@Description:
1120     @@@@lang:en
1121     @@@@@:
1122     A <QUOTE::for> URI reference used if it is missing from
1123     <P::tfqnames>.
1124 wakaba 1.49 @@@nullCase:
1125 wakaba 1.33 @@@@Description:
1126     @@@@@lang:en
1127     @@@@@@:
1128     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1129     @@NodeParam:
1130     @@Return:
1131     @@@Type:
1132 wakaba 1.110 DISCore:TFURI
1133 wakaba 1.33 @@@Description:
1134     @@@@lang:en
1135     @@@@@:
1136 wakaba 1.47 The <Q::dis:TFQNames>-expanded URI references.
1137 wakaba 1.33 @@@UndeclaredPrefixException:
1138     @@@PerlDef:
1139     my ($typeq, $forq, @forpq) = split /\s*[:|][:|]\s*/, $tfpqnames;
1140     my ($typeURI, $forURI);
1141     my $forpURI = [];
1142     undef $forq if defined $forq and $forq eq '+';
1143     if (defined $forq) {
1144     __DEEP{
1145     $typeURI = $typeq eq ''
1146     ? defined $defaultTypeURI ? $defaultTypeURI
1147     : <Q::DOMMain:any>
1148 wakaba 1.48 : $self-><M::NSResolverDIS.qnameToURI> ($typeq, %opt);
1149 wakaba 1.33 if (length $forq) {
1150 wakaba 1.48 $forURI = $self-><M::NSResolverDIS.qnameToURI> ($forq, %opt);
1151 wakaba 1.33 } else {
1152     $forURI = <Q::ManakaiDOM:all>;
1153     }
1154     }__;
1155     } else { ## "For" omitted
1156     __DEEP{
1157     $typeURI = $typeq eq ''
1158     ? defined $defaultTypeURI ? $defaultTypeURI
1159     : <Q::DOMMain:any>
1160 wakaba 1.48 : $self-><M::NSResolverDIS.qnameToURI> ($typeq, %opt);
1161 wakaba 1.33 }__;
1162     $forURI = defined $defaultForURI ? $defaultForURI
1163     : <Q::ManakaiDOM:all>;
1164     }
1165     __DEEP{
1166     for my $forpq (@forpq) {
1167 wakaba 1.48 push @$forpURI, $self-><M::NSResolverDIS.qnameToURI>
1168 wakaba 1.33 ($forpq, %opt);
1169     }
1170     }__;
1171     __CODE{tfpurisToURI:: $turi => $typeURI, $furi => $forURI,
1172     $forp => $forpURI, $uri => $r}__;
1173 wakaba 1.48 ##NSResolverDIS
1174    
1175     PropDef:
1176     @QName: defaultNamespaceURI
1177     @enDesc:
1178     Default namespace URI for an element.
1179 wakaba 1.57 @DIS:key: dns
1180 wakaba 1.48
1181     IFClsDef:
1182     @IFQName: DISElement
1183     @ClsQName: ManakaiDISElement
1184    
1185     @ClsISA: ManakaiNSResolverDIS
1186     @ClsISA: ManakaiDISNode
1187     @ClsISA:
1188 wakaba 1.110 swcfg21:ManakaiSWCFGElement
1189 wakaba 1.48 @ClsISA: dp|ManakaiDISElementPerl
1190    
1191     @Description:
1192     @@lang:en
1193     @@@:
1194     <QUOTE::dis> element node objects.
1195    
1196 wakaba 1.33 @Method:
1197 wakaba 1.48 @@Name: forMatch
1198     @@Description:
1199     @@@lang:en
1200     @@@@:
1201     Tests whether this element is for a <QUOTE::for> or not.
1202 wakaba 1.2 @@Param:
1203 wakaba 1.48 @@@Name: forArg
1204     @@@Type: ForURI
1205     @@@Description:
1206     @@@@lang:en
1207     @@@@@:
1208     The <QUOTE::For> URI reference to test against.
1209 wakaba 1.3 @@Param:
1210 wakaba 1.48 @@@Name: forpArg
1211     @@@Type: ForURIList
1212     @@@Description:
1213     @@@@lang:en
1214     @@@@@:
1215     The <QUOTE::For+> URI references to test against.
1216 wakaba 1.49 @@@nullCase:
1217 wakaba 1.48 @@@@Description:
1218     @@@@@lang:en
1219     @@@@@@:
1220     No additional <QUOTE::For> URI reference.
1221     Equivalent to an empty array reference.
1222 wakaba 1.49 @@NamedParam:
1223     @@@Name: databaseArg
1224     @@@Type: DISDatabase
1225     @@@enDesc:
1226     A <QUOTE::dis> database.
1227     @@@nullCase:
1228     @@@@enDesc:
1229     The database associated to the document is used.
1230 wakaba 1.2 @@Return:
1231 wakaba 1.48 @@@Type:
1232 wakaba 1.110 DOMMain:boolean
1233 wakaba 1.48 @@@Description:
1234     @@@@lang:en
1235     @@@@@:
1236     Whether this element is for <P::forArg> and <P::forpArg> or not.
1237     @@@UndeclaredPrefixException:
1238     @@@NoDBException:
1239 wakaba 1.2 @@@PerlDef:
1240 wakaba 1.48 $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
1241     $forpArg ||= [];
1242    
1243     FORMATCH: {
1244     __DEEP{
1245 wakaba 1.49 my $for_res = ($databaseArg ||=
1246     $self-><AG::DISNode.ownerDISDocument>
1247     -><AG::DISDocument.disDatabase>)
1248     -><M::DISDatabase.getFor> ($forArg);
1249 wakaba 1.48 my $forp_res = [map {
1250 wakaba 1.49 $databaseArg-><M::DISDatabase.getFor> ($_)
1251 wakaba 1.48 } @{$forpArg}];
1252    
1253     my @ce = @{$self-><M::ManakaiDISElement.disAllChildElements>};
1254     for my $ce (@ce) {
1255 wakaba 1.110 my $et = $ce-><AG::swcfg21:SWCFGElement
1256 wakaba 1.48 .expandedURI>;
1257     if ($et eq <Q::dis:ForCheck>) {
1258     my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
1259 wakaba 1.110 .value>];
1260 wakaba 1.48 FCs: for my $f (@$fors) {
1261     if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
1262     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($1);
1263 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1264 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1265     for my $arg_res ($for_res, @{$forp_res}) {
1266     if ($arg_res eq $for) {
1267     $r = false;
1268     last FORMATCH;
1269     }
1270     }
1271     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
1272     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($1);
1273 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1274 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1275     for my $arg_res ($for_res, @{$forp_res}) {
1276     if ($arg_res-><M::DISFor.isaURI> ($uri)) {
1277     $r = false;
1278     last FORMATCH;
1279     }
1280     }
1281     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
1282     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($1);
1283 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1284 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1285     for my $arg_res ($for_res, @{$forp_res}) {
1286     if ($arg_res eq $for) {
1287     next FCs;
1288     }
1289     }
1290     $r = false;
1291     last FORMATCH;
1292     } else { ## -- ISA
1293     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($f);
1294 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1295 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1296     for my $arg_res ($for_res, @{$forp_res}) {
1297     if ($arg_res-><M::DISFor.isaURI> ($uri)) {
1298     next FCs;
1299     }
1300     }
1301     $r = false;
1302     last FORMATCH;
1303     }
1304     } # FCs
1305     } # dis:ForCheck
1306     } # children
1307    
1308     my $has_for = false;
1309     for my $ce (@ce) {
1310 wakaba 1.110 if ($ce-><AG::swcfg21:SWCFGElement
1311 wakaba 1.48 .expandedURI> eq
1312     <Q::dis:For>) {
1313     my $fors = [split /\s+/, $ce-><M::swcfg21:SWCFGNode
1314 wakaba 1.110 .value>];
1315 wakaba 1.48 my $ok = true;
1316     $has_for = true;
1317     AFOR: for my $f (@$fors) {
1318     if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
1319     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($1);
1320 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1321 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1322     if ($for eq $for_res) {
1323     $ok = false;
1324     last AFOR;
1325     }
1326     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
1327     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($1);
1328 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1329 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1330     if ($for_res-><M::ManakaiDISForDefinition.isaURI> ($uri)) {
1331     $ok = false;
1332     last AFOR;
1333     }
1334     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
1335     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($1);
1336 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1337 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1338     unless ($for eq $for_res) {
1339     $ok = false;
1340     last AFOR;
1341     }
1342     } else { ## -- ISA
1343     my $uri = $self-><M::NSResolverDIS.qnameToURI> ($f);
1344 wakaba 1.49 my $for = $databaseArg-><M::DISDatabase.getFor> ($uri);
1345 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($ce);
1346     unless ($for_res-><M::ManakaiDISForDefinition.isaURI>($uri)){
1347     $ok = false;
1348     last AFOR;
1349     }
1350     }
1351     } # AFOR
1352     if ($ok) {
1353     $r = true;
1354     last FORMATCH;
1355     }
1356     } # dis:For
1357     } # $ce
1358     $r = $has_for ? false : true;
1359     }__;
1360     } # FORMATCH
1361 wakaba 1.2
1362 wakaba 1.4 @Method:
1363 wakaba 1.48 @@Name: mediaTypeMatch
1364     @@Description:
1365     @@@lang:en
1366     @@@@:
1367     Tests whether the content media type of this element matches to
1368     a type or not.
1369     @@Param:
1370     @@@Name: mediaType
1371     @@@Type: MediaTypeURI
1372     @@@Description:
1373     @@@@lang:en
1374     @@@@@:
1375     A media type URI reference to test against.
1376     @@Param:
1377     @@@Name: defaultMediaType
1378     @@@Type: MediaTypeURI
1379     @@@Description:
1380     @@@@lang:en
1381     @@@@@:
1382     The default media type for this element.
1383 wakaba 1.49 @@@nullCase:
1384 wakaba 1.48 @@@@Description:
1385     @@@@@lang:en
1386     @@@@@@:
1387     No default type provided. All <P::mediaType> will match.
1388 wakaba 1.4 @@ForParam:
1389     @@ForpParam:
1390 wakaba 1.49 @@NamedParam:
1391     @@@Name: databaseArg
1392     @@@Type: DISDatabase
1393     @@@enDesc:
1394     A <QUOTE::dis> database.
1395     @@@nullCase:
1396     @@@@enDesc:
1397     The database associated to the document is used.
1398 wakaba 1.4 @@Return:
1399 wakaba 1.48 @@@Type:
1400 wakaba 1.110 DOMMain:boolean
1401 wakaba 1.48 @@@Description:
1402     @@@@lang:en
1403     @@@@@:
1404     Whether this element is of <P::mediaType> or not.
1405 wakaba 1.2 @@@PerlDef:
1406 wakaba 1.48 if (defined $mediaType) {
1407     __DEEP{
1408 wakaba 1.49 my $ctn = $self-><M::SWCFGNode.getAttributeNS>
1409     (<Q::dis:>, 'ContentType');
1410 wakaba 1.48 my $ct;
1411     $ct = $ctn-><AG::DISElement.qnameValueURI> if $ctn;
1412     $ct = $defaultMediaType unless defined $ct;
1413     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
1414     -><AG::ManakaiDISDocument.disDatabase>
1415     -><M::ManakaiDISDatabase.getResource> ($ct);
1416     $res-><AS::DISAnyResource.isReferred> ($ctn or $self);
1417     unless ($res-><M::ManakaiDISResourceDefinition
1418     .isSubsetOfURI> ($mediaType)) {
1419     $r = false;
1420     } else {
1421     $r = true;
1422     }
1423     }__;
1424     } else {
1425     $r = true;
1426     }
1427 wakaba 1.5
1428 wakaba 1.10 @Method:
1429 wakaba 1.48 @@Name:mediaTypeURI
1430 wakaba 1.10 @@enDesc:
1431 wakaba 1.48 The URI reference of the media type of this element.
1432     @@Type: MediaTypeURI
1433     @@NamedParam:
1434     @@@Name:defaultMediaType
1435     @@@Type:MediaTypeURI
1436     @@@enDesc:
1437     The default media type URI reference.
1438     @@@nullCase:
1439     @@@@enDesc:
1440     No default is specified.
1441     @@ForParam:
1442     @@ForpParam:
1443 wakaba 1.10 @@Return:
1444     @@@enDesc:
1445 wakaba 1.48 The media type URI reference of this element.
1446 wakaba 1.2 @@@nullCase:
1447     @@@@enDesc:
1448 wakaba 1.48 This element has no media type information and
1449     <P::defaultMediaType> parameter is not provided.
1450 wakaba 1.2 @@@UndeclaredPrefixException:
1451 wakaba 1.3 @@@PerlDef:
1452 wakaba 1.48 __DEEP{
1453     $r = $defaultMediaType;
1454 wakaba 1.49 my $ctn = $self-><M::SWCFGNode.getAttributeNS>
1455     (<Q::dis:>, 'ContentType');
1456 wakaba 1.48 $r = $ctn-><AG::DISElement.qnameValueURI> if $ctn;
1457     }__;
1458 wakaba 1.4
1459 wakaba 1.48 @Method:
1460     @@Name: disGetAttribute
1461     @@enDesc:
1462     Gets an attribute node.
1463     @@Param:
1464     @@@Name: attrName
1465     @@@Type: AnyURI
1466     @@@enDesc:
1467     The name expanded URI of the node to retrieve.
1468     @@ForParam:
1469     @@ForpParam:
1470     @@MediaTypeParam:
1471     @@MediaTypeDefaultParam:
1472 wakaba 1.49 @@NamedParam:
1473     @@@Name: databaseArg
1474     @@@Type: DISDatabase
1475     @@@enDesc:
1476     A <QUOTE::dis> database.
1477     @@@nullCase:
1478     @@@@enDesc:
1479     The database associated to the document is used.
1480 wakaba 1.48 @@Return:
1481     @@@Type: DISElement
1482     @@@clsActualType: ManakaiDISElement
1483     @@@enDesc:
1484     The attribute (property) element node.
1485     @@@nullCase:
1486     @@@@enDesc:
1487     No attribute node found.
1488     @@@PerlDef:
1489     C: for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1490 wakaba 1.49 (for_arg => $forArg, forp_arg => $forpArg,
1491     database_arg => $databaseArg)}) {
1492 wakaba 1.110 if ($c-><AG::swcfg21:SWCFGElement
1493 wakaba 1.48 .expandedURI> eq $attrName and
1494     $c-><M::ManakaiDISElement.mediaTypeMatch>
1495     ($mediaType, $defaultMediaType,
1496 wakaba 1.49 for_arg => $forArg, forp_arg => $forpArg,
1497     database_arg => $databaseArg)) {
1498 wakaba 1.48 $r = $c;
1499     last C;
1500     }
1501     }
1502    
1503     @Method:
1504     @@Name: disGetAttributeList
1505     @@enDesc:
1506     Gets attribute nodes.
1507     @@Param:
1508     @@@Name: attrName
1509     @@@Type: AnyURI
1510     @@@enDesc:
1511     The name expanded URI of the node to retrieve.
1512     @@ForParam:
1513     @@ForpParam:
1514     @@MediaTypeParam:
1515     @@MediaTypeDefaultParam:
1516 wakaba 1.49 @@NamedParam:
1517     @@@Name: databaseArg
1518     @@@Type: DISDatabase
1519     @@@enDesc:
1520     A <QUOTE::dis> database.
1521     @@@nullCase:
1522     @@@@enDesc:
1523     The database associated to the document is used.
1524 wakaba 1.48 @@Return:
1525     @@@Type: DISElementList
1526     @@@clsActualType: ManakaiDISElementList
1527     @@@enDesc:
1528     The attribute (property) element nodes.
1529     @@@PerlDef:
1530     $r = bless [], <ClassName::ManakaiDISElementList>;
1531     for my $c (@{$self-><M::ManakaiDISElement.disChildElements>
1532 wakaba 1.49 (for_arg => $forArg, forp_arg => $forpArg,
1533     database_arg => $databaseArg)}) {
1534 wakaba 1.110 if ($c-><AG::swcfg21:SWCFGElement
1535 wakaba 1.48 .expandedURI> eq $attrName and
1536     $c-><M::ManakaiDISElement.mediaTypeMatch>
1537     ($mediaType, $defaultMediaType,
1538 wakaba 1.49 for_arg => $forArg, forp_arg => $forpArg,
1539     database_arg => $databaseArg)) {
1540 wakaba 1.48 push @$r, $c;
1541     }
1542     }
1543    
1544     @Method:
1545     @@Name: disChildElements
1546     @@enDesc:
1547     A list of child elements, with <QUOTE::for> check.
1548     @@ForParam:
1549     @@ForpParam:
1550 wakaba 1.49 @@NamedParam:
1551     @@@Name: databaseArg
1552     @@@Type: DISDatabase
1553     @@@enDesc:
1554     A <QUOTE::dis> database.
1555     @@@nullCase:
1556     @@@@enDesc:
1557     The database associated to the document is used.
1558 wakaba 1.48 @@Return:
1559     @@@Type: DISElementList
1560     @@@clsActualType: ManakaiDISElementList
1561     @@@enDesc:
1562     The current snapshot of child nodes.
1563     @@@PerlDef:
1564     $r = bless [], <ClassName::ManakaiDISElementList>;
1565     __DEEP{
1566 wakaba 1.110 C: for my $cn (@{$self-><AG::swcfg21:SWCFGNode
1567 wakaba 1.48 .childNodes>}) {
1568     ## $cn is an #element.
1569     my $dn;
1570 wakaba 1.110 __CODE{ManakaiNode|getNewReference::
1571 wakaba 1.53 $object => {$cn->{<H::mn:node>}},
1572 wakaba 1.48 $ref => $dn,
1573     $class => {<ClassName::ManakaiDISElement>},
1574     }__;
1575     next C unless $dn-><M::ManakaiDISElement.forMatch>
1576 wakaba 1.49 ($forArg, $forpArg,
1577     database_arg => $databaseArg);
1578 wakaba 1.48 push @$r, $dn;
1579     }
1580     }__;
1581    
1582     @Method:
1583     @@Name: disAllChildElements
1584     @@enDesc:
1585     A list of child elements, without <QUOTE::for> check.
1586     @@Return:
1587     @@@Type: DISElementList
1588     @@@clsActualType: ManakaiDISElementList
1589     @@@enDesc:
1590     The current snapshot of child nodes.
1591     @@@PerlDef:
1592     $r = bless [], <ClassName::ManakaiDISElementList>;
1593     __DEEP{
1594 wakaba 1.110 for my $cn (@{$self-><AG::swcfg21:SWCFGNode
1595 wakaba 1.48 .childNodes>}) {
1596     ## $cn is an #element.
1597     my $dn;
1598 wakaba 1.110 __CODE{ManakaiNode|getNewReference::
1599 wakaba 1.53 $object => {$cn->{<H::mn:node>}},
1600 wakaba 1.48 $ref => $dn,
1601     $class => {<ClassName::ManakaiDISElement>},
1602     }__;
1603     push @$r, $dn;
1604     }
1605     }__;
1606    
1607     @Attr:
1608     @@Name: qnameValueURI
1609     @@enDesc:
1610 wakaba 1.68 The element value (written as <Q::DISCore:QName>), as URI reference.
1611 wakaba 1.48 \
1612     {NOTE:: What should be if list value?
1613     \
1614     }
1615     @@Get:
1616     @@@Type:AnyURI
1617     @@@nullCase:
1618     @@@@enDesc:
1619     No value.
1620     @@@UndeclaredPrefixException:
1621     @@@PerlDef:
1622     __DEEP{
1623 wakaba 1.110 my $v = $self-><M::swcfg21:SWCFGNode.value>;
1624 wakaba 1.48 if (defined $v and not ref $v eq 'ARRAY') {
1625     $r = $self-><M::NSResolverDIS.qnameToURI> ($v, node => $self);
1626     } else {
1627     $r = null;
1628     }
1629     }__;
1630    
1631     @Attr:
1632     @@Name: qnameValueLocalName
1633 wakaba 1.4 @@enDesc:
1634     The local name part of the element value (assumed as
1635 wakaba 1.68 written as <Q::DISCore:QName>).
1636 wakaba 1.4 \
1637     {NOTE:: What should be if list value?
1638     \
1639     }
1640     @@Get:
1641     @@@Type:
1642 wakaba 1.110 DISCore:LocalName
1643 wakaba 1.4 @@@nullCase:
1644     @@@@enDesc:
1645     No value.
1646     @@@PerlDef:
1647     __DEEP{
1648 wakaba 1.110 my $v = $self-><M::swcfg21:SWCFGNode.value>;
1649 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1650 wakaba 1.15 my ($n, $v) = split /\s*[:|]\s*/, $v, 2;
1651 wakaba 1.4 $r = defined $v ? $v : $n;
1652     } else {
1653     $r = null;
1654     }
1655     }__;
1656    
1657     @Attr:
1658 wakaba 1.43 @@Name: qnameValuePrefix
1659     @@enDesc:
1660     The prefix part of the element value (assumed as
1661 wakaba 1.68 written as <Q::DISCore:QName>).
1662 wakaba 1.43 \
1663     {NOTE:: What should be if list value?
1664     \
1665     }
1666     @@Get:
1667     @@@Type:
1668 wakaba 1.110 DISCore:NamespacePrefix
1669 wakaba 1.43 @@@nullCase:
1670     @@@@enDesc:
1671     No value.
1672     @@@PerlDef:
1673     __DEEP{
1674 wakaba 1.110 my $v = $self-><M::swcfg21:SWCFGNode.value>;
1675 wakaba 1.43 if (defined $v and not ref $v eq 'ARRAY') {
1676     my ($p, $l) = split /\s*[:|]\s*/, $v, 2;
1677     $r = defined $l ? $p : null;
1678     } else {
1679     $r = null;
1680     }
1681     }__;
1682    
1683     @Attr:
1684 wakaba 1.4 @@Name: qnameValueNamespaceURI
1685     @@enDesc:
1686     The namespace URI of the element value (assumed as written
1687 wakaba 1.68 in <Q::DISCore:QName>).
1688 wakaba 1.4 \
1689     {NOTE:: What should be if list value?
1690     \
1691     }
1692     @@Get:
1693     @@@Type:AnyURI
1694     @@@nullCase:
1695     @@@@enDesc:
1696     No value.
1697     @@@UndeclaredPrefixException:
1698     @@@PerlDef:
1699     __DEEP{
1700 wakaba 1.110 my $v = $self-><M::swcfg21:SWCFGNode.value>;
1701 wakaba 1.4 if (defined $v and not ref $v eq 'ARRAY') {
1702 wakaba 1.15 my ($p, $v) = split /\s*[:|]\s*/, $v, 2;
1703 wakaba 1.48 $r = $self-><M::NSResolverDIS.prefixToURI>
1704 wakaba 1.4 (defined $v ? $p : null);
1705     } else {
1706     $r = null;
1707     }
1708     }__;
1709 wakaba 1.2
1710 wakaba 1.6 @Method:
1711 wakaba 1.3 @@Name: tfqnamesValueURI
1712 wakaba 1.2 @@enDesc:
1713 wakaba 1.47 The element value (written as <Q::dis:TFQNames>),
1714 wakaba 1.2 as URI reference.
1715     \
1716     {NOTE:: What should be if list value?
1717     \
1718     }
1719 wakaba 1.6 @@Param:
1720     @@@Name: defaultTypeURI
1721     @@@Type: NameURI
1722     @@@Description:
1723     @@@@lang:en
1724     @@@@@:
1725     A name URI reference used if it is missing from
1726     <P::tfqnames>.
1727 wakaba 1.49 @@@nullCase:
1728 wakaba 1.6 @@@@Description:
1729     @@@@@lang:en
1730     @@@@@@:
1731     Equivalent to <Q::DOMMain:any>.
1732     @@Param:
1733     @@@Name: defaultForURI
1734     @@@Type: ForURI
1735     @@@Description:
1736     @@@@lang:en
1737     @@@@@:
1738     A <QUOTE::for> URI reference used if it is missing from
1739     <P::tfqnames>.
1740 wakaba 1.49 @@@nullCase:
1741 wakaba 1.6 @@@@Description:
1742     @@@@@lang:en
1743     @@@@@@:
1744     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1745 wakaba 1.33 @@ForParam:
1746     @@ForpParam:
1747 wakaba 1.49 @@NamedParam:
1748     @@@Name:databaseArg
1749     @@@Type:DISDatabase
1750 wakaba 1.6 @@Return:
1751 wakaba 1.2 @@@Type:ResourceURI
1752     @@@nullCase:
1753     @@@@enDesc:
1754     No value.
1755     @@@UndeclaredPrefixException:
1756 wakaba 1.3 @@@PerlDef:
1757 wakaba 1.110 my $v = $self-><M::swcfg21:SWCFGNode.value>;
1758 wakaba 1.2 if (defined $v and not ref $v eq 'ARRAY') {
1759     __DEEP{
1760 wakaba 1.33 if ($self-><M::ManakaiDISElement.mediaTypeMatch>
1761 wakaba 1.48 (<Q::DISCore:TFPQNames>, <Q::DISCore:TFPQNames>,
1762 wakaba 1.49 for_arg => $forArg, forp_arg => $forpArg,
1763     database_arg => $databaseArg)) {
1764 wakaba 1.48 $r = $self-><M::NSResolverDIS.tfpqnamesToURI>
1765 wakaba 1.33 ($v, $defaultTypeURI, $defaultForURI,
1766     node => $self);
1767     } else {
1768 wakaba 1.48 $r = $self-><M::NSResolverDIS.tfqnamesToURI>
1769 wakaba 1.33 ($v, $defaultTypeURI, $defaultForURI,
1770     node => $self);
1771     }
1772 wakaba 1.2 }__;
1773     } else {
1774     $r = null;
1775     }
1776 wakaba 1.7
1777     @Method:
1778     @@Name: elementTypeMatch
1779     @@enDesc:
1780     Returns whether the element type of this element matches
1781     with another element type (either the same element type or
1782     this type is a subtype of another type).
1783     @@Param:
1784     @@@Name: etype
1785     @@@Type: ResourceURI
1786     @@@enDesc:
1787     An element type name URI reference to test.
1788 wakaba 1.89 @@NamedParam:
1789     @@@Name: srinfo
1790 wakaba 1.110 @@@Type: DISPerl|HASH
1791 wakaba 1.89 @@@enDesc:
1792     The <CODE::srinfo> hash.
1793     @@@nullCase:
1794     @@@@enDesc:
1795     No <CODE::srinfo>.
1796 wakaba 1.7 @@Return:
1797     @@@Type:
1798 wakaba 1.110 DOMMain:boolean
1799 wakaba 1.7 @@@TrueCase:
1800     @@@@enDesc:
1801     Either the element type expanded URI reference of this element is
1802     same as <P::etype> or it is a sub-element type of <P::etype>.
1803     @@@FalseCase:
1804     @@@@enDesc:
1805     This element is not of <P::etype>.
1806     @@@NoDBException:
1807     @@@PerlDef:
1808     __DEEP{
1809 wakaba 1.110 my $et = $self->expanded_uri;
1810 wakaba 1.7 my $rdef = $self-><AG::ManakaiDISNode.ownerDISDocument>
1811     -><AG::ManakaiDISDocument.disDatabase>
1812     -><M::ManakaiDISDatabase.getResource> ($et);
1813 wakaba 1.89 $r = $rdef-><M::DISResource.isSubsetOfURI>
1814     ($etype, srinfo => $srinfo);
1815 wakaba 1.7 }__;
1816    
1817     @Attr:
1818     @@Name: isResourceElement
1819     @@enDesc:
1820     Whether this element defines a resource or not.
1821     \
1822     {NOTE:: An element defines a resource if its element type is
1823     <Q::dis:ResourceDef> or its subtype.
1824     \
1825     }
1826     @@Get:
1827     @@@Type:
1828 wakaba 1.110 DOMMain:boolean
1829 wakaba 1.7 @@@TrueCase:
1830     @@@@enDesc:
1831     This element defines a resource.
1832     @@@FalseCase:
1833     @@@@enDesc:
1834     This element does not define any resource.
1835     @@@NoDBException:
1836     @@@PerlDef:
1837     __DEEP{
1838 wakaba 1.49 $r = ($self-><AG::SWCFGElement.expandedURI> eq <Q::dis:ResourceDef>);
1839 wakaba 1.7 }__;
1840    
1841 wakaba 1.49 @Method:
1842 wakaba 1.7 @@Name: isPropertyElement
1843     @@enDesc:
1844     Whether this element is a property or not.
1845     \
1846 wakaba 1.81 {NOTE:: An element is a property if the resource whose
1847     URI is equal to the element type name is a property,
1848     i.e. whose type is <Q::DISSource|Property>.
1849 wakaba 1.7 }
1850 wakaba 1.49 @@NamedParam:
1851     @@@Name: databaseArg
1852     @@@Type: DIS|DISDatabase
1853     @@@nullCase:
1854     @@Return:
1855 wakaba 1.7 @@@Type:
1856 wakaba 1.110 DOMMain:boolean
1857 wakaba 1.7 @@@TrueCase:
1858     @@@@enDesc:
1859     This element is a property.
1860     @@@FalseCase:
1861     @@@@enDesc:
1862     This element is not a property.
1863     @@@NoDBException:
1864     @@@PerlDef:
1865     __DEEP{
1866 wakaba 1.48 my $xn = $self-><AG::SWCFGElement.expandedURI>;
1867 wakaba 1.81 if ($xn eq <Q::DISCore|resourceType> or $xn eq <Q::rdf:type>) {
1868 wakaba 1.7 $r = true;
1869     } else {
1870 wakaba 1.49 my $rdef = ($databaseArg or
1871     $self-><AG::DISNode.ownerDISDocument>
1872     -><AG::DISDocument.disDatabase>)
1873     -><M::DISDatabase.getResource> ($xn);
1874 wakaba 1.81 $r = $rdef-><M::DISAnyResource.isTypeURI>
1875     (<Q::DISSource|Property>) ||
1876     $rdef-><M::DISAnyResource.isTypeURI> (<Q::rdf:Property>);
1877     ## TODO: Remove this.
1878 wakaba 1.18 }
1879     }__;
1880 wakaba 1.19
1881     @Method:
1882 wakaba 1.48 @@Name: unlinkFromDocument
1883     @@enDesc:
1884     Removes any relationship to this node from the owner document tree.
1885     In addition, namespace bindings are copied from the document.
1886     The node <kwd:MUST> be a cloned one (or just newly created one)
1887     so that it does not have any parent-child relationship.
1888    
1889     {NOTE:: Once a subtree has removed from the document, the nodes
1890     belongs to the subtree can't be part of any document anymore.
1891     }
1892 wakaba 1.49 @@Param:
1893     @@@Name: databaseArg
1894     @@@Type: DISDatabase
1895     @@@enDesc:
1896     The <QUOTE::dis> database.
1897 wakaba 1.48 @@Return:
1898     @@@PerlDef:
1899     __DEEP{
1900 wakaba 1.53 my $ods = $self->{<H::mn:node>}->{<H::swcfg21:ownerDocument>};
1901     $self->{<H::mn:node>}->{<H::swcfg21:nsBinding>}
1902 wakaba 1.49 = $self-><M::DISElement.getNamespaceBindingList> ($databaseArg);
1903 wakaba 1.53 $self->{<H::mn:node>}->{<H::DIS|defaultNamespaceURI>}
1904 wakaba 1.49 = ${$self-><M::DISElement.getDefaultNamespaceURIRef>};
1905 wakaba 1.53 my @nodes = ($self->{<H::mn:node>});
1906 wakaba 1.49 while (defined (my $node = shift @nodes)) {
1907 wakaba 1.53 CORE::delete $node->{<H::swcfg21:ownerDocument>};
1908     push @nodes, grep {$_} @{$node->{<H::swcfg21:childNodes>}},
1909     $node->{<H::swcfg21:shadowContent>},
1910     $node->{<H::swcfg21:shadowSibling>};
1911 wakaba 1.49 }
1912 wakaba 1.53 $self->{<H::mn:node>}
1913 wakaba 1.110 -><M::ManakaiNode|NodeStem.orphanate>;
1914 wakaba 1.49 }__;
1915    
1916     @Method:
1917     @@Name: getNamespaceBindingList
1918     @@enDesc:
1919     Returns the <QUOTE::live> hash reference of namespace bindings.
1920 wakaba 1.110 @@Type: DISPerl|HASH
1921 wakaba 1.49 @@Param:
1922     @@@Name: databaseArg
1923     @@@Type: DISDatabase
1924     @@@enDesc:
1925     The <QUOTE::dis> database.
1926     @@Return:
1927     @@@PerlDef:
1928 wakaba 1.53 my $ods = $self->{<H::mn:node>}->{<H::swcfg21:ownerDocument>};
1929     if ($ods->{<H::DIS|allNSBindings>}) {
1930     $r = $ods->{<H::DIS|allNSBindings>};
1931 wakaba 1.49 } else {
1932     if ($databaseArg) {
1933     for my $mod_uri (keys %{$databaseArg->{modDef}}) {
1934     my $mod = $databaseArg-><M::DISDatabase.getModule> ($mod_uri);
1935 wakaba 1.53 $ods->{<H::DIS|allNSBindings>}
1936 wakaba 1.49 ->{$mod-><AG::DISAnyResource.localName>}
1937 wakaba 1.57 = $mod-><AG::DIS|DISModule.targetNamespaceURI>;
1938 wakaba 1.48 }
1939     }
1940 wakaba 1.53 for my $prefix (keys %{$ods->{<H::swcfg21:nsBinding>}}) {
1941     $ods->{<H::DIS|allNSBindings>}->{$prefix}
1942     = $ods->{<H::swcfg21:nsBinding>}->{$prefix};
1943 wakaba 1.48 }
1944 wakaba 1.53 $r = $ods->{<H::DIS|allNSBindings>};
1945 wakaba 1.49 }
1946    
1947     @Method:
1948     @@Name: getDefaultNamespaceURIRef
1949     @@enDesc: A reference to the URI of the default namespace.
1950 wakaba 1.110 @@Type: DISPerl|SCALAR
1951 wakaba 1.49 @@Return:
1952     @@@PerlDef:
1953 wakaba 1.53 my $ods = $self->{<H::mn:node>}->{<H::swcfg21:ownerDocument>};
1954     if ($ods->{<H::DIS|defaultNamespaceURI>}) {
1955     $r = \ ($ods->{<H::DIS|defaultNamespaceURI>});
1956 wakaba 1.49 } else {
1957     __DEEP{
1958 wakaba 1.53 $r = \($ods->{<H::DIS|defaultNamespaceURI>}
1959 wakaba 1.49 = $self-><AG::DISNode.ownerDISDocument>
1960     -><AG::DISDocument.moduleElement>
1961     -><AG::DISModuleElement.definingNamespaceURI>);
1962     }__;
1963     }
1964    
1965 wakaba 1.48
1966     @Method:
1967     @@Name: preserveNodePath
1968     @@enDesc:
1969     Saves a copy of node path string.
1970     @@Return:
1971     @@@PerlDef:
1972     __DEEP{
1973     $self-><M::SWCFGNode.flag> (nodePath => $self-><M::SWCFGNode.nodePath>
1974     (key => [qw/QName Name Type type/]));
1975     }__;
1976    
1977     @Method:
1978     @@Operator:
1979 wakaba 1.68 @@@ContentType: DISCore|QName
1980 wakaba 1.48 @@@@:
1981     DISPerl:CloneMethod
1982 wakaba 1.19 @@Description:
1983     @@@lang:en
1984     @@@@:
1985 wakaba 1.48 Makes a copy of this node. All child nodes are cloned and
1986     all flags and options are copied (rather than cloned).
1987     The new node does not have any parent.
1988     @@Return:
1989     @@@Type: DISElement
1990 wakaba 1.19 @@@Description:
1991     @@@@lang:en
1992     @@@@@:
1993 wakaba 1.48 The cloned node.
1994     \
1995     If this node is a document node, then the another document is made.
1996     @@@PerlDef:
1997     $r = bless $self->SUPER::clone, <ClassName::ManakaiDISElement>;
1998     ##DISElement
1999 wakaba 1.19
2000 wakaba 1.49 PropDef:
2001     @QName: allNSBindings
2002     @enDesc:
2003     Collected set of namespace bindings for a node.
2004    
2005 wakaba 1.81 ResourceTypeDef:
2006     @QName: DIS|AnyMethod
2007     @enDesc:
2008     A method or attribute for particular resource types.
2009     @subsetOf: DISLang|AnyMethod
2010    
2011     ResourceTypeDef:
2012     @QName: DIS|Method
2013     @enDesc:
2014     A method for particular resource types.
2015     @subsetOf: DISLang|Method
2016     @subsetOf: DIS|AnyMethod
2017    
2018     ResourceTypeDef:
2019     @QName: DIS|Attribute
2020     @enDesc:
2021     A attribute for particular resource types.
2022     @subsetOf: DISLang|Attribute
2023     @subsetOf: DIS|AnyMethod
2024    
2025     RPropDef:
2026     @QName: DIS|targetType
2027     @enDesc:
2028     A resource type for which the method is applied.
2029     @rdfs:range: DISCore|ResourceType
2030     @rdfs:domain: DIS|Method
2031     @dataType: DISCore|QName
2032     @multipleProperties: DISCore|UnorderedList
2033    
2034     ResourceDef:
2035     @QName: DISString
2036 wakaba 1.110 @AliasFor: DISLang|String
2037 wakaba 1.81
2038     ElementTypeBinding:
2039     @Name: ResourceTypeDef
2040     @ElementType:
2041     dis:ResourceDef
2042     @ShadowContent:
2043     @@DISCore:resourceType: DISCore|ResourceType
2044    
2045 wakaba 1.47 IFClsDef:
2046     @IFQName: DISModuleElement
2047     @ClsQName: ManakaiDISModuleElement
2048 wakaba 1.19
2049 wakaba 1.47 @IFISA: DISElement
2050 wakaba 1.4 @ClsISA: ManakaiDISElement
2051 wakaba 1.47
2052 wakaba 1.4 @enDesc:
2053     The <Q::dis:Module> elements.
2054    
2055     @Attr:
2056     @@Name: requireElement
2057     @@enDesc:
2058     The <Q::dis:Require> child element. The element is
2059     newly created if not exist.
2060 wakaba 1.47 @@Type: DISElement
2061     @@clsActualType: ManakaiDISElement
2062 wakaba 1.4 @@Get:
2063     @@@PerlDef:
2064     __DEEP{
2065 wakaba 1.29 $r = bless $self-><M::swcfg21:SWCFGNode
2066 wakaba 1.110 .getAttributeNS>
2067 wakaba 1.29 (<Q::dis:>, 'Require', make_new_node => true),
2068     <ClassName::ManakaiDISElement>;
2069 wakaba 1.4 }__;
2070 wakaba 1.7
2071     @Attr:
2072     @@Name: definingNamespaceURI
2073     @@enDesc:
2074 wakaba 1.48 The value of <Q::dis:Namespace> attribute, i.e.
2075 wakaba 1.7 the URI reference of the namespace that this module primary
2076     defines.
2077     \
2078     {NOTE:: Defining namespace URI is <QUOTE::for> independent.
2079     \
2080     }
2081     @@Type: AnyURI
2082     @@Get:
2083     @@@PerlDef:
2084     __DEEP{
2085 wakaba 1.110 my $df = $self-><M::swcfg21:SWCFGNode
2086 wakaba 1.7 .getAttributeNS>
2087     (<Q::dis:>, 'Namespace');
2088     if ($df) {
2089 wakaba 1.110 $r = $df->value;
2090 wakaba 1.7 } else {
2091     __ASSERT{DISPerl:invariant::
2092     msg => {qq["dis:Namespace" attribute not found]},
2093     }__;
2094     }
2095     }__;
2096     @@Set:
2097     @@@PerlDef:
2098     __DEEP{
2099 wakaba 1.110 $self-><M::swcfg21:SWCFGNode.setAttributeNS>
2100 wakaba 1.7 (<Q::dis:>, 'Namespace' => $given);
2101     }__;
2102 wakaba 1.4 ##DISModuleElement
2103    
2104 wakaba 1.47 IFClsDef:
2105     @IFQName: DISElementList
2106 wakaba 1.2 @ClsQName: ManakaiDISElementList
2107 wakaba 1.47
2108 wakaba 1.2 @enDesc:
2109     @@lang:en
2110     @@@:
2111     Lists of elements.
2112     \
2113     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
2114     later changes to the tree does not affect this type of objects.
2115     \
2116     }
2117     ##DISElementList
2118    
2119 wakaba 1.47 IFClsDef:
2120     @IFQName: DISComment
2121 wakaba 1.1 @ClsQName: ManakaiDISComment
2122 wakaba 1.47
2123 wakaba 1.7 @ClsISA: ManakaiDISNode
2124 wakaba 1.1 @ClsISA:
2125 wakaba 1.110 swcfg21:ManakaiSWCFGComment
2126 wakaba 1.47
2127 wakaba 1.1 @Description:
2128     @@lang:en
2129     @@@:
2130     <QUOTE::dis> comment node objects.
2131     ##DISComment
2132    
2133 wakaba 1.47 IFClsDef:
2134     @IFQName: DISDocumentFragment
2135 wakaba 1.1 @ClsQName: ManakaiDISDocumentFragment
2136 wakaba 1.47
2137 wakaba 1.7 @ClsISA: ManakaiDISNode
2138 wakaba 1.1 @ClsISA:
2139 wakaba 1.110 swcfg21:ManakaiSWCFGDocumentFragment
2140 wakaba 1.47
2141 wakaba 1.1 @Description:
2142     @@lang:en
2143     @@@:
2144     <QUOTE::dis> document fragment node objects.
2145     ##DISDocumentFragment
2146    
2147 wakaba 1.47 IFClsDef:
2148     @IFQName: DISDocument
2149 wakaba 1.1 @ClsQName: ManakaiDISDocument
2150 wakaba 1.47
2151 wakaba 1.7 @ClsISA: ManakaiDISNode
2152 wakaba 1.1 @ClsISA:
2153 wakaba 1.110 swcfg21:ManakaiSWCFGDocument
2154 wakaba 1.47
2155 wakaba 1.1 @Description:
2156     @@lang:en
2157     @@@:
2158     <QUOTE::dis> document node objects.
2159 wakaba 1.2
2160     @Attr:
2161 wakaba 1.4 @@Name: moduleElement
2162     @@enDesc:
2163     The <Q::dis:Module> element in this document. The element is
2164     newly created if not exist.
2165 wakaba 1.47 @@Type: DISModuleElement
2166     @@clsActualType: ManakaiDISModuleElement
2167 wakaba 1.4 @@Get:
2168     @@@PerlDef:
2169     __DEEP{
2170     $r = $self-><M::swcfg21:SWCFGNode
2171 wakaba 1.110 .getAttributeNS>
2172 wakaba 1.4 (<Q::dis:>, 'Module', make_new_node => true);
2173     }__;
2174     $r = bless $r, <ClassName::ManakaiDISModuleElement>;
2175    
2176     @Attr:
2177 wakaba 1.2 @@Name: disDatabase
2178     @@enDesc:
2179     Associated <QUOTE::dis> database.
2180    
2181 wakaba 1.47 @@Type: DISDatabase
2182     @@clsActualType: ManakaiDISDatabase
2183 wakaba 1.2 @@Get:
2184     @@@NoDBException:
2185     @@@PerlDef:
2186 wakaba 1.53 if ($self->{<H::mn:node>}->{<H::DIS|db>}) {
2187     $r = $self->{<H::mn:node>}->{<H::DIS|db>};
2188 wakaba 1.2 } else {
2189     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
2190     }
2191     @@Set:
2192     @@@PerlDef:
2193 wakaba 1.53 $self->{<H::mn:node>}->{<H::DIS|db>} = $given;
2194 wakaba 1.2 require Scalar::Util;
2195 wakaba 1.53 Scalar::Util::weaken ($self->{<H::mn:node>}->{<H::DIS|db>});
2196 wakaba 1.5
2197     @Method:
2198     @@Name: disChildElements
2199     @@enDesc:
2200 wakaba 1.10 A list of child elements, with <QUOTE::for> checks.
2201 wakaba 1.5 @@ForParam:
2202     @@ForpParam:
2203 wakaba 1.49 @@NamedParam:
2204     @@@Name: databaseArg
2205     @@@Type: DISDatabase
2206     @@@enDesc:
2207     A <QUOTE::dis> database.
2208     @@@nullCase:
2209     @@@@enDesc:
2210     The database associated to the document is used.
2211 wakaba 1.5 @@Return:
2212 wakaba 1.47 @@@Type: DISElementList
2213     @@@clsActualType: ManakaiDISElementList
2214 wakaba 1.5 @@@enDesc:
2215     The current snapshot of child nodes.
2216     @@@PerlDef:
2217     $r = bless [], <ClassName::ManakaiDISElementList>;
2218     __DEEP{
2219 wakaba 1.110 C: for my $cn (@{$self-><AG::swcfg21:SWCFGNode
2220 wakaba 1.5 .childNodes>}) {
2221 wakaba 1.110 next C unless $cn-><AG::swcfg21:SWCFGNode
2222 wakaba 1.5 .nodeType> eq '#element';
2223 wakaba 1.47 my $dn;
2224 wakaba 1.110 __CODE{ManakaiNode|getNewReference::
2225 wakaba 1.53 $object => {$cn->{<H::mn:node>}},
2226 wakaba 1.47 $ref => $dn,
2227     $class => {<ClassName::ManakaiDISElement>},
2228     }__;
2229     next C unless $dn-><M::ManakaiDISElement.forMatch>
2230 wakaba 1.49 ($forArg, $forpArg,
2231     database_arg => $databaseArg);
2232 wakaba 1.5 push @$r, $dn;
2233     }
2234     }__;
2235 wakaba 1.10
2236     @Method:
2237     @@Name: disAllChildElements
2238     @@enDesc:
2239     A list of child elements, without <QUOTE::for> checks.
2240     @@Return:
2241 wakaba 1.47 @@@Type: DISElementList
2242     @@@clsActualType: ManakaiDISElementList
2243 wakaba 1.10 @@@enDesc:
2244     The current snapshot of child nodes.
2245     @@@PerlDef:
2246     $r = bless [], <ClassName::ManakaiDISElementList>;
2247     __DEEP{
2248 wakaba 1.110 C: for my $cn (@{$self-><AG::swcfg21:SWCFGNode
2249 wakaba 1.10 .childNodes>}) {
2250 wakaba 1.110 next C unless $cn-><AG::swcfg21:SWCFGNode
2251 wakaba 1.10 .nodeType> eq '#element';
2252 wakaba 1.47 my $dn;
2253 wakaba 1.110 __CODE{ManakaiNode|getNewReference::
2254 wakaba 1.53 $object => {$cn->{<H::mn:node>}},
2255 wakaba 1.47 $ref => $dn,
2256     $class => {<ClassName::ManakaiDISElement>},
2257     }__;
2258 wakaba 1.10 push @$r, $dn;
2259     }
2260     }__;
2261 wakaba 1.51
2262     @Method:
2263     @@Name: addNamespaceBinding
2264     @@Param:
2265     @@@Name: prefix
2266 wakaba 1.110 @@@Type: DISLang|String
2267 wakaba 1.51 @@Param:
2268     @@@Name: namespaceURI
2269 wakaba 1.110 @@@Type: DISLang|String
2270 wakaba 1.51 @@@nullCase:
2271     @@Return:
2272     @@@PerlDef:
2273     if (defined $namespaceURI) {
2274 wakaba 1.53 $self->{<H::mn:node>}->{<H::swcfg21:nsBinding>}->{$prefix}
2275 wakaba 1.51 = $namespaceURI;
2276     } else {
2277 wakaba 1.53 CORE::delete $self->{<H::mn:node>}->{<H::swcfg21:nsBinding>}
2278 wakaba 1.51 ->{$prefix};
2279     }
2280 wakaba 1.88
2281     @Attr:
2282     @@Name: disNamespaceResolver
2283     @@enDesc:
2284     A namespace resolver code that is called by
2285 wakaba 1.110 <M::swcfg21|SWCFGNode.lookupNamesopaceURI> method
2286 wakaba 1.88 when in-document namespace binding information is not sufficient.
2287 wakaba 1.110 @@Type: DISPerl|CODE
2288 wakaba 1.88 @@Get:
2289     @@@PerlDef:
2290     $r = $self->{<H::mn:node>}->{<H::DIS|disNamespaceResolver>};
2291     @@Set:
2292     @@@PerlDef:
2293     $self->{<H::mn:node>}->{<H::DIS|disNamespaceResolver>} = $given;
2294 wakaba 1.1 ##DISDocument
2295 wakaba 1.2
2296     PropDef:
2297 wakaba 1.88 @QName: DIS|disNamespaceResolver
2298    
2299     PropDef:
2300 wakaba 1.2 @QName: db
2301     @enDesc:
2302     Associated <QUOTE::dis> database.
2303     @rdfs:domain: ManakaiDISDocument
2304     @rdfs:range: ManakaiDISDatabase
2305    
2306     ## -- Definition object database
2307    
2308 wakaba 1.47 IFClsDef:
2309     @IFQName: DISDatabase
2310 wakaba 1.2 @ClsQName: ManakaiDISDatabase
2311 wakaba 1.47
2312 wakaba 1.48 @ClsISA: dp|ManakaiDISDatabasePerl
2313 wakaba 1.47
2314 wakaba 1.2 @enDesc:
2315     Resource database created from <QUOTE::dis> source data.
2316    
2317     @Method:
2318     @@Name: getModule
2319     @@Description:
2320     @@@lang:en
2321     @@@@:
2322     Returns a <QUOTE::dis> module definition.
2323     @@Param:
2324 wakaba 1.9 @@@Name: moduleURI
2325 wakaba 1.2 @@@Type: ModuleURI
2326     @@@Description:
2327     @@@@lang:en
2328     @@@@@:
2329     A <QUOTE::dis> module URI reference.
2330 wakaba 1.9 @@ForParam:
2331 wakaba 1.2 @@Return:
2332 wakaba 1.47 @@@Type: DISModule
2333     @@@clsActualType: ManakaiDISModuleDefinition
2334 wakaba 1.2 @@@Description:
2335     @@@@lang:en
2336     @@@@@:
2337     The module definition.
2338     @@@PerlDef:
2339 wakaba 1.9 my $modURI;
2340     if (defined $forArg) {
2341     __CODE{tfurisToURI:: $turi => $moduleURI, $furi => $forArg,
2342     $uri => $modURI}__;
2343     } else {
2344     $modURI = $moduleURI;
2345     }
2346 wakaba 1.2 if (defined $self->{modDef}->{$modURI}) {
2347     $r = $self->{modDef}->{$modURI};
2348     } else {
2349     $r = $self->{modDef}->{$modURI}
2350     = bless {
2351     uri => $modURI,
2352     db => $self,
2353     forp => [],
2354 wakaba 1.79 <H::DIS|typeURI> => <Q::DISCore|Module>,
2355     <H::DIS|revision> => 0,
2356 wakaba 1.2 }, <ClassName::ManakaiDISModuleDefinition>;
2357     require Scalar::Util;
2358     Scalar::Util::weaken ($r->{db});
2359 wakaba 1.110 __CODE{DISPerl|HashStringRef::
2360 wakaba 1.89 $result => {$r->{for}},
2361     $given => {<Q::ManakaiDOM|all>},
2362     }__;
2363 wakaba 1.2 }
2364    
2365 wakaba 1.79 @@Test:
2366     @@@QName: DISDB.getModule.test
2367     @@@PerlDef:
2368     my $db;
2369     __CODE{createDISDBForTest:: $db => $db}__;
2370    
2371     my $res = $db-><M::DISDatabase.getModule> ('about:1');
2372    
2373     $test->id ('is.type.uri');
2374     $test->assert_true ($res-><M::DISAnyResource.isTypeURI>
2375     (<Q::DISCore|Module>));
2376     $test->assert_true ($res-><M::DISAnyResource.isTypeURI>
2377     (<Q::DISCore|AnyResource>));
2378    
2379     $test->id ('revision');
2380     $test->assert_num_equals
2381     (actual_value => $res-><AG::DISAnyResource.revision>,
2382     expected_value => 0);
2383    
2384 wakaba 1.2 @Method:
2385     @@Name: getFor
2386     @@Description:
2387     @@@lang:en
2388     @@@@:
2389     Returns a <QUOTE::for> definition object.
2390     @@Param:
2391     @@@Name: forURI
2392     @@@Type: ForURI
2393     @@@Description:
2394     @@@@lang:en
2395     @@@@@:
2396     A <QUOTE::for> URI reference.
2397 wakaba 1.49 @@@nullCase:
2398 wakaba 1.2 @@@@Description:
2399     @@@@@lang:en
2400     @@@@@@:
2401     Defaulted to <Q::ManakaiDOM:all>.
2402     @@Return:
2403 wakaba 1.47 @@@Type: DISFor
2404     @@@clsActualType: ManakaiDISForDefinition
2405 wakaba 1.2 @@@PerlDef:
2406     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
2407     if (defined $self->{forDef}->{$forURI}) {
2408     $r = $self->{forDef}->{$forURI};
2409 wakaba 1.55 } elsif (defined $self->{<H::DIS|resourceModuleMap>}->{$forURI}) {
2410     __DEEP{
2411     $self-><M::dp|ManakaiDISDatabasePerl.plLoadDISDatabaseModule>
2412     ($self-><M::DIS|DISDatabase.getModule>
2413     (${$self->{<H::DIS|resourceModuleMap>}->{$forURI}}));
2414     }__;
2415     unless (defined $self->{forDef}->{$forURI}) {
2416     __EXCEPTION{DIS|RESOURCE_NOT_DEFINED_ERR::
2417     DIS:uri => {$forURI},
2418     DIS:moduleURI => {${$self->{<H::DIS|resourceModuleMap>}
2419     ->{$forURI}}},
2420     }__;
2421     }
2422     $r = $self->{forDef}->{$forURI};
2423 wakaba 1.2 } else {
2424     $r = $self->{forDef}->{$forURI}
2425     = bless {
2426     uri => $forURI,
2427     isa => {<Q::ManakaiDOM:all> => true},
2428     revISA => {},
2429     db => $self,
2430 wakaba 1.79 <H::DIS|typeURI> => <Q::DISCore|For>,
2431     <H::DIS|revision> => 0,
2432 wakaba 1.2 }, <ClassName::ManakaiDISForDefinition>;
2433     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
2434     require Scalar::Util;
2435     Scalar::Util::weaken ($r->{db});
2436     }
2437    
2438 wakaba 1.79 @@Test:
2439     @@@QName: DISDB.getFor.test
2440     @@@PerlDef:
2441     my $db;
2442     __CODE{createDISDBForTest:: $db => $db}__;
2443    
2444     my $res = $db-><M::DISDatabase.getFor> ('about:1');
2445    
2446     $test->id ('is.type.uri');
2447     $test->assert_true ($res-><M::DISAnyResource.isTypeURI>
2448     (<Q::DISCore|For>));
2449     $test->assert_true ($res-><M::DISAnyResource.isTypeURI>
2450     (<Q::DISCore|AnyResource>));
2451    
2452     $test->id ('revision');
2453     $test->assert_num_equals
2454     (actual_value => $res-><AG::DISAnyResource.revision>,
2455     expected_value => 0);
2456    
2457 wakaba 1.2 @Method:
2458     @@Name: getResource
2459     @@Description:
2460     @@@lang:en
2461     @@@@:
2462     Returns a <QUOTE::dis> resource definition.
2463     @@Param:
2464 wakaba 1.9 @@@Name: resourceURI
2465 wakaba 1.2 @@@Type: ResourceURI
2466     @@@Description:
2467     @@@@lang:en
2468     @@@@@:
2469     A <QUOTE::dis> resource URI reference.
2470 wakaba 1.3 @@@nullCase:
2471 wakaba 1.2 @@@@Description:
2472     @@@@@lang:en
2473     @@@@@@:
2474     Defaulted to <Q::DOMMain:any>.
2475 wakaba 1.9 @@ForParam:
2476 wakaba 1.2 @@Return:
2477 wakaba 1.47 @@@Type: DISResource
2478     @@@clsActualType: ManakaiDISResourceDefinition
2479 wakaba 1.2 @@@Description:
2480     @@@@lang:en
2481     @@@@@:
2482     The resource definition.
2483 wakaba 1.54 @@@RaiseException:
2484     @@@@@: DIS|RESOURCE_NOT_DEFINED_ERR
2485     @@@@enDesc:
2486     The resource should be included in database submodule but
2487     it is not.
2488 wakaba 1.2 @@@PerlDef:
2489 wakaba 1.9 $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
2490     my $resURI;
2491     if (defined $forArg) {
2492     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
2493     $uri => $resURI}__;
2494     } else {
2495     $resURI = $resourceURI;
2496     }
2497 wakaba 1.54
2498 wakaba 1.2 if (defined $self->{resDef}->{$resURI}) {
2499     $r = $self->{resDef}->{$resURI};
2500 wakaba 1.54 } elsif (defined $self->{<H::DIS|resourceModuleMap>}->{$resURI}) {
2501     __DEEP{
2502     $self-><M::dp|ManakaiDISDatabasePerl.plLoadDISDatabaseModule>
2503     ($self-><M::DIS|DISDatabase.getModule>
2504     (${$self->{<H::DIS|resourceModuleMap>}->{$resURI}}));
2505     }__;
2506     unless (defined $self->{resDef}->{$resURI}) {
2507     __EXCEPTION{DIS|RESOURCE_NOT_DEFINED_ERR::
2508     DIS:uri => {$resURI},
2509     DIS:moduleURI => {${$self->{<H::DIS|resourceModuleMap>}
2510     ->{$resURI}}},
2511     }__;
2512     }
2513     $r = $self->{resDef}->{$resURI};
2514 wakaba 1.2 } else {
2515     $r = $self->{resDef}->{$resURI}
2516     = bless {
2517     uri => $resURI,
2518 wakaba 1.6 aliasURI => {$resURI => true},
2519 wakaba 1.2 db => $self,
2520     forp => [],
2521 wakaba 1.9 seq => -1,
2522 wakaba 1.79 <H::DIS|typeURI> => <Q::DISCore|Resource>,
2523     <H::DIS|revision> => 0,
2524 wakaba 1.2 }, <ClassName::ManakaiDISResourceDefinition>;
2525     require Scalar::Util;
2526     Scalar::Util::weaken ($r->{db});
2527 wakaba 1.110 __CODE{DISPerl|HashStringRef::
2528 wakaba 1.89 $result => {$r->{for}},
2529     $given => {<Q::ManakaiDOM|all>},
2530     }__;
2531 wakaba 1.2 }
2532 wakaba 1.3
2533 wakaba 1.79 @@Test:
2534     @@@QName: DISDB.getResource.test
2535     @@@PerlDef:
2536     my $db;
2537     __CODE{createDISDBForTest:: $db => $db}__;
2538    
2539     my $res = $db-><M::DISDatabase.getResource> ('about:1');
2540    
2541    
2542     $test->id ('is.type.uri');
2543     $test->assert_true ($res-><M::DISAnyResource.isTypeURI>
2544     (<Q::DISCore|Resource>));
2545     $test->assert_true ($res-><M::DISAnyResource.isTypeURI>
2546     (<Q::DISCore|AnyResource>));
2547    
2548     $test->id ('revision');
2549     $test->assert_num_equals
2550     (actual_value => $res-><AG::DISAnyResource.revision>,
2551     expected_value => 0);
2552    
2553 wakaba 1.3 @Method:
2554 wakaba 1.61 @@Name: getAnyResource
2555     @@enDesc:
2556     Returns a resource object, either module, <Q::for>, or resource.
2557     @@Param:
2558     @@@Name: resourceURI
2559     @@@Type: ResourceURI
2560     @@@Description:
2561     @@@@lang:en
2562     @@@@@:
2563     A resource URI.
2564     @@@nullCase:
2565     @@@@Description:
2566     @@@@@lang:en
2567     @@@@@@:
2568     Defaulted to <Q::DOMMain:any>.
2569     @@ForParam:
2570     @@Return:
2571     @@@Type: DIS|DISAnyResource
2572     @@@Description:
2573     @@@@lang:en
2574     @@@@@:
2575     The resource definition.
2576     @@@RaiseException:
2577     @@@@@: DIS|RESOURCE_NOT_DEFINED_ERR
2578     @@@@enDesc:
2579     The resource should be included in database submodule but
2580     it is not.
2581     @@@PerlDef:
2582     $resourceURI = <Q::DOMMain:any> unless defined $resourceURI;
2583     my $resURI;
2584     if (defined $forArg) {
2585     __CODE{tfurisToURI:: $turi => $resourceURI, $furi => $forArg,
2586     $uri => $resURI}__;
2587     } else {
2588     $resURI = $resourceURI;
2589     }
2590    
2591     if (defined $self->{resDef}->{$resURI}) {
2592     $r = $self->{resDef}->{$resURI};
2593     } elsif (defined $self->{modDef}->{$resURI}) {
2594     $r = $self->{modDef}->{$resURI};
2595     } elsif (defined $self->{forDef}->{$resURI}) {
2596     $r = $self->{forDef}->{$resURI};
2597     } elsif (defined $self->{<H::DIS|resourceModuleMap>}->{$resURI}) {
2598     __DEEP{
2599     $self-><M::dp|ManakaiDISDatabasePerl.plLoadDISDatabaseModule>
2600     ($self-><M::DIS|DISDatabase.getModule>
2601     (${$self->{<H::DIS|resourceModuleMap>}->{$resURI}}));
2602     }__;
2603     if (defined $self->{resDef}->{$resURI}) {
2604     $r = $self->{resDef}->{$resURI};
2605     } elsif (defined $self->{forDef}->{$resURI}) {
2606     $r = $self->{forDef}->{$resURI};
2607     } else {
2608     __EXCEPTION{DIS|RESOURCE_NOT_DEFINED_ERR::
2609     DIS:uri => {$resURI},
2610     DIS:moduleURI => {${$self->{<H::DIS|resourceModuleMap>}
2611     ->{$resURI}}},
2612     }__;
2613     }
2614     } else {
2615     __DEEP{
2616 wakaba 1.62 $r = $self-><M::DIS|DISDatabase.getResource> ($resURI);
2617 wakaba 1.61 }__;
2618     }
2619    
2620     @Method:
2621 wakaba 1.3 @@Name: getSourceFile
2622     @@enDesc:
2623     Gets <QUOTE::dis> source document.
2624     @@Param:
2625     @@@Name: fileName
2626     @@@Type: FileURI
2627     @@@enDesc:
2628     A URI reference identifying a file.
2629     @@Return:
2630 wakaba 1.47 @@@Type: DISDocument
2631     @@@clsActualType: ManakaiDISDocument
2632 wakaba 1.3 @@@enDesc:
2633     The <QUOTE::dis> source document.
2634     @@@nullCase:
2635     @@@@enDesc:
2636     No document associated with that <P::fileName>.
2637     @@@PerlDef:
2638 wakaba 1.53 $r = $self->{<H::DIS|sourceFile>}->{$fileName};
2639 wakaba 1.3 @Method:
2640     @@Name: setSourceFile
2641     @@enDesc:
2642     Puts <QUOTE::dis> source document object.
2643     @@Param:
2644     @@@Name: fileName
2645     @@@Type: FileURI
2646     @@@enDesc:
2647 wakaba 1.4 A URI reference identifying a file. If there is already a
2648 wakaba 1.3 source document, then the association has been updated.
2649     @@Param:
2650     @@@Name: doc
2651 wakaba 1.47 @@@Type: DISDocument
2652     @@@clsActualType: ManakaiDISDocument
2653 wakaba 1.3 @@@enDesc:
2654     The document object to set.
2655     @@Return:
2656     @@@PerlDef:
2657 wakaba 1.53 $self->{<H::DIS|sourceFile>}->{$fileName} = $doc;
2658 wakaba 1.4
2659     @Method:
2660     @@Name: loadModule
2661     @@enDesc:
2662     Loads definitions from a <QUOTE::dis> document.
2663     @@Param:
2664     @@@Name: doc
2665 wakaba 1.47 @@@Type: DISDocument
2666     @@@clsActualType: ManakaiDISDocument
2667 wakaba 1.4 @@@enDesc:
2668     The source <QUOTE::dis> document object. Its
2669     <A::ManakaiDISDocument.disDatabase> must be this database.
2670     @@Param:
2671     @@@Name: resolver
2672     @@@Type: DISModuleResolver
2673     @@@enDesc:
2674     The resolver to convert module name into <QUOTE::dis> document object.
2675     @@ForParam:
2676 wakaba 1.32 @@NamedParam:
2677     @@@Name: onResourceRead
2678     @@@Type:
2679 wakaba 1.110 DISPerl:CODE
2680 wakaba 1.32 @@@enDesc:
2681     An event handler called when a resource is read.
2682     @@@nullCase:
2683     @@@@enDesc:
2684     No event handler is read.
2685 wakaba 1.85 @@NamedParam:
2686     @@@Name: srinfo
2687 wakaba 1.110 @@@Type: DISPerl|HASH
2688 wakaba 1.85 @@@enDesc:
2689     A hash returned by <M::DISDatabase.unloadModule>, to
2690     restore super-resource relationship.
2691     @@@nullCase:
2692     @@@@enDesc:
2693     If it is not the updating.
2694 wakaba 1.4 @@Return:
2695     @@@RaiseException:
2696     @@@@@: NO_MODULE_QNAME_ERR
2697     @@@@enDesc:
2698     The <Q::dis:Module> element must have a <Q::dis:QName> attribute.
2699     @@@RaiseException:
2700     @@@@@: UNABLE_TO_GET_MODULE_ERR
2701     @@@@enDesc:
2702     The implementation is unable to get a module source.
2703 wakaba 1.5 @@@ForDefDupException:
2704     @@@ForDefNoQNameException:
2705     @@@ResDefDupException:
2706     @@@ElementNotAllowedException:
2707 wakaba 1.7 @@@RaiseException:
2708     @@@@@:NO_REQUIRED_ATTR_ERR
2709     @@@@enDesc:
2710     The <Q::dis:Module> element does not have
2711     <Q::dis:Namespace> attribute.
2712 wakaba 1.4 @@@PerlDef:
2713     $resolver = bless $resolver, <ClassName::ManakaiDISModuleResolver>
2714     if ref $resolver eq 'CODE';
2715     ## -- Module Name, URI
2716 wakaba 1.109 $forArg = <Q::ManakaiDOM:all> unless defined $forArg and $forArg ne '';
2717 wakaba 1.4 my $mod_node;
2718     my $mod_name_node;
2719     __DEEP{
2720 wakaba 1.48 $mod_node = $doc-><AG::DISDocument.moduleElement>;
2721     $mod_name_node = $mod_node-><M::SWCFGNode.getAttributeNS>
2722 wakaba 1.4 (<Q::dis:>, 'QName');
2723     unless ($mod_name_node) {
2724     __UNDEEP{
2725     __EXCEPTION{NO_MODULE_QNAME_ERR::
2726     DIS:sourceNode => {$mod_node},
2727     }__;
2728     }__;
2729     }
2730 wakaba 1.51 $mod_name_node = bless $mod_name_node, <ClassName::ManakaiDISElement>
2731     if $mod_name_node->isa (<ClassName::swcfg21:ManakaiSWCFGElement
2732 wakaba 1.110 >);
2733 wakaba 1.5 my $mod_name_uri = $mod_name_node
2734 wakaba 1.48 -><AG::DISElement.qnameValueURI>;
2735     my $mod = $self-><M::DISDatabase.getModule>
2736 wakaba 1.9 ($mod_name_uri, for_arg => $forArg);
2737 wakaba 1.4
2738 wakaba 1.48 unless ($mod-><AG::DISAnyResource.isDefined>) {
2739 wakaba 1.4 ## -- Initializes Module Definition Object
2740 wakaba 1.59 my $v = $mod_name_node-><AG::DISElement.qnameValueLocalName>;
2741 wakaba 1.110 __CODE{DISPerl|HashStringRef::
2742 wakaba 1.59 $result => {$mod->{localName}},
2743     $given => {$v},
2744     }__;
2745     my $ns = $mod_name_node-><AG::DISElement.qnameValueNamespaceURI>;
2746 wakaba 1.110 __CODE{DISPerl|HashStringRef::
2747 wakaba 1.59 $result => {$mod->{namespaceURI}},
2748     $given => {$ns},
2749     }__;
2750 wakaba 1.110 __CODE{DISPerl|HashStringRef::
2751 wakaba 1.59 $result => {$mod->{for}},
2752     $given => {$forArg},
2753     }__;
2754 wakaba 1.4 $mod->{src} = $mod_node;
2755 wakaba 1.48 $mod->{<Q::DIS|isDefined>} = true;
2756 wakaba 1.49 $self-><M::DISDatabase.setSourceFile> ($mod_name_uri => $doc);
2757 wakaba 1.48
2758 wakaba 1.57 $mod-><AS::DIS|ManakaiDISModuleDefinition.targetNamespaceURI>
2759     ($mod_node-><AG::DISModuleElement.definingNamespaceURI>);
2760 wakaba 1.48
2761     __CODE{dv:createValue::
2762     $result => {$mod->{<Q::DIS:sourceFile>}},
2763 wakaba 1.49 $value => {$doc-><M::SWCFGNode.flag> (<Q::swcfg21:fileName>)},
2764 wakaba 1.48 $base_type => {<Q::DISCore:String>},
2765     $type => {<Q::DISCore:String>},
2766 wakaba 1.60 $name => {<Q::DIS:sourceFile>},
2767 wakaba 1.48 }__;
2768 wakaba 1.88 __CODE{setRevision:: $resource => $mod}__;
2769 wakaba 1.5
2770 wakaba 1.12 ## -- Loads "for" definition
2771     my $root_elements
2772 wakaba 1.48 = $doc-><M::DISDocument.disAllChildElements>;
2773     if ($mod-><AG::DISAnyResource.forURI> eq <Q::ManakaiDOM:all>) {
2774     R: for my $el (@$root_elements) {
2775     next R unless $el-><AG::SWCFGElement
2776 wakaba 1.12 .expandedURI> eq <Q::dis:ForDef>;
2777 wakaba 1.85 $self-><M::DISDatabase.loadFor>
2778     ($mod, $el, srinfo => $srinfo);
2779 wakaba 1.12 }
2780     }
2781    
2782 wakaba 1.5 ## -- Loads "for all"
2783 wakaba 1.48 my $rmod = $self-><M::DISDatabase.getModule>
2784 wakaba 1.51 ($mod_name_uri,
2785 wakaba 1.48 for_arg => <Q::ManakaiDOM:all>);
2786     unless ($rmod-><AG::DISAnyResource.isDefined>) {
2787     my $rdoc = $resolver-><M::DISModuleResolver.uriToDocument>
2788     ($self, $rmod-><AG::DISAnyResource.uri>,
2789     $mod-><AG::DISAnyResource.namespaceURI>,
2790     $mod-><AG::DISAnyResource.localName>,
2791     <Q::ManakaiDOM:all>);
2792 wakaba 1.5 unless ($rdoc) {
2793     __UNDEEP{
2794     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2795 wakaba 1.48 DIS:uri => {$rmod-><AG::DISAnyResource.uri>},
2796     DIS:namespaceURI =>
2797     {$mod-><AG::DISAnyResource.namespaceURI>},
2798     DIS:localName => {$mod-><AG::DISAnyResource.localName>},
2799 wakaba 1.9 DIS:for => {<Q::ManakaiDOM:all>},
2800 wakaba 1.48 DIS:sourceNode => {$mod-><AG::DISAnyResource.sourceElement>},
2801 wakaba 1.5 }__;
2802     }__;
2803     }
2804 wakaba 1.48 $self-><M::DISDatabase.loadModule>
2805 wakaba 1.32 ($rdoc, $resolver, for_arg => <Q::ManakaiDOM:all>,
2806 wakaba 1.85 on_resource_read => $onResourceRead,
2807     srinfo => $srinfo);
2808 wakaba 1.77 } else { # if "for all" loaded
2809     $rmod-><M::DIS|DISResourceProp.getPropertyBoolean>
2810     (<Q::dis:In>);
2811     ## Dummy to ensure the module is loaded
2812     }
2813 wakaba 1.4
2814     ## -- Loads Required Modules
2815 wakaba 1.10 ## NOTE:: "dis:For" is not allowed since "dis:ForDef" is not read
2816 wakaba 1.48 my $req_node = $mod_node-><AG::DISModuleElement.requireElement>;
2817     for my $rm (@{$req_node-><M::DISElement.disAllChildElements>}) {
2818     next unless $rm-><AG::SWCFGElement.expandedURI> eq <Q::dis:Module>;
2819 wakaba 1.4 my ($uri, $nuri, $ln, $for);
2820 wakaba 1.48 my $mqn = $rm-><M::SWCFGNode.getAttributeNS> (<Q::dis:>, 'QName');
2821 wakaba 1.4 if ($mqn) {
2822 wakaba 1.48 my $mqv = $mqn-><M::SWCFGNode.value>;
2823 wakaba 1.51 my $mqp = ($mqn->isa (<ClassName::swcfg21:ManakaiSWCFGElement
2824 wakaba 1.110 >)
2825 wakaba 1.51 ? (bless $mqn, <ClassName::ManakaiDISElement>) : $mqn)
2826 wakaba 1.48 -><M::NSResolverDIS.qnameToPair> ($mqv, node => $mqn);
2827 wakaba 1.4 ($nuri, $ln) = @$mqp;
2828     } else {
2829 wakaba 1.48 my $mn = $rm-><M::SWCFGNode.getAttributeNS> (<Q::dis:>, 'Name');
2830 wakaba 1.4 if ($mn) {
2831 wakaba 1.48 $nuri = $mod-><AG::DISAnyResource.namespaceURI>;
2832     $ln = $mn-><M::SWCFGNode.value>;
2833 wakaba 1.4 } else {
2834 wakaba 1.48 $nuri = $mod-><AG::DISAnyResource.namespaceURI>;
2835     $ln = $mod-><AG::DISAnyResource.localName>;
2836 wakaba 1.4 }
2837     }
2838 wakaba 1.48 my $wfn = $rm-><M::SWCFGNode.getAttributeNS>
2839     (<Q::dis:>, 'WithFor');
2840 wakaba 1.4 if ($wfn) {
2841 wakaba 1.51 $for = ($wfn->isa (<ClassName::swcfg21:ManakaiSWCFGElement
2842 wakaba 1.110 >)
2843 wakaba 1.51 ? (bless $wfn, <ClassName::ManakaiDISElement>) : $wfn)
2844 wakaba 1.48 -><AG::DISElement.qnameValueURI>;
2845 wakaba 1.4 } else {
2846 wakaba 1.48 $for = $mod-><AG::DISAnyResource.forURI>;
2847 wakaba 1.4 }
2848 wakaba 1.48 my $rmod = $self-><M::DISDatabase.getModule>
2849 wakaba 1.9 ($nuri . $ln, for_arg => $for);
2850 wakaba 1.87 $mod-><M::DISModule.addReferringModuleURI> ($nuri.$ln);
2851 wakaba 1.48 unless ($rmod-><AG::DISAnyResource.isDefined>) {
2852     my $rdoc = $resolver-><M::DISModuleResolver.uriToDocument>
2853     ($self, $rmod-><AG::DISAnyResource.uri>,
2854     $nuri, $ln, $for);
2855 wakaba 1.4 unless ($rdoc) {
2856     __UNDEEP{
2857     __EXCEPTION{UNABLE_TO_GET_MODULE_ERR::
2858 wakaba 1.48 DIS:uri => {$rmod-><AG::DISAnyResource.uri>},
2859 wakaba 1.4 DIS:namespaceURI => {$nuri},
2860     DIS:localName => {$ln},
2861     DIS:for => {$for},
2862     DIS:sourceNode => {$rm},
2863     }__;
2864     }__;
2865     }
2866 wakaba 1.48 $self-><M::DISDatabase.loadModule>
2867 wakaba 1.32 ($rdoc, $resolver, for_arg => $for,
2868 wakaba 1.85 on_resource_read => $onResourceRead,
2869     srinfo => $srinfo);
2870 wakaba 1.4 }
2871     } # Child Module elements
2872    
2873 wakaba 1.12 ## -- Loads child resources
2874 wakaba 1.48 $root_elements = $doc-><M::DISDocument.disChildElements>
2875 wakaba 1.49 (for_arg => $forArg,
2876     database_arg => $self);
2877 wakaba 1.5 for my $el (@$root_elements) {
2878 wakaba 1.48 if ($el-><AG::DISElement.isResourceElement>) {
2879     $self-><M::DISDatabase.loadResource>
2880 wakaba 1.9 ($mod, null, null, $el,
2881 wakaba 1.32 for_arg => $forArg,
2882 wakaba 1.85 on_resource_read => $onResourceRead,
2883     srinfo => $srinfo);
2884 wakaba 1.7 } else {
2885 wakaba 1.48 my $et = $el-><AG::SWCFGElement.expandedURI>;
2886 wakaba 1.7 if ({
2887 wakaba 1.5 <Q::dis:ForDef> => 1,
2888     <Q::dis:Module> => 1,
2889     <Q::dis:ImplNote> => 1,
2890 wakaba 1.7 }->{$et}) {
2891     #
2892     } else {
2893     __UNDEEP{
2894     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2895     DIS:elementType => {$et},
2896     DIS:sourceNode => {$el},
2897 wakaba 1.98 DIS:uri => {$mod-><AG::anyres.uri>},
2898 wakaba 1.7 }__;
2899 wakaba 1.5 }__;
2900 wakaba 1.7 }
2901     } # element types
2902     }
2903    
2904 wakaba 1.48 my $dn = $mod_node-><M::SWCFGNode.getAttributeNS>
2905     (<Q::dis:>, 'Namespace');
2906     unless ($dn and defined $dn-><M::SWCFGNode.value>) {
2907 wakaba 1.7 __UNDEEP{
2908     __EXCEPTION{NO_REQUIRED_ATTR_ERR::
2909     DIS:elementType => {<Q::dis:Namespace>},
2910     DIS:sourceNode => {$mod_node},
2911 wakaba 1.5 }__;
2912 wakaba 1.7 }__;
2913 wakaba 1.5 }
2914     } # Unless this module loaded
2915     }__; # Deep
2916    
2917     @Method:
2918     @@Name: loadFor
2919     @@enDesc:
2920     Loads definition of a <QUOTE::for> from a <Q::dis:ForDef> element.
2921     @@Param:
2922     @@@Name: mod
2923 wakaba 1.47 @@@Type: DISModule
2924     @@@clsActualType: ManakaiDISModuleDefinition
2925 wakaba 1.5 @@@enDesc:
2926     The module in which the <QUOTE::for> to load is defined.
2927     @@Param:
2928     @@@Name: el
2929 wakaba 1.47 @@@Type: DISElement
2930 wakaba 1.5 @@@enDesc:
2931     The source <QUOTE::dis> <Q::dis:ForDef> element object.
2932 wakaba 1.85 @@NamedParam:
2933     @@@Name: srinfo
2934 wakaba 1.110 @@@Type: DISPerl|HASH
2935 wakaba 1.85 @@@enDesc:
2936     A hash returned by <M::DISDatabase.unloadModule>, to
2937     restore super-resource relationship.
2938     @@@nullCase:
2939     @@@@enDesc:
2940     If it is not the updating.
2941 wakaba 1.5 @@Return:
2942     @@@ForDefDupException:
2943     @@@ForDefNoQNameException:
2944     @@@ElementNotAllowedException:
2945     @@@PerlDef:
2946     __DEEP{
2947 wakaba 1.48 my $qn_node = $el-><M::SWCFGNode.getAttributeNS> (<Q::dis:>, 'QName');
2948 wakaba 1.5 unless ($qn_node) {
2949     __UNDEEP{
2950     __EXCEPTION{NO_FOR_QNAME_ERR::
2951 wakaba 1.48 DIS:sourceNode => {$el},
2952 wakaba 1.5 }__;
2953     }__;
2954     }
2955 wakaba 1.51 $qn_node = bless $qn_node, <ClassName::ManakaiDISElement>
2956     if $qn_node->isa (<ClassName::swcfg21:ManakaiSWCFGElement
2957 wakaba 1.110 >);
2958 wakaba 1.48 my $qn_uri = $qn_node-><AG::DISElement.qnameValueURI>;
2959     my $for = $self-><M::DISDatabase.getFor> ($qn_uri);
2960 wakaba 1.5
2961 wakaba 1.48 unless ($for-><AG::DISAnyResource.isDefined>) {
2962 wakaba 1.10 ## -- Initializes "For" Definition Object
2963 wakaba 1.5 $for->{src} = $el;
2964 wakaba 1.53 $for->{<H::DIS|isDefined>} = true;
2965     $for->{<H::DIS|definingModule>} = \ ($mod->{uri});
2966 wakaba 1.85 $mod-><M::DISModule.addForResource> ($for);
2967 wakaba 1.5
2968 wakaba 1.10 for my $ce (@{$el-><M::ManakaiDISElement.disAllChildElements>}) {
2969 wakaba 1.48 my $xn = $ce-><AG::SWCFGElement.expandedURI>;
2970 wakaba 1.5 if ($xn eq <Q::dis:ISA> or $xn eq <Q::dis:Implement>) {
2971 wakaba 1.48 my $sfor = $self-><M::DISDatabase.getFor>
2972     ($ce-><AG::DISElement.qnameValueURI>);
2973     $for-><M::DISFor.addISA> ($sfor);
2974     $sfor-><AS::DISAnyResource.isReferred> ($ce);
2975 wakaba 1.5 ## TODO: warn if dis:Implement
2976     } elsif ({
2977     <Q::dis:Description> => 1,
2978     <Q::dis:ImplNote> => 1,
2979     <Q::dis:FullName> => 1,
2980     <Q::dis:QName> => 1,
2981     }->{$xn}) {
2982     #
2983     } else {
2984     __UNDEEP{
2985     __EXCEPTION{ELEMENT_NOT_ALLOWED_ERR::
2986     DIS:elementType => {$xn},
2987     DIS:sourceNode => {$ce},
2988 wakaba 1.48 DIS:uri => {$qn_uri},
2989 wakaba 1.5 }__;
2990     }__;
2991     }
2992     }
2993 wakaba 1.85
2994     for (keys %{$srinfo->{for}->{$qn_uri}->{supOf} or {}}) {
2995     my $subfor = $self-><M::DISDatabase.getFor> ($_);
2996 wakaba 1.89 $subfor-><M::DISFor.addISA> ($for, srinfo => $srinfo);
2997     }
2998     for (keys %{$srinfo->{for}->{$qn_uri}->{subOf} or {}}) {
2999     my $supfor = $self-><M::DISDatabase.getFor> ($_);
3000     $for-><M::DISFor.addISA> ($supfor, srinfo => $srinfo);
3001 wakaba 1.85 }
3002 wakaba 1.5 } else {
3003     __UNDEEP{
3004     __EXCEPTION{FOR_ALREADY_DEFINED_ERR::
3005     DIS:sourceNode => {$el},
3006 wakaba 1.48 DIS:anotherSourceNode => {$el},
3007     DIS:uri => {$qn_uri},
3008 wakaba 1.5 }__;
3009     }__;
3010     } # isDefine?
3011     }__; # DEEP
3012    
3013     @Method:
3014     @@Name: loadResource
3015     @@enDesc:
3016     Loads definition of a <QUOTE::dis> resource from a
3017     <Q::dis:ResourceDef> element.
3018     @@Param:
3019     @@@Name: mod
3020 wakaba 1.47 @@@Type: DISModule
3021     @@@clsActualType: ManakaiDISModuleDefinition
3022 wakaba 1.5 @@@enDesc:
3023     The module in which the resource to load is defined.
3024     @@Param:
3025     @@@Name: parentResource
3026 wakaba 1.47 @@@Type: DISResource
3027     @@@clsActualType: ManakaiDISResourceDefinition
3028 wakaba 1.5 @@@enDesc:
3029 wakaba 1.7 The (static) parent resource in which the resource to load is defined.
3030 wakaba 1.5 @@@nullCase:
3031     @@@@enDesc:
3032     The resource to load is a root resource, i.e. <P::el> is
3033     a direct child of the document node.
3034     @@Param:
3035 wakaba 1.7 @@@Name: dynParent
3036 wakaba 1.47 @@@Type: DISResource
3037     @@@clsActualType: ManakaiDISResourceDefinition
3038 wakaba 1.7 @@@enDesc:
3039     The dynamic parent resource of the resource to load.
3040 wakaba 1.9 @@@nullCase:
3041 wakaba 1.7 @@@@enDesc:
3042 wakaba 1.9 If this resource is a root resource, i.e. <P::el> is
3043     a direct child of the document node.
3044 wakaba 1.7 @@Param:
3045 wakaba 1.5 @@@Name: el
3046 wakaba 1.47 @@@Type: DISElement
3047     @@@clsActualType: ManakaiDISElement
3048 wakaba 1.5 @@@enDesc:
3049     The source <QUOTE::dis> <Q::dis:ResourceDef> element object.
3050     @@ForParam:
3051     @@ForpParam:
3052 wakaba 1.32 @@NamedParam:
3053     @@@Name: onResourceRead
3054     @@@Type:
3055 wakaba 1.110 DISPerl:CODE
3056 wakaba 1.32 @@@enDesc:
3057     An event handler called when a resource is read.
3058     @@@nullCase:
3059     @@@@enDesc:
3060     No event handler is read.
3061 wakaba 1.85 @@NamedParam:
3062     @@@Name: srinfo
3063 wakaba 1.110 @@@Type: DISPerl|HASH
3064 wakaba 1.85 @@@enDesc:
3065     A hash returned by <M::DISDatabase.unloadModule>, to
3066     restore super-resource relationship.
3067     @@@nullCase:
3068     @@@@enDesc:
3069     If it is not the updating.
3070 wakaba 1.5 @@Return:
3071     @@@ResDefDupException:
3072     @@@ElementNotAllowedException:
3073 wakaba 1.49 @@@RaiseException:
3074     @@@@@: NO_RDF_TYPE_ERR
3075     @@@@enDesc:
3076     There is a resorce that does not have any <Q::rdf:type>
3077     attribute.
3078 wakaba 1.5 @@@PerlDef:
3079     $forArg = <Q::ManakaiDOM:all> unless defined $forArg;
3080     $forpArg ||= [];
3081     __DEEP{
3082 wakaba 1.6 ## -- Node names
3083 wakaba 1.86 my @res_uri;
3084 wakaba 1.6
3085     ## Unique resource identifier generated from node id
3086 wakaba 1.50 my $node_id = $el-><AG::SWCFGNode.nodeIDRef>;
3087 wakaba 1.6 my $node_uri;
3088 wakaba 1.50 __CODE{tfpurisToURI:: $turi => {$$node_id}, $furi => $forArg,
3089 wakaba 1.6 $forp => $forpArg, $uri => $node_uri}__;
3090    
3091 wakaba 1.54 my $al_node = $el-><M::DISElement.disGetAttribute>
3092     (<Q::dis:AliasFor>, for_arg => $forArg,
3093     forp_arg => $forpArg,
3094     database_arg => $self);
3095     my $al_canon_uri;
3096     if ($al_node) {
3097     $al_canon_uri = $al_node-><M::DISElement.tfqnamesValueURI>
3098 wakaba 1.59 ($$node_id, $forArg,
3099     for_arg => $forArg,
3100     forp_arg => $forpArg,
3101     database_arg => $self);
3102 wakaba 1.54 }
3103    
3104 wakaba 1.6 ## User defined resource identifiers
3105 wakaba 1.5 my $qn_node = $el-><M::ManakaiDISElement.disGetAttribute>
3106     (<Q::dis:QName>, for_arg => $forArg,
3107 wakaba 1.49 forp_arg => $forpArg,
3108     database_arg => $self);
3109 wakaba 1.5 my $res;
3110 wakaba 1.54 ALD: {
3111 wakaba 1.5 if ($qn_node) {
3112     my $qn_uri = $qn_node-><AG::ManakaiDISElement.qnameValueURI>;
3113 wakaba 1.86 my $qn_urif;
3114     __CODE{tfurisToURI:: $turi => $qn_uri, $furi => $forArg,
3115     $uri => $qn_urif}__;
3116     push @res_uri, $qn_urif;
3117     $res = $self-><M::DISDatabase.getResource> ($qn_urif);
3118 wakaba 1.48 if ($res-><AG::DISAnyResource.isDefined>) {
3119 wakaba 1.54 last ALD if defined $al_canon_uri and
3120     $res->{aliasURI}->{$al_canon_uri};
3121 wakaba 1.5 __UNDEEP{
3122     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
3123 wakaba 1.92 DIS:uri => {$qn_urif},
3124 wakaba 1.5 DIS:sourceNode => {$qn_node},
3125     DIS:anotherSourceNode => {$res->{src}},
3126     }__;
3127 wakaba 1.6 }__;
3128 wakaba 1.5 }
3129 wakaba 1.59 my $v = $qn_node-><AG::DIS|DISElement.qnameValueLocalName>;
3130 wakaba 1.110 __CODE{DISPerl|HashStringRef::
3131 wakaba 1.59 $result => {$res->{localName}},
3132     $given => {$v},
3133     }__;
3134     my $ns = $qn_node-><AG::DIS|DISElement.qnameValueNamespaceURI>;
3135 wakaba 1.110 __CODE{DISPerl|HashStringRef::
3136 wakaba 1.59 $result => {$res->{namespaceURI}},
3137     $given => {$ns},
3138     }__;
3139 wakaba 1.5 } else { ## Anonymous or local
3140     my $n_node = $el-><M::ManakaiDISElement.disGetAttribute>
3141     (<Q::dis:Name>, for_arg => $forArg,
3142 wakaba 1.49 forp_arg => $forpArg,
3143     database_arg => $self);
3144 wakaba 1.5 if ($n_node) {
3145     if ($parentResource) {
3146     my $puri = $parentResource->{uri};
3147     my $ru;
3148 wakaba 1.86 my $ruf;
3149 wakaba 1.14 my $ln = $n_node-><M::swcfg21:SWCFGNode
3150 wakaba 1.110 .value>;
3151 wakaba 1.5 __CODE{getChildResourceURI:: $parentURI => $puri,
3152     $localName => $ln,
3153     $result => $ru}__;
3154 wakaba 1.86 __CODE{tfurisToURI:: $turi => $ru, $furi => $forArg,
3155     $uri => $ruf}__;
3156     push @res_uri, $ruf;
3157     $res = $self-><M::DISDatabase.getResource> ($ruf);
3158 wakaba 1.59 my $v = $n_node-><M::SWCFGNode.value>;
3159 wakaba 1.110 __CODE{DISPerl|HashStringRef::
3160 wakaba 1.59 $result => {$res->{localName}},
3161     $given => {$v},
3162     }__;
3163 wakaba 1.53 $res->{<H::DIS|isAnon>} = true;
3164 wakaba 1.5 } else { ## Root local name resource
3165 wakaba 1.48 my $ln = $n_node-><M::SWCFGNode.value>;
3166     my $ns_uri = $mod-><AG::DISAnyResource.sourceElement>
3167     -><AG::DISModuleElement.definingNamespaceURI>;
3168 wakaba 1.7 my $qn_uri = $ns_uri . $ln;
3169 wakaba 1.86 my $qn_urif;
3170     __CODE{tfurisToURI:: $turi => $qn_uri, $furi => $forArg,
3171     $uri => $qn_urif}__;
3172     push @res_uri, $qn_urif;
3173     $res = $self-><M::DISDatabase.getResource> ($qn_urif);
3174 wakaba 1.48 if ($res-><AG::DISAnyResource.isDefined>) {
3175 wakaba 1.65 last ALD if defined $al_canon_uri and
3176     $res->{aliasURI}->{$al_canon_uri};
3177 wakaba 1.6 __UNDEEP{
3178     __EXCEPTION{RESOURCE_ALREADY_DEFINED_ERR::
3179 wakaba 1.48 DIS:uri => {$res-><AG::DISAnyResource.uri>},
3180 wakaba 1.6 DIS:sourceNode => {$n_node},
3181 wakaba 1.48 DIS:anotherSourceNode
3182     => {$res-><AG::DISAnyResource.sourceElement>},
3183 wakaba 1.6 }__;
3184     }__;
3185     }
3186 wakaba 1.110 __CODE{DISPerl|HashStringRef::
3187 wakaba 1.59 $result => {$res->{namespaceURI}},
3188     $given => {$ns_uri},
3189     }__;
3190 wakaba 1.110 __CODE{DISPerl|HashStringRef::
3191 wakaba 1.59 $result => {$res->{localName}},
3192     $given => {$ln},
3193     }__;
3194 wakaba 1.5 }
3195     } else {
3196 wakaba 1.86 push @res_uri, $node_uri;
3197 wakaba 1.48 $res = $self-><M::DISDatabase.getResource> ($node_uri);
3198 wakaba 1.53 $res->{<H::DIS|isAnon>} = true;
3199 wakaba 1.5 }
3200 wakaba 1.6 } # anon
3201 wakaba 1.110 __CODE{DISPerl|HashStringRef::
3202 wakaba 1.59 $result => {$res->{for}},
3203     $given => {$forArg},
3204     }__;
3205 wakaba 1.5 $res->{forp} = $forpArg;
3206     $res->{src} = $el;
3207 wakaba 1.53 $res->{<H::DIS|definingModule>} = \ ($mod->{uri});
3208 wakaba 1.54 $res-><AS::DIS|ManakaiDISResourceDefinition.parentResource>
3209     ($parentResource) if $parentResource;
3210     $res-><AS::DIS|ManakaiDISResourceDefinition.dynamicParentResource>
3211     ($dynParent) if $dynParent;
3212 wakaba 1.9 unless ($res->{uri} eq $node_uri) {
3213 wakaba 1.86 push @res_uri, $node_uri;
3214 wakaba 1.48 my $nu_res = $self-><M::DISDatabase.getResource> ($node_uri);
3215     $res-><M::DISResource.mergeAsAlias> ($nu_res);
3216 wakaba 1.9 }
3217     $res->{seq} = $self->{seq}++;
3218 wakaba 1.50 $res-><AS::DISAnyResource.sourceNodeIDRef> ($node_id);
3219 wakaba 1.79 __CODE{setRevision:: $resource => $res}__;
3220 wakaba 1.86 $mod-><M::DISModule.addResourceURI> ($_) for @res_uri;
3221 wakaba 1.9
3222 wakaba 1.6 ## -- Alias
3223     if ($al_node) {
3224 wakaba 1.54 my $canon_res = $self-><M::DISDatabase.getResource> ($al_canon_uri);
3225 wakaba 1.48 $canon_res-><AS::DISAnyResource.isReferred> ($al_node);
3226 wakaba 1.91 $canon_res-><M::DISResource.mergeAsAlias>
3227     ($res, node => $al_node, no_equality_check => true);
3228 wakaba 1.6 $res = $canon_res;
3229 wakaba 1.92 } else {
3230     $res->{<H::DIS|isDefined>} = true;
3231     }
3232 wakaba 1.54 } # ALD
3233 wakaba 1.5
3234 wakaba 1.11 ## -- Registers as child
3235 wakaba 1.54 $parentResource-><M::DIS|ManakaiDISResourceDefinition
3236     .addChildResource> ($res)
3237 wakaba 1.11 if $parentResource;
3238 wakaba 1.54 $dynParent-><M::DIS|ManakaiDISResourceDefinition
3239     .addDynamicChildResource> ($res)
3240 wakaba 1.11 if $dynParent;
3241    
3242 wakaba 1.7 my $is_multires = false;
3243     my @props;
3244     my @cres;
3245 wakaba 1.48 my @ce0 = @{$el-><M::DISElement.disChildElements>
3246 wakaba 1.49 (for_arg => $forArg, forp_arg => $forpArg,
3247     database_arg => $self)};
3248     my $has_type = $al_node;
3249 wakaba 1.7 while (@ce0) {
3250     my $ce = shift @ce0;
3251 wakaba 1.81 if ($ce-><M::DISElement.elementTypeMatch>
3252 wakaba 1.89 (<Q::DISCore|resourceType>, database_arg => $self,
3253     srinfo => $srinfo) or
3254 wakaba 1.81 $ce-><M::DISElement.elementTypeMatch> (<Q::rdf:type>,
3255 wakaba 1.89 database_arg => $self,
3256     srinfo => $srinfo)) {
3257 wakaba 1.81 ## TODO: Remove this.
3258 wakaba 1.49 $has_type = true;
3259 wakaba 1.48 my $type_uri = $ce-><AG::DISElement.qnameValueURI>;
3260     my $type = $self-><M::DISDatabase.getResource> ($type_uri);
3261 wakaba 1.93 $res-><M::DISAnyResource.addTypeURI> ($type_uri,
3262     srinfo => $srinfo);
3263 wakaba 1.48 $type-><AS::DISAnyResource.isReferred> ($ce);
3264     if ($type-><M::DISResource.isSubsetOfURI>
3265 wakaba 1.89 (<Q::dis:MultipleResource>,
3266     srinfo => $srinfo)) {
3267 wakaba 1.7 $is_multires = true;
3268     }
3269 wakaba 1.48 } elsif ($ce-><M::DISElement.elementTypeMatch>
3270 wakaba 1.49 (<Q::dis:subsetOf>,
3271 wakaba 1.89 database_arg => $self,
3272     srinfo => $srinfo)) {
3273 wakaba 1.48 my $sres = $self-><M::DISDatabase.getResource>
3274     ($ce-><M::DISElement.tfqnamesValueURI>
3275 wakaba 1.50 ($$node_id, $forArg,
3276 wakaba 1.49 for_arg => $forArg, forp_arg => $forpArg,
3277     database_arg => $self));
3278 wakaba 1.89 $res-><M::DISResource.addSuperResource> ($sres, srinfo => $srinfo);
3279 wakaba 1.48 } elsif ($ce-><AG::DISElement.isResourceElement>) {
3280 wakaba 1.7 push @cres, $ce;
3281 wakaba 1.48 } elsif ($ce-><M::DISElement.elementTypeMatch>
3282 wakaba 1.49 (<Q::dis:dataType>,
3283 wakaba 1.89 database_arg => $self,
3284     srinfo => $srinfo)) {
3285 wakaba 1.48 my $uri = $ce-><AG::DISElement.qnameValueURI>;
3286     __CODE{dv:createURI::
3287     $uri => $uri,
3288     $result => {$res->{<Q::dis:dataType>}},
3289 wakaba 1.60 $name => {$ce-><AG::SWCFGElement.expandedURI>},
3290 wakaba 1.48 }__;
3291     my $type = $self-><M::DISDatabase.getResource> ($uri);
3292     $type-><AS::DISAnyResource.isReferred> ($ce);
3293     } elsif ($ce-><M::DISElement.elementTypeMatch>
3294 wakaba 1.89 (<Q::dis:multipleProperties>,
3295     database_arg => $self,
3296     srinfo => $srinfo)) {
3297 wakaba 1.48 my $uri = $ce-><AG::DISElement.qnameValueURI>;
3298     __CODE{dv:createURI::
3299     $uri => $uri,
3300     $result => {$res->{<Q::dis:multipleProperties>}},
3301 wakaba 1.60 $name => {$ce-><AG::SWCFGElement.expandedURI>},
3302 wakaba 1.48 }__;
3303     my $type = $self-><M::DISDatabase.getResource> ($uri);
3304     $type-><AS::DISAnyResource.isReferred> ($ce);
3305 wakaba 1.7 } else {
3306     ## Property and invalid element is not checked, since not
3307     ## all property definitions has loaded at this stage.
3308     push @props, $ce;
3309     }
3310     } # @ce0
3311    
3312 wakaba 1.49 unless ($has_type) {
3313     __UNDEEP{__EXCEPTION{NO_RDF_TYPE_ERR::
3314     DIS:uri => {$res->{uri}},
3315     DIS:sourceNode => {$el},
3316     }__}__;
3317     }
3318    
3319 wakaba 1.85 my $srres = $srinfo->{resource}->{$res-><AG::DISAnyResource.uri>};
3320 wakaba 1.91 F: for my $auri (keys %{$srres->{aliasURI} or {}}) {
3321 wakaba 1.85 next F unless $srres->{aliasURI}->{$auri};
3322     $res->{aliasURI}->{$auri} = true;
3323 wakaba 1.91 $self->{resDef}->{$auri} = $res;
3324 wakaba 1.85 A: for (keys %{$res->{subOf} or {}}) {
3325     next A unless $res->{subOf}->{$_};
3326     my $s = $self-><M::DISDatabase.getResource> ($_);
3327     $s->{supOf}->{$auri} = true;
3328     }
3329     A: for (keys %{$res->{supOf} or {}}) {
3330     next A unless $res->{supOf}->{$_};
3331     my $s = $self-><M::DISDatabase.getResource> ($_);
3332     $s->{subOf}->{$auri} = true;
3333     }
3334     }
3335     F: for my $suri (keys %{$srres->{supOf} or {}}) {
3336     next F unless $srres->{supOf}->{$suri};
3337     my $sres = $self-><M::DISDatabase.getResource> ($suri);
3338 wakaba 1.89 $sres-><M::DISResource.addSuperResource> ($res, srinfo => $srinfo);
3339     }
3340     F: for my $suri (keys %{$srres->{subOf} or {}}) {
3341     next F unless $srres->{subOf}->{$suri};
3342     my $sres = $self-><M::DISDatabase.getResource> ($suri);
3343     $res-><M::DISResource.addSuperResource> ($sres, srinfo => $srinfo);
3344 wakaba 1.85 }
3345    
3346 wakaba 1.7 ## -- Child resources
3347 wakaba 1.94 if (not $is_multires and not $al_node) {
3348 wakaba 1.7 for my $re (@cres) {
3349 wakaba 1.94 $self-><M::ManakaiDISDatabase.loadResource>
3350 wakaba 1.7 ($mod, $res, $res, $re,
3351 wakaba 1.32 for_arg => $forArg, forp_arg => $forpArg,
3352 wakaba 1.85 on_resource_read => $onResourceRead,
3353     srinfo => $srinfo);
3354 wakaba 1.4 }
3355 wakaba 1.7 }
3356 wakaba 1.5
3357 wakaba 1.7 ## -- Multiple representations
3358     if ($is_multires) {
3359     for my $pe (@props) {
3360     if ($pe-><M::ManakaiDISElement.elementTypeMatch>
3361 wakaba 1.49 (<Q::dis:resourceFor>,
3362 wakaba 1.89 database_arg => $self,
3363     srinfo => $srinfo)) {
3364 wakaba 1.14 my $for_uri = $pe-><AG::ManakaiDISElement.qnameValueURI>;
3365 wakaba 1.7 my $for = $self-><M::ManakaiDISDatabase.getFor> ($for_uri);
3366 wakaba 1.48 $for-><AS::DISAnyResource.isReferred> ($pe);
3367 wakaba 1.7 $self-><M::ManakaiDISDatabase.loadResource>
3368     ($mod, $parentResource, $res, $el,
3369     for_arg => $forArg,
3370 wakaba 1.32 forp_arg => [@{$forpArg}, $for_uri],
3371 wakaba 1.85 on_resource_read => $onResourceRead,
3372     srinfo => $srinfo);
3373 wakaba 1.7 }
3374     }
3375     }
3376 wakaba 1.48 ($onResourceRead or sub {})->($self, $res);
3377     }__; # DEEP
3378 wakaba 1.2
3379 wakaba 1.48 @Method:
3380     @@Name: readProperties
3381     @@enDesc:
3382     Reads property values in the source tree and
3383     removes the source tree from the database.
3384     @@NamedParam:
3385     @@@Name: onResourceRead
3386     @@@Type:
3387 wakaba 1.110 DISPerl:CODE
3388 wakaba 1.48 @@@enDesc:
3389     An event handler called when a resource is read.
3390     @@@nullCase:
3391     @@@@enDesc:
3392     No event handler is read.
3393 wakaba 1.101 @@NamedParam:
3394     @@@Name: implementation
3395 wakaba 1.104 @@@Type: DOMImpl
3396 wakaba 1.101 @@@enDesc:
3397 wakaba 1.104 The <IF::DOMImpl> object to which the database belongs.
3398 wakaba 1.101 It might be used to create property value objects.
3399 wakaba 1.48 @@Return:
3400     @@@RaiseException:
3401     @@@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
3402     @@@@enDesc:
3403     There is an element whose element type is not supported.
3404 wakaba 1.2 @@@PerlDef:
3405 wakaba 1.48 __DEEP{
3406 wakaba 1.89 F: for my $fd (values %{$self->{modDef}},
3407     values %{$self->{forDef}},
3408     values %{$self->{resDef}}) {
3409     next F if $fd->isa (<ClassName::ManakaiDISModuleLite>);
3410 wakaba 1.48 if ($fd-><AG::DISAnyResource.isDefined>) {
3411     $fd-><M::DISAnyResource.readProperties>
3412 wakaba 1.101 (on_resource_read => $onResourceRead,
3413     implementation => $implementation);
3414 wakaba 1.48 }
3415     }
3416 wakaba 1.53 CORE::delete $self->{<H::DIS|sourceFile>};
3417 wakaba 1.48 }__;
3418 wakaba 1.10
3419 wakaba 1.48 @Method:
3420     @@Name: checkUndefinedResource
3421 wakaba 1.44 @@enDesc:
3422 wakaba 1.48 Checks whether there is referred but undefined resource or not.
3423     @@Return:
3424     @@@RaiseException:
3425     @@@@@: FOR_NOT_DEFINED_ERR
3426     @@@@enDesc:
3427     There is a <QUOTE::for> that is referred but not defined.
3428     @@@RaiseException:
3429     @@@@@: RESOURCE_NOT_DEFINED_ERR
3430     @@@@enDesc:
3431     There is a resource that is referred but not defined.
3432 wakaba 1.44 @@@PerlDef:
3433 wakaba 1.48 for my $fd (values %{$self->{forDef}}) {
3434     if (my $ref = $fd-><AG::DISAnyResource.isReferred> and
3435     not $fd-><AG::DISAnyResource.isDefined>) {
3436     __EXCEPTION{FOR_NOT_DEFINED_ERR::
3437     DIS:uri => {$fd-><AG::DISAnyResource.uri>},
3438     DIS:sourceNodePath => {$ref},
3439     }__;
3440     }
3441     }
3442     for my $fd (values %{$self->{resDef}}) {
3443     if (my $ref = $fd-><AG::DISAnyResource.isReferred> and
3444     not $fd-><AG::DISAnyResource.isDefined>) {
3445     __EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3446     DIS:uri => {$fd-><AG::DISAnyResource.uri>},
3447     DIS:sourceNodePath => {$ref},
3448     }__;
3449     }
3450     }
3451 wakaba 1.85
3452     @Method:
3453     @@Name: unloadModule
3454     @@enDesc:
3455     Removes a module and resources defined in the module
3456     from the database.
3457     @@Param:
3458     @@@Name: module
3459     @@@Type: DISModule
3460     @@@enDesc:
3461     The module to remove.
3462     @@NamedParam:
3463     @@@Name: srinfo
3464 wakaba 1.110 @@@Type: DISPerl|HASH
3465 wakaba 1.85 @@@enDesc:
3466     A hash returned by <M::DISDatabase.unloadModule>, to
3467     restore super-resource relationship later. The hash
3468     returned by the method is built based on this value.
3469     @@@nullCase:
3470     @@@@enDesc:
3471     If it is not the updating.
3472     @@Return:
3473 wakaba 1.110 @@@Type: DISPerl|HASH
3474 wakaba 1.85 @@@enDesc:
3475     {LI:: <CODE::resource> or <CODE::for>:::
3476    
3477     {LI:: <VAR::Resource URI>:::
3478    
3479     {LI:: <CODE::supOf>:::
3480    
3481     - <VAR::Superset URI>::: A <DOM::true> value
3482    
3483     where <VAR::resource URI> is a URI of the resource
3484     (either canonical URI or an alias URI defined within
3485     the module) and <VAR::superset URI> is a URI
3486     from the list of superset URI of the resource minus
3487     the list of alias URIs (including the canonical URI)
3488     of the resource.
3489    
3490     }
3491    
3492     {LI:: <CODE::aliasURI>:::
3493    
3494     - <VAR::Alias URI>::: A <DOM::true> value
3495    
3496     where <VAR::alias URI> is an alias URI of the resource
3497     defined by other module.
3498    
3499     }
3500     }
3501     }
3502     @@@PerlDef:
3503     __DEEP{
3504     $r = $srinfo || {};
3505    
3506     ## -- |For|s
3507     F: for my $for (@{$module-><M::DISModule.getForResourceList>}) {
3508     my $uri = $for-><AG::DISAnyResource.uri>;
3509     A: for (%{$for->{ISA} or {}}) {
3510     next A unless $for->{ISA}->{$_};
3511     my $sfor = $self-><M::DISDatabase.getFor> ($_);
3512     next A unless $sfor;
3513     delete $sfor->{revISA}->{$uri};
3514     }
3515     A: for (%{$for->{revISA} or {}}) {
3516     next A unless $for->{revISA}->{$_};
3517     my $sfor = $self-><M::DISDatabase.getFor> ($_);
3518     next A unless $sfor;
3519     delete $sfor->{ISA}->{$uri};
3520     $r->{for}->{$uri}->{supOf}->{$_} = true;
3521     }
3522     delete $self->{forDef}->{$uri};
3523     delete $self->{<H::DIS|resourceModuleMap>}->{$uri};
3524     } # F
3525    
3526     ## -- Resources
3527 wakaba 1.86 my @res_list = map {
3528     [$_, $self-><M::DISDatabase.getResource> ($_)]
3529     } @{$module-><M::DISModule.getResourceURIList>};
3530     my %res_list = map {$_->[0] => true} @res_list;
3531     for my $ur (@res_list) {
3532     my $uri = $ur->[0];
3533     my $res = $ur->[1];
3534     my $owner = $res-><AG::DISAnyResource.ownerModule>;
3535     if (defined $owner and $owner eq $module) {
3536 wakaba 1.85 ## Non-alias
3537     my %alias;
3538     my %sub = %{$res->{supOf} or {}};
3539     A: for (keys %{$res->{aliasURI} or {}}) {
3540     next A unless $res->{aliasURI}->{$_};
3541     $alias{$_} = true;
3542     delete $sub{$_} if $res->{aliasURI}->{$_};
3543     $r->{resource}->{$uri}->{supOf} = \%sub;
3544     unless ($res_list{$_}) {
3545     ## Defined by other module
3546     $r->{resource}->{$uri}->{aliasURI}->{$_} = true;
3547     }
3548     }
3549     A: for (keys %{$res->{subOf} or {}}) {
3550     next A unless $res->{aliasURI}->{$_};
3551     my $sres = $self-><M::DISDatabase.getResource> ($_);
3552     next A unless $sres;
3553     delete $res->{supOf}->{$_} for keys %alias;
3554     }
3555     A: for (keys %{$res->{supOf} or {}}) {
3556     next A unless $res->{aliasURI}->{$_};
3557     my $sres = $self-><M::DISDatabase.getResource> ($_);
3558     next A unless $sres;
3559     delete $res->{subOf}->{$_} for keys %alias;
3560     }
3561     A: for (keys %alias) {
3562     delete $self->{resDef}->{$_};
3563     delete $self->{<H::DIS|resourceModuleMap>}->{$_};
3564     }
3565     } else {
3566     ## Alias
3567     delete $res->{aliasURI}->{$uri};
3568     delete $res->{subOf}->{$uri};
3569     delete $res->{supOf}->{$uri};
3570 wakaba 1.86 A: for (keys %{$res->{subOf} or {}}) {
3571 wakaba 1.85 next A unless $res->{subOf}->{$_};
3572     my $sres = $self-><M::DISDatabase.getResource> ($_);
3573     next A unless $sres;
3574     delete $sres->{supOf}->{$uri};
3575     }
3576 wakaba 1.86 A: for (keys %{$res->{supOf} or {}}) {
3577 wakaba 1.85 next A unless $res->{supOf}->{$_};
3578     my $sres = $self-><M::DISDatabase.getResource> ($_);
3579     next A unless $sres;
3580     delete $sres->{subOf}->{$uri};
3581     }
3582     delete $self->{resDef}->{$uri};
3583     delete $self->{<H::DIS|resourceModuleMap>}->{$uri};
3584     }
3585     }
3586    
3587     ## -- Keys
3588     my $v = $module->{<H::dp|plHashKey>};
3589     K: for my $scope (keys %{$v or {}}) {
3590 wakaba 1.89 my $ks = $self-><M::DISDatabase.getResource> ($scope);
3591 wakaba 1.85 L: for my $key (keys %{$v->{$scope} or {}}) {
3592     next L unless $v->{$scope}->{$key};
3593 wakaba 1.89 delete $ks->{<H::dp|plHashKey>}->{$key};
3594 wakaba 1.85 }
3595     }
3596    
3597     ## -- Module itself
3598     for (@{$module-><AG::DISAnyResource.uris>}) {
3599     delete $self->{modDef}->{$_};
3600     }
3601     }__;
3602 wakaba 1.48
3603     @Method:
3604     @@Name: xcrefToResource
3605 wakaba 1.10 @@enDesc:
3606 wakaba 1.48 Returns a resource object selected by an exception code
3607 wakaba 1.98 reference (<Q::dx|XCRef>).
3608 wakaba 1.10 @@Param:
3609 wakaba 1.48 @@@Name: xcref
3610 wakaba 1.98 @@@Type: DISString
3611 wakaba 1.10 @@@enDesc:
3612 wakaba 1.48 Exception code to select.
3613 wakaba 1.2 @@Param:
3614 wakaba 1.48 @@@Name: contextNode
3615 wakaba 1.50 @@@Type: NSResolverDIS
3616 wakaba 1.48 @@@enDesc:
3617     A context element node. Namespace prefixes in
3618     <P::xcref> are resolved against this node.
3619     @@ForParam:
3620     @@NodeParam:
3621 wakaba 1.2 @@Return:
3622     @@@Type:
3623 wakaba 1.110 DISPerl:ARRAY
3624 wakaba 1.48 @@@enDesc:
3625     A reference to the array containing two or three
3626     resource definitions (<Class::ManakaiDISResourceDefinition>).
3627     The first (index <CODE::0>) resource is an exception class.
3628     The second (index <CODE::1>) resource is an exception code
3629     constant. The third (index <CODE::2>) resource
3630     is an exception subtype or <DOM::null> if the reference identifies
3631     no subtype.
3632     @@@RaiseException:
3633     @@@@@: RESOURCE_NOT_DEFINED_ERR
3634 wakaba 1.2 @@@@enDesc:
3635 wakaba 1.48 The resource identified by the <P::xcref> is not defined
3636     or not an exception.
3637 wakaba 1.2 @@@PerlDef:
3638 wakaba 1.48 my ($q1, $q2, $q3) = split /\s*\.\s*/, $xcref, 3;
3639     __DEEP{
3640     if (defined $q3) {
3641     $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
3642     ($contextNode-><M::NSResolverDIS.tfqnamesToURI>
3643     ($q3, null, $forArg, node => $node));
3644 wakaba 1.54 $r->[1] = $r->[2]-><AG::DIS|DISResource.parentResource>;
3645 wakaba 1.48 } elsif (defined $q2) {
3646     if ($q2 =~ /:/) {
3647     $r->[1] = $self-><M::ManakaiDISDatabase.getResource>
3648     ($contextNode-><M::NSResolverDIS.tfqnamesToURI>
3649     ($q2, null, $forArg, node => $node));
3650     } else {
3651     $r->[0] = $self-><M::ManakaiDISDatabase.getResource>
3652     ($contextNode-><M::NSResolverDIS.tfqnamesToURI>
3653     ($q1, null, $forArg, node => $node));
3654     $r->[1] = $r->[0]-><M::ManakaiDISResourceDefinition
3655     .getConstResourceByName> ($q2);
3656     }
3657     } else { ## $q1 only
3658     $r->[2] = $self-><M::ManakaiDISDatabase.getResource>
3659     ($contextNode-><M::NSResolverDIS.tfqnamesToURI>
3660     ($q1, null, $forArg, node => $node));
3661 wakaba 1.79 if ($r->[2]-><M::DISAnyResource.isTypeURI> (<Q::dx:ErrorSubCode>)) {
3662 wakaba 1.54 $r->[1] = $r->[2]-><AG::DIS|DISResource.parentResource>;
3663 wakaba 1.48 } else {
3664     $r->[1] = $r->[2]; CORE::delete $r->[2];
3665     }
3666     }
3667 wakaba 1.2
3668 wakaba 1.48 if ($r->[2] and
3669 wakaba 1.79 not $r->[2]-><M::DISAnyResource
3670 wakaba 1.64 .isTypeURI> (<Q::dx:ErrorSubCode>)) {
3671 wakaba 1.48 __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3672     DIS:uri => {$r->[2]->{uri}},
3673 wakaba 1.64 DIS:expectedType => {<Q::dx:ErrorSubCode>},
3674 wakaba 1.48 DIS:sourceNode => {$node},
3675     DIS:sourceCode => {$xcref},
3676     }__}__;
3677     }
3678     $r->[2]-><AS::DISAnyResource.isReferred>
3679     ($node or $contextNode)
3680     if $r->[2];
3681    
3682     if (not $r->[1] or
3683 wakaba 1.79 not $r->[1]-><M::DISAnyResource
3684 wakaba 1.48 .isTypeURI> (<Q::ManakaiDOM:Const>)) {
3685     __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3686 wakaba 1.63 DIS:uri => {($r->[1] ? $r->[1]-><AG::DIS|DISAnyResource.uri>
3687     : null)},
3688     DIS:localName => {($r->[1] ? $r->[1]-><AG::DIS|DISAnyResource
3689     .localName> : null)},
3690 wakaba 1.48 DIS:expectedType => {<Q::ManakaiDOM:Const>},
3691     DIS:sourceNode => {$node},
3692     DIS:sourceCode => {$xcref},
3693     }__}__;
3694     }
3695     $r->[1]-><AS::DISAnyResource.isReferred>
3696     ($node or $contextNode);
3697 wakaba 1.5
3698 wakaba 1.48 unless ($r->[0]) {
3699 wakaba 1.54 my $cg = $r->[1]-><AG::DIS|DISResource.parentResource>;
3700     $r->[0] = $cg-><AG::DIS|DISResource.parentResource> if $cg;
3701 wakaba 1.48 }
3702     if (not $r->[0] or
3703 wakaba 1.79 not $r->[0]-><M::DISAnyResource
3704 wakaba 1.60 .isTypeURI> (<Q::dx:AnyExceptionAnyClass>)) {
3705 wakaba 1.48 __UNDEEP{__EXCEPTION{RESOURCE_NOT_DEFINED_ERR::
3706     DIS:uri => {$r->[0]->{uri}},
3707 wakaba 1.59 DIS:localName => {$r->[0]-><AG::DIS|DISAnyResource.localName>},
3708 wakaba 1.60 DIS:expectedType => {<Q::dx:AnyExceptionAnyClass>},
3709 wakaba 1.48 DIS:sourceNode => {$node},
3710     DIS:sourceCode => {$xcref},
3711     }__}__;
3712 wakaba 1.5 }
3713 wakaba 1.48 $r->[0]-><AS::DISAnyResource.isReferred>
3714     ($node or $contextNode);
3715 wakaba 1.7 }__;
3716 wakaba 1.5
3717 wakaba 1.38 @Method:
3718 wakaba 1.48 @@Name: free
3719 wakaba 1.22 @@enDesc:
3720 wakaba 1.48 Marks the database, resources in the database, and source
3721     <QUOTE::dis> document trees in the database as no longer used.
3722     @@ForCheck: ManakaiDOM|ForClass
3723 wakaba 1.22 @@Return:
3724     @@@PerlDef:
3725 wakaba 1.53 for my $file (values %{$self->{<H::DIS|sourceFile>}}) {
3726 wakaba 1.110 $file-><M::ManakaiNode|ManakaiNodeRef.free>
3727 wakaba 1.48 if $file;
3728     }
3729     CORE::delete $self->{modDef};
3730     CORE::delete $self->{forDef};
3731     CORE::delete $self->{resDef};
3732 wakaba 1.62
3733     @Method:
3734     @@Name: getModuleURIList
3735     @@enDesc:
3736     Returns a snapshot list of URIs of modules in the database.
3737     @@Return:
3738 wakaba 1.110 @@@Type: DISPerl|ARRAY
3739 wakaba 1.62 @@@enDesc:
3740     A snapshot list of URIs.
3741     @@@PerlDef:
3742     $r = [map {$_-><AG::DIS|DISAnyResource.uri>} values %{$self->{modDef}}];
3743    
3744     @Method:
3745     @@Name: getAnyResourceURIList
3746     @@enDesc:
3747     Returns a snapshot list of URIs of resources in the database.
3748     @@Return:
3749 wakaba 1.110 @@@Type: DISPerl|ARRAY
3750 wakaba 1.62 @@@enDesc:
3751     A snapshot list of URIs.
3752     @@@PerlDef:
3753     $r = [keys %{$self->{<H::DIS|resourceModuleMap>}},
3754     map {$_-><AG::DIS|DISAnyResource.uri>} values %{$self->{modDef}}];
3755 wakaba 1.81
3756     @IntMethod:
3757     @@Operator: ManakaiDOM|MUErrorHandler
3758     @@enDesc:
3759 wakaba 1.110 When a <IF::ecore|ErrorInterface> is <Perl::report>ed
3760 wakaba 1.81 with an <Perl::-object> of <IF::Node>, then this method is invoked.
3761    
3762     The method calls the <cfg::error-handler> if the error is of
3763     <IF::c|DOMError>. Otherwise, including the cases of
3764     <IF::DOMCore|DOMException>s,
3765     the error is rethrown so that appropriate <Perl::catch> clause
3766     can catch the error.
3767     @@Param:
3768     @@@Name: err
3769 wakaba 1.110 @@@Type: ecore|ErrorInterface
3770 wakaba 1.81 @@@enDesc:
3771     The reported error object.
3772     @@Return:
3773 wakaba 1.110 @@@Type: DISPerl|Any
3774 wakaba 1.81 @@@enDesc:
3775     If the <P::err> is a <IF::c|DOMError>, then the return value
3776     of the error handler.
3777    
3778     {NOTE:: If the error is thrown, the method never returns.
3779     }
3780     @@@nullCase:
3781     @@@@enDesc:
3782     No error handler.
3783     @@@PerlDef:
3784 wakaba 1.108 if ($err->isa (<IFName::c|DOMError>)) {
3785 wakaba 1.81 __DEEP{
3786     my $cfg = $self-><AG::DISDatabase.domConfig>;
3787     my $h = $cfg-><M::DOMConfig.getParameter> ('error-handler');
3788 wakaba 1.110 $r = $h-><M::DOMCore|DOMErrorHandler.handleError> ($err);
3789 wakaba 1.81 }__;
3790     } else {
3791 wakaba 1.110 $err-><M::ecore|ErrorInterface.throw>;
3792 wakaba 1.81 }
3793    
3794     @Attr:
3795     @@Name: domConfig
3796     @@enDesc:
3797     The configuration of the document.
3798     @@Get:
3799     @@@Type: DOMConfig
3800     @@@enDesc: The DOM configuration object.
3801     @@@PerlDef:
3802 wakaba 1.110 __CODE{c|getConfigObject::
3803 wakaba 1.81 $target => $self,
3804     $targetHash => {$self},
3805     $targetType => {<IFName::DISDatabase>},
3806     $result => $r,
3807     }__;
3808 wakaba 1.85
3809     @Method:
3810     @@Name: getModuleResourceList
3811     @@enDesc:
3812     Returns a snapshot list of modules contained in the database.
3813     @@Return:
3814     @@@Type: ResourceList
3815     @@@enDesc:
3816     A snapshot list of the modules.
3817     @@@PerlDef:
3818     $r = [map {$self->{modDef}->{$_}}
3819     grep {defined $self->{modDef}->{$_}}
3820     keys %{$self->{modDef}}];
3821 wakaba 1.48 ##DISDatabase
3822    
3823 wakaba 1.81 CParamApp:
3824 wakaba 1.110 @c:domConfigurationParameter: c|error-handler
3825 wakaba 1.81 @c:targetType: DISDatabase
3826    
3827     ElementTypeBinding:
3828     @Name: CParamApp
3829     @ElementType:
3830     dis:ResourceDef
3831     @ShadowContent:
3832     @@rdf:type: c|DOMConfigurationParameterApplication
3833    
3834 wakaba 1.48 PropDef:
3835 wakaba 1.54 @QName: DIS|resourceModuleMap
3836     @enDesc:
3837     Resource-module mapping table.
3838     @DIS:key: rm
3839     @Type: DISPerl|HASH
3840    
3841     PropDef:
3842 wakaba 1.48 @QName: sourceNodeID
3843     @enDesc:
3844     The URI reference of the source node identifier.
3845 wakaba 1.55 @DIS:key: snid
3846     @Type: DISPerl|SCALAR
3847 wakaba 1.24
3848 wakaba 1.48 PropDef:
3849 wakaba 1.55 @QName: DIS|resource
3850     @enDesc:
3851 wakaba 1.48 Resources defined in a module.
3852 wakaba 1.55 @DIS:key: mres
3853     @Type: DISPerl|ARRAY
3854 wakaba 1.22
3855 wakaba 1.48 PropDef:
3856 wakaba 1.54 @QName: DIS|parentResource
3857 wakaba 1.48 @enDesc:
3858     Static parent resource. No parent for root resources.
3859 wakaba 1.54 @DIS:key: puri
3860 wakaba 1.27
3861 wakaba 1.48 PropDef:
3862 wakaba 1.54 @QName: DIS|dynamicParentResource
3863 wakaba 1.48 @enDesc:
3864     Dynamic parent resource. No parent for root resources.
3865 wakaba 1.54 @DIS:key: dpuri
3866 wakaba 1.25
3867 wakaba 1.48 PropDef:
3868 wakaba 1.54 @QName: DIS|childResource
3869 wakaba 1.48 @enDesc:
3870     Static child resources.
3871 wakaba 1.54 @DIS:key: curis
3872 wakaba 1.35
3873 wakaba 1.48 PropDef:
3874 wakaba 1.54 @QName: DIS|dynamicChildResource
3875 wakaba 1.48 @enDesc:
3876     Dynamic child resources.
3877 wakaba 1.54 @DIS:key: dcuris
3878    
3879     PropDef:
3880     @QName: DIS|key
3881     @enDesc:
3882     Property name in resource objects.
3883     @rdfs:subPropertyOf: DISPerl|propHashKey
3884     @dataType: DISCore|String
3885     @multipleProperties: DISCore|Single
3886    
3887     ResourceDef:
3888     @QName: DIS|DISResourceList
3889     @enDesc:
3890     A reference to array whose items are resource
3891 wakaba 1.110 (<IF::DIS|DISAnyResource>) objects.
3892 wakaba 1.54 @rdfs:subClassOf: DISPerl|ARRAY
3893     @rdf:type: DISLang|DataType
3894 wakaba 1.38
3895 wakaba 1.48 ElementTypeBinding:
3896     @Name: ForDefDupException
3897     @ElementType:
3898     ManakaiDOM:raises
3899     @ShadowContent:
3900     @@@: FOR_ALREADY_DEFINED_ERR
3901     @@Description:
3902     @@@lang:en
3903     @@@@:
3904     The <QUOTE::for> is already defined elsewhere.
3905 wakaba 1.27
3906 wakaba 1.48 ElementTypeBinding:
3907     @Name: ForDefNoQNameException
3908     @ElementType:
3909     ManakaiDOM:raises
3910     @ShadowContent:
3911     @@@: NO_FOR_QNAME_ERR
3912     @@Description:
3913     @@@lang:en
3914     @@@@:
3915     A <Q::dis:ForDef> element must have a <Q::dis:QName> attribute.
3916 wakaba 1.22
3917 wakaba 1.48 ElementTypeBinding:
3918     @Name: ResDefDupException
3919     @ElementType:
3920     ManakaiDOM:raises
3921     @ShadowContent:
3922     @@@: RESOURCE_ALREADY_DEFINED_ERR
3923     @@Description:
3924     @@@lang:en
3925     @@@@:
3926     The <QUOTE::dis> resource is already defined elsewhere.
3927 wakaba 1.24
3928 wakaba 1.48 ElementTypeBinding:
3929     @Name: ElementNotAllowedException
3930     @ElementType:
3931     ManakaiDOM:raises
3932     @ShadowContent:
3933     @@@: ELEMENT_NOT_ALLOWED_ERR
3934     @@Description:
3935     @@@lang:en
3936     @@@@:
3937     An element has found where it is not allowed.
3938 wakaba 1.24
3939 wakaba 1.48 IFClsDef:
3940     @IFQName: DISModuleResolver
3941     @ClsQName: ManakaiDISModuleResolver
3942 wakaba 1.22
3943 wakaba 1.48 @enDesc:
3944     Objects implementing <IF::DISModuleResolver> interface
3945     are used to convert module name into <QUOTE::dis> document object.
3946     \
3947     {NOTE:: It is also acceptable to pass a <Perl::CODE> reference
3948     as a method parameter where <IF::DISModuleResolver> is
3949     expected.
3950     \
3951     }
3952 wakaba 1.24 @Method:
3953 wakaba 1.48 @@Name: uriToDocument
3954 wakaba 1.32 @@enDesc:
3955 wakaba 1.48 Returns a <QUOTE::dis> document from module name information.
3956     @@Param:
3957     @@@Name: disDB
3958     @@@Type: DISDatabase
3959     @@@clsActualType: ManakaiDISDatabase
3960     @@@enDesc:
3961     The <QUOTE::dis> database.
3962     @@Param:
3963     @@@Name: moduleURI
3964     @@@Type: ModuleURI
3965     @@@enDesc:
3966     The URI reference of the module.
3967     \
3968     {NOTE:: This parameter is redundant, since it can be
3969     composed from other three parameters.
3970     \
3971     }
3972     @@Param:
3973     @@@Name: moduleNamespaceURI
3974     @@@Type: AnyURI
3975     @@@enDesc:
3976     The namespace URI of the module name.
3977     @@Param:
3978     @@@Name: moduleLocalName
3979     @@@Type:
3980 wakaba 1.110 DISCore:LocalName
3981 wakaba 1.48 @@@enDesc:
3982     The local name of the module name.
3983 wakaba 1.24 @@Param:
3984 wakaba 1.48 @@@Name: moduleFor
3985     @@@Type: ForURI
3986 wakaba 1.24 @@@enDesc:
3987 wakaba 1.48 The <QUOTE::for> URI reference for which the module is defined.
3988 wakaba 1.24 @@Return:
3989 wakaba 1.48 @@@Type: DISDocument
3990     @@@clsActualType: ManakaiDISDocument
3991 wakaba 1.24 @@@enDesc:
3992 wakaba 1.48 The <QUOTE::dis> document. It don't have to be a newly created
3993     object.
3994     @@@nullCase:
3995     @@@@enDesc:
3996     The method is unable to resolve the reference.
3997 wakaba 1.24 @@@PerlDef:
3998 wakaba 1.72 goto &$self;
3999 wakaba 1.48
4000     @ResourceDef:
4001     @@rdf:type: DISLang|InputProcessor
4002     @@PerlDef:
4003     $INPUT = bless $INPUT, <ClassName::ManakaiDISModuleResolver>
4004     if ref $INPUT eq 'CODE';
4005     ##DISModuleResolver
4006 wakaba 1.22
4007 wakaba 1.24 PropDef:
4008 wakaba 1.48 @QName: sourceFile
4009     @enDesc:
4010     Source <QUOTE::dis> documents.
4011     @rdfs:domain: DISDatabase
4012     @rdfs:range: DISDocument
4013    
4014     IFClsDef:
4015     @IFQName: DISAnyResource
4016     @ClsQName: ManakaiDISAnyResource
4017    
4018 wakaba 1.24 @enDesc:
4019 wakaba 1.48 {P:: A <IF::DISAnyResource> object represents a resource defined
4020     in <QUOTE::dis> files. In <QUOTE::dis> model, resources are
4021     categorized as:
4022    
4023     - Module::: A <QUOTE::dis> module is a file entity.
4024     This kind of objects <kwd:MUST> implement the
4025     <IF::DISModule> interface.
4026    
4027     - <QUOTE::For>::: A <QUOTE::for> is a target for which
4028     resources are defined. This kind of objects
4029     <kwd:MUST> implement the <IF::DISFor> interface.
4030    
4031     - <QUOTE::dis> Resource::: Something described in <QUOTE::dis>.
4032     This kind of objects <kwd:MUST> implement the
4033     <IF::DISModule> interface.
4034 wakaba 1.24
4035 wakaba 1.48 }
4036 wakaba 1.22
4037 wakaba 1.48 @Attr:
4038     @@Name: uri
4039     @@Type: AnyURI
4040     @@Description:
4041     @@@lang:en
4042     @@@@:
4043     The URI reference of the resource.
4044     @@Get:
4045     @@@enDesc:
4046     The representive URI reference of the resource.
4047 wakaba 1.21
4048 wakaba 1.48 {NOTE:: The URI might be non-persistent if the
4049     resource is not assigned a URI in <QUOTE::dis> source file,
4050     in which case a URI is randomly-generated at the
4051     time of object generation.
4052     }
4053     @@@PerlDef:
4054     $r = $self->{uri};
4055 wakaba 1.54
4056     @Attr:
4057     @@Name: uriRef
4058 wakaba 1.110 @@Type: DISPerl|SCALAR
4059 wakaba 1.54 @@enDesc:
4060     A reference to the URI of the resource.
4061    
4062     {NOTE:: Applications <kwd:MUST-NOT> modify the referenced
4063     value directly.
4064     }
4065     @@Get:
4066     @@@PerlDef: $r = \ ($self->{uri});
4067 wakaba 1.48
4068     @Attr:
4069     @@Name: uris
4070     @@Type:
4071 wakaba 1.110 DISPerl:Array
4072 wakaba 1.48 @@enDesc:
4073     A set of URIs that identifies the resource.
4074     @@Get:
4075     @@@enDesc:
4076     A reference to array in which the URIs are contained
4077     in undefined order.
4078 wakaba 1.38
4079 wakaba 1.48 {NOTE:: The array is <EM::not> live; it is only a snapshot.
4080     }
4081 wakaba 1.47
4082 wakaba 1.48 @Method:
4083     @@Name: isSameResource
4084 wakaba 1.21 @@Operator:
4085     @@@@:eq
4086     @@@ContentType:
4087     lang:Perl
4088     @@enDesc:
4089 wakaba 1.48 Whether two resources are same or not. Two resources are
4090     same if and only if their <A::DISAnyResource.uri> are
4091     equivalent as strings (i.e. in character-by-character based matching).
4092 wakaba 1.21 @@Param:
4093     @@@Name: anotherResource
4094 wakaba 1.48 @@@Type: DISAnyResource
4095 wakaba 1.21 @@@enDesc:
4096 wakaba 1.48 Another resource object to compare.
4097 wakaba 1.21 @@Return:
4098     @@@Type:
4099 wakaba 1.110 DOMMain:boolean
4100 wakaba 1.21 @@@enDesc:
4101 wakaba 1.48 Whether two resources are same or not.
4102     @@@TrueCase:
4103     @@@@enDesc: Two resources are same.
4104     @@@FalseCase:
4105     @@@@enDesc: Two resources are different.
4106 wakaba 1.21 @@@PerlDef:
4107     if (UNIVERSAL::isa ($anotherResource,
4108 wakaba 1.48 <ClassName::ManakaiDISAnyResource>)) {
4109 wakaba 1.21 $r = $self->{uri} eq $anotherResource->{uri};
4110     }
4111 wakaba 1.2
4112     @Attr:
4113     @@Name: nameURI
4114     @@Type: NameURI
4115     @@enDesc:
4116 wakaba 1.48 The URI reference of this module, without
4117 wakaba 1.2 <QUOTE::for> identifier.
4118     @@Get:
4119 wakaba 1.49 @@@enDesc:
4120     The name URI of the resource.
4121     @@@nullCase:
4122     @@@@enDesc:
4123     The resource has no name URI.
4124    
4125     {NOTE:: A resource has no URI if and only if the resource
4126     has no local name.
4127     }
4128 wakaba 1.3 @@@PerlDef:
4129 wakaba 1.49 if (defined $self->{localName}) {
4130     $r = defined $self->{namespaceURI}
4131 wakaba 1.59 ? ${$self->{namespaceURI}} . ${$self->{localName}}
4132     : ${$self->{localName}};
4133 wakaba 1.49 }
4134 wakaba 1.2
4135     @Attr:
4136 wakaba 1.48 @@Name: localName
4137 wakaba 1.32 @@enDesc:
4138 wakaba 1.48 The local name of this module.
4139 wakaba 1.32
4140 wakaba 1.48 {NOTE:: <QUOTE::for> resources has no local name.
4141     }
4142 wakaba 1.2 @@Type:
4143 wakaba 1.110 DISCore:LocalName
4144 wakaba 1.2 @@Get:
4145     @@@PerlDef:
4146 wakaba 1.59 $r = defined $self->{localName} ? ${$self->{localName}} : null;
4147 wakaba 1.2
4148     @Attr:
4149     @@Name: namespaceURI
4150     @@Type: AnyURI
4151     @@enDesc:
4152     The namespace URI of the name of this resource.
4153 wakaba 1.48
4154     {NOTE:: <QUOTE::for> resources has no namespace URI.
4155     }
4156 wakaba 1.2 @@Get:
4157     @@@PerlDef:
4158 wakaba 1.59 $r = defined $self->{namespaceURI} ? ${$self->{namespaceURI}} : null;
4159 wakaba 1.2
4160     @Attr:
4161     @@Name: forURI
4162 wakaba 1.48 @@Type: ForURI
4163 wakaba 1.2 @@enDesc:
4164 wakaba 1.48 The <QUOTE::for> URI reference for which this module is defined.
4165 wakaba 1.2 @@Get:
4166     @@@PerlDef:
4167 wakaba 1.59 $r = defined $self->{for} ? ${$self->{for}} : null;
4168 wakaba 1.2
4169     @Attr:
4170     @@Name: forpURI
4171     @@enDesc:
4172     The <QUOTE::for+> URI references for which this resource is defined.
4173 wakaba 1.48
4174     {NOTE:: <QUOTE::for> resources has no <QUOTE::for+> URI.
4175     }
4176 wakaba 1.2 @@Type: ForURIList
4177     @@Get:
4178 wakaba 1.15 @@@enDesc:
4179     List of <QUOTE::for> URI references. Note that this list is
4180     <QUOTE::dead>.
4181 wakaba 1.3 @@@PerlDef:
4182 wakaba 1.15 $r = [@{$self->{forp}}];
4183    
4184     @Method:
4185     @@Name: isForURI
4186     @@enDesc:
4187     Tests whether this resource is defined for a <QUOTE::for>
4188     or <QUOTE::for+> URI reference or not.
4189     @@Param:
4190     @@@Name:forURI
4191     @@@Type:ForURI
4192     @@@enDesc:
4193     A <QUOTE::for> URI reference to test.
4194     @@Return:
4195     @@@Type:
4196 wakaba 1.110 DOMMain:boolean
4197 wakaba 1.15 @@@TrueCase:
4198     @@@@enDesc:
4199     This resource is for <P::forURI>.
4200     @@@FalseCase:
4201     @@@@enDesc:
4202     This resource is not for <P::forURI>.
4203     @@@PerlDef:
4204     __DEEP{
4205 wakaba 1.59 C: for my $this_for_uri (${$self->{for}||\''}, @{$self->{forp}||[]}) {
4206 wakaba 1.15 if ($this_for_uri eq $forURI) { ## Shortcut
4207     $r = true;
4208 wakaba 1.48 last C;
4209 wakaba 1.15 }
4210 wakaba 1.98 my $this_for = $self-><AG::DISAnyResource.database>
4211     -><M::DIS|DISDatabase.getFor>
4212 wakaba 1.15 ($this_for_uri);
4213 wakaba 1.48 if ($this_for-><M::DIS|DISFor.isaURI> ($forURI)) {
4214 wakaba 1.15 $r = true;
4215 wakaba 1.48 last C;
4216 wakaba 1.15 }
4217     }
4218     }__;
4219 wakaba 1.48
4220     @Attr:
4221     @@Name: isDefined
4222 wakaba 1.2 @@Description:
4223     @@@lang:en
4224     @@@@:
4225 wakaba 1.48 Whether this module is defined or not.
4226     @@Type:
4227 wakaba 1.110 DOMMain:boolean
4228 wakaba 1.48 @@Get:
4229     @@@PerlDef:
4230 wakaba 1.53 $r = $self->{<H::DIS|isDefined>};
4231 wakaba 1.79 @@Set:
4232     @@@PerlDef:
4233     $self->{<H::DIS|isDefined>} = $given;
4234 wakaba 1.48
4235     @Attr:
4236     @@Name: ownerModule
4237     @@enDesc:
4238     The module in which the resource is defined. If the resource
4239     is a module, the module itself is the attribute value.
4240     @@Get:
4241     @@@Type: DISModule
4242     @@@clsActualType: ManakaiDISModuleDefinition
4243     @@@enDesc:
4244     The owner module object.
4245     @@@nullCase:
4246 wakaba 1.2 @@@@enDesc:
4247 wakaba 1.48 The resource is not part of any module since
4248     its definition is not read (i.e. <A::DISAnyResource.isDefined> is
4249 wakaba 1.79 <DOM::false>) or since it is created in memory.
4250 wakaba 1.2 @@@PerlDef:
4251 wakaba 1.98 $r = $self-><AG::DISAnyResource.database>
4252 wakaba 1.48 -><M::DISDatabase.getModule>
4253 wakaba 1.53 (${$self->{<H::DIS|definingModule>}})
4254     if defined $self->{<H::DIS|definingModule>};
4255 wakaba 1.2
4256 wakaba 1.48 @Attr:
4257 wakaba 1.54 @@Name: ownerModuleURI
4258     @@enDesc:
4259     A URI of the owner module of the resource.
4260     @@Type: DIS|AnyURI
4261     @@nullCase:
4262     @@@enDesc:
4263     The resource does not belong to any module since the
4264 wakaba 1.79 resource definition is not read yet or since
4265     it is created in memory.
4266 wakaba 1.54 @@Get:
4267     @@@PerlDef:
4268     if (defined $self->{<H::DIS|definingModule>}) {
4269     $r = ${$self->{<H::DIS|definingModule>}};
4270     }
4271    
4272     @Attr:
4273     @@Name: ownerModuleURIRef
4274     @@enDesc:
4275     A reference to a URI of the owner module of the resource.
4276 wakaba 1.110 @@Type: DISPerl|SCALAR
4277 wakaba 1.54 @@nullCase:
4278     @@@enDesc:
4279     The resource does not belong to any module since the
4280 wakaba 1.79 resource definition is not read yet or since
4281     it is created in memory.
4282 wakaba 1.54 @@Get:
4283     @@@PerlDef:
4284     $r = $self->{<H::DIS|definingModule>};
4285 wakaba 1.88 @@Set:
4286     @@@PerlDef:
4287     $self->{<H::DIS|definingModule>} = $given;
4288 wakaba 1.54
4289     @Attr:
4290 wakaba 1.48 @@Name: isReferred
4291     @@Description:
4292     @@@lang:en
4293     @@@@:
4294     Whether the resource is referenced somewhere or not.
4295 wakaba 1.110 @@Type: DISLang|String
4296 wakaba 1.48 @@Get:
4297     @@@enDesc:
4298     A node path string that identifies the node from
4299     which the resource is referenced.
4300     @@@nullCase:
4301     The resource is not referred.
4302     @@@PerlDef:
4303 wakaba 1.53 $r = $self->{<H::DIS|isReferred>};
4304 wakaba 1.48 @@Set:
4305 wakaba 1.7 @@@enDesc:
4306 wakaba 1.48 A node path string that identifies the node from
4307     which the resource is referenced.
4308     @@@InCase:
4309     @@@@Type: DISElement
4310     @@@@enDesc:
4311     The resource is referenced by the element. It's node path
4312     string is set as the attribute value.
4313     @@@PerlDef:
4314     if (defined $given) {
4315     if (ref $given) {
4316 wakaba 1.72 __DEEP{
4317 wakaba 1.50 if ($given->isa (<IFName::dv|DVValue>)) {
4318     $given = $given-><AG::dv|DVValue.sourceNodePath>;
4319     } else {
4320     $given = $given-><M::SWCFGNode.flag> ('nodePath') ||
4321     $given-><M::SWCFGNode.nodePath>
4322 wakaba 1.52 (key => [qw/QName Name type Type/]);
4323 wakaba 1.50 }
4324 wakaba 1.72 }__;
4325 wakaba 1.48 }
4326 wakaba 1.53 $self->{<H::DIS|isReferred>} = $given;
4327 wakaba 1.48 }
4328    
4329     @Attr:
4330     @@Name: sourceNodeID
4331     @@enDesc:
4332     The identifier URI reference of the source node.
4333     @@enDesc:
4334     @@@ForCheck: ManakaiDOM|ForClass
4335     @@@@:
4336     Modules and <QUOTE::for>s does not have source node identifier
4337     in the current implementation.
4338     @@Type: AnyURI
4339     @@Get:
4340     @@@nullCase:
4341     @@@@enDesc:
4342     The resource is not (yet) associated with any source node.
4343     @@@PerlDef:
4344 wakaba 1.53 if (defined $self->{<H::DIS:sourceNodeID>}) {
4345     $r = ${$self->{<H::DIS:sourceNodeID>}};
4346 wakaba 1.50 } else {
4347     $r = null;
4348     }
4349     @@Set:
4350     @@@PerlDef:
4351     if (defined $given) {
4352 wakaba 1.53 $self->{<H::DIS:sourceNodeID>} = \$given;
4353 wakaba 1.50 } else {
4354 wakaba 1.53 CORE::delete $self->{<H::DIS:sourceNodeID>};
4355 wakaba 1.50 }
4356    
4357     @Attr:
4358     @@Name: sourceNodeIDRef
4359     @@enDesc:
4360     The identifier URI reference of the source node.
4361     @@enDesc:
4362     @@@ForCheck: ManakaiDOM|ForClass
4363     @@@@:
4364     Modules and <QUOTE::for>s does not have source node identifier
4365     in the current implementation.
4366 wakaba 1.110 @@Type: DISPerl|SCALAR
4367 wakaba 1.50 @@Get:
4368     @@@nullCase:
4369     @@@@enDesc:
4370     The resource is not (yet) associated with any source node.
4371     @@@PerlDef:
4372 wakaba 1.53 $r = $self->{<H::DIS:sourceNodeID>};
4373 wakaba 1.48 @@Set:
4374 wakaba 1.7 @@@PerlDef:
4375 wakaba 1.50 if (defined $given) {
4376 wakaba 1.53 $self->{<H::DIS:sourceNodeID>} = $given;
4377 wakaba 1.50 } else {
4378 wakaba 1.53 CORE::delete $self->{<H::DIS:sourceNodeID>};
4379 wakaba 1.50 }
4380 wakaba 1.7
4381 wakaba 1.2 @Attr:
4382 wakaba 1.48 @@Name: isAnonymous
4383     @@enDesc:
4384     Whether the resource has persistent name or not.
4385     @@Type:
4386 wakaba 1.110 DOMMain:boolean
4387 wakaba 1.2 @@Get:
4388     @@@TrueCase:
4389 wakaba 1.48 This resource does <EM::not> have any globally unique name.
4390     <A::DISAnyResource.uri> is a temporary URI reference.
4391 wakaba 1.2 @@@FalseCase:
4392 wakaba 1.48 This resource does have its formal name.
4393     <A::DISAnyResource.uri> is a URI reference
4394     generated from the name and the <QUOTE::for> URI reference
4395     of this resource.
4396 wakaba 1.2 @@@PerlDef:
4397 wakaba 1.53 $r = $self->{<H::DIS|isAnon>};
4398 wakaba 1.79 @@Set:
4399     @@@PerlDef:
4400     $self->{<H::DIS|isAnon>} = $given;
4401 wakaba 1.2
4402     @Attr:
4403 wakaba 1.48 @@Name: sourceElement
4404     @@enDesc:
4405     The source <QUOTE::dis> element node from which this
4406     definition is read.
4407 wakaba 1.2 @@Get:
4408 wakaba 1.48 @@@Type: DISElement
4409     @@@InCase:
4410     @@@@Type: DISModuleElement
4411     @@@@enDesc: If this resource is a module.
4412     @@@PerlDef: $r = $self->{src};
4413 wakaba 1.2 @@@nullCase:
4414 wakaba 1.48 @@@@enDesc:
4415     The definition is not yet read.
4416 wakaba 1.2
4417     @Attr:
4418 wakaba 1.48 @@Name: database
4419     @@enDesc:
4420     The <QUOTE::dis> database to which the resource belongs.
4421     @@Type: DISDatabase
4422 wakaba 1.2 @@Get:
4423     @@@PerlDef:
4424 wakaba 1.48 $r = $self->{db};
4425    
4426 wakaba 1.6 @Method:
4427 wakaba 1.48 @@Name: readProperties
4428 wakaba 1.6 @@enDesc:
4429 wakaba 1.48 Reads property values in the source tree and
4430     removes reference to the source node.
4431     @@NamedParam:
4432     @@@Name: onResourceRead
4433     @@@Type:
4434 wakaba 1.110 DISPerl:CODE
4435 wakaba 1.6 @@@enDesc:
4436 wakaba 1.48 An event handler called when a resource is read.
4437     @@@nullCase:
4438     @@@@enDesc:
4439     No event handler is read.
4440 wakaba 1.101 @@NamedParam:
4441     @@@Name: implementation
4442 wakaba 1.104 @@@Type: DOMImpl
4443 wakaba 1.101 @@@enDesc:
4444 wakaba 1.104 The <IF::DOMImpl> object to which the database belongs.
4445 wakaba 1.101 It might be used to create property value objects.
4446 wakaba 1.6 @@Return:
4447 wakaba 1.11 @@@RaiseException:
4448 wakaba 1.48 @@@@@: UNSUPPORTED_ELEMENT_TYPE_ERR
4449     @@@@enDesc:
4450     There is an element whose element type is not supported.
4451 wakaba 1.11 @@@PerlDef:
4452 wakaba 1.6 __DEEP{
4453 wakaba 1.48 if (my $src = $self->{src}) {
4454 wakaba 1.49 my $for = $self-><AG::DISAnyResource.forURI>;
4455     my $forp = $self-><AG::DISAnyResource.forpURI>;
4456     my $db = $self-><AG::DISAnyResource.database>;
4457 wakaba 1.101 my $factory;
4458 wakaba 1.48 for my $el (@{$src-><M::DISElement.disChildElements>
4459 wakaba 1.49 (for_arg => $for,
4460     forp_arg => $forp,
4461     database_arg => $db)}) {
4462 wakaba 1.48 my $xu = $el-><AG::SWCFGElement.expandedURI>;
4463     if ({
4464     <Q::dis:AliasFor> => true,
4465     <Q::dis:ContentType> => true,
4466     <Q::dis:dataType> => true,
4467     <Q::dis:For> => true,
4468     <Q::dis:ForCheck> => true,
4469     <Q::dis:Name> => true,
4470     <Q::dis:Namespace> => true,
4471     <Q::dis:multipleProperties> => true,
4472 wakaba 1.81 <Q::DISCore|resourceType> => true,
4473     <Q::rdf:type> => true, ## TODO: Remove this.
4474 wakaba 1.48 <Q::dis:QName> => true,
4475     <Q::dis:Require> => true,
4476     <Q::dis:resourceFor> => true,
4477     }->{$xu}) {
4478     #
4479 wakaba 1.49 } elsif ($el-><M::DISElement.isPropertyElement>
4480     (database_arg => $db)) {
4481 wakaba 1.48 my $add_prop;
4482     $add_prop = sub ($$$) {
4483     my ($self, $el, $db) = @_;
4484     my $prop = $db-><M::DISDatabase.getResource>
4485     ($el-><AG::SWCFGElement.expandedURI>);
4486     my $prop_uri = $prop-><AG::DISAnyResource.uri>;
4487     my $prop_mult = $prop-><AG::DISResource.multiplePropertiesURI>;
4488     my $new_value;
4489     my $base_type;
4490     my $copy_tree = false;
4491    
4492 wakaba 1.49 my %mtopt = (for_arg => $for,
4493     forp_arg => $forp,
4494 wakaba 1.48 default_media_type => $prop-><AG::DISResource
4495 wakaba 1.49 .defaultLextypeURI>,
4496     database_arg => $db);
4497 wakaba 1.51 my $new_value_type = $el-><M::DISElement.mediaTypeURI>(%mtopt);
4498    
4499 wakaba 1.48 if ($el-><M::DISElement.mediaTypeMatch>
4500 wakaba 1.68 (<Q::DISCore:QName>, $mtopt{default_media_type}, %mtopt)) {
4501 wakaba 1.48 __CODE{dv|createValue::
4502     $value => {null},
4503 wakaba 1.68 $base_type => {$base_type = <Q::DISCore:QName>},
4504 wakaba 1.50 $type => {$new_value_type},
4505 wakaba 1.48 $result => $new_value,
4506 wakaba 1.60 $name => {$prop_uri},
4507 wakaba 1.48 }__;
4508     $new_value-><AS::dv|DVQNameValue.localName>
4509     ($el-><AG::DISElement.qnameValueLocalName>);
4510     $new_value-><AS::dv|DVQNameValue.prefix>
4511 wakaba 1.49 (my $prefix = $el-><AG::DISElement.qnameValuePrefix>);
4512     if (not defined $prefix) {
4513     if ($el-><M::DISElement.mediaTypeMatch>
4514     (<Q::DISCore:LanguageTag>,
4515     $mtopt{default_media_type}, %mtopt)) {
4516     $new_value-><AS::dv|DVQNameValue.namespaceURI>
4517     ('urn:x-suika-fam-cx:lang:');
4518     } elsif ($el-><M::DISElement.mediaTypeMatch>
4519     (<Q::DISCore:ScriptTag>,
4520     $mtopt{default_media_type}, %mtopt)) {
4521     $new_value-><AS::dv|DVQNameValue.namespaceURI>
4522     ('http://suika.fam.cx/~wakaba/archive/2005/5/script#');
4523     } else {
4524     $new_value-><AS::dv|DVQNameValue.namespaceURI>
4525     ($el-><AG::DISElement.qnameValueNamespaceURI>);
4526     }
4527     } else {
4528     $new_value-><AS::dv|DVQNameValue.namespaceURI>
4529     ($el-><AG::DISElement.qnameValueNamespaceURI>);
4530     }
4531 wakaba 1.48 ## TODO: Check whether defined
4532     } elsif ($el-><M::DISElement.mediaTypeMatch>
4533     (<Q::dis:TFQNames>, $mtopt{default_media_type}, %mtopt) or
4534     $el-><M::DISElement.mediaTypeMatch>
4535     (<Q::DISCore:TFPQNames>, $mtopt{default_media_type}, %mtopt)) {
4536     __CODE{dv|createURI::
4537     $uri => {$el-><M::DISElement.tfqnamesValueURI>
4538     ($self-><AG::DISAnyResource.sourceNodeID>,
4539     $self-><AG::DISAnyResource.forURI>,
4540     for_arg => $self-><AG::DISAnyResource.forURI>,
4541 wakaba 1.49 forp_arg => $self-><AG::DISAnyResource.forpURI>,
4542     database_arg => $db)},
4543 wakaba 1.48 $result => $new_value,
4544 wakaba 1.60 $name => {$prop_uri},
4545 wakaba 1.48 }__;
4546     ## TODO: Check whether defined
4547 wakaba 1.50 $new_value_type = <Q::DISCore:URI>;
4548 wakaba 1.48 } elsif ($el-><M::DISElement.mediaTypeMatch>
4549     (<Q::lang:Perl>, $mtopt{default_media_type},
4550     %mtopt)) {
4551     $el-><M::DISElement.preserveNodePath>;
4552 wakaba 1.50 __CODE{dv|createValueRef::
4553     $value_ref => {$el-><AG::SWCFGNode.valueRef>},
4554 wakaba 1.49 $base_type => {$base_type = <Q::lang:Perl>},
4555 wakaba 1.50 $type => {$new_value_type},
4556 wakaba 1.48 $result => $new_value,
4557 wakaba 1.60 $name => $prop_uri,
4558 wakaba 1.48 }__;
4559     for my $p (<Q::dis:Type>, <Q::dis:actualType>) {
4560     if (UNIVERSAL::isa ($self->{$p},<IFName::dv|DVURIValue>)) {
4561     my $v;
4562     __CODE{dv|createURI::
4563     $uri => {$self->{$p}-><AG::dv|DVURIValue.uri>},
4564     $result => $v,
4565 wakaba 1.60 $name => $prop_uri,
4566 wakaba 1.48 }__;
4567     $new_value-><M::dv|DVValue.setProperty> ($p => $v);
4568     }
4569     }
4570 wakaba 1.49 $new_value-><AS::dv|DVNSValue.defaultNamespaceURIRef>
4571     ($el-><M::DISElement.getDefaultNamespaceURIRef>);
4572     $new_value-><AS::dv|DVNSValue.namespaceBindingList>
4573     ($el-><M::DISElement.getNamespaceBindingList> ($db));
4574     $new_value-><AS::dv|DVValue.sourceNodePath>
4575     ($el-><M::SWCFGNode.flag> ('nodePath'));
4576 wakaba 1.48 } elsif ($el-><M::DISElement.mediaTypeMatch>
4577     (<Q::lang:disdoc>, $mtopt{default_media_type},
4578     %mtopt) or
4579     $el-><M::DISElement.mediaTypeMatch>
4580     (<Q::lang:disdocInline>, $mtopt{default_media_type},
4581 wakaba 1.49 %mtopt) or
4582     $el-><M::DISElement.mediaTypeMatch>
4583     (<Q::lang:muf>, $mtopt{default_media_type},
4584 wakaba 1.74 %mtopt) or
4585     $el-><M::DISElement.mediaTypeMatch>
4586     (<Q::lang:dpg>, $mtopt{default_media_type},
4587 wakaba 1.77 %mtopt) or
4588     $el-><M::DISElement.mediaTypeMatch>
4589     (<Q::lang:tdterr>,
4590     $mtopt{default_media_type},
4591 wakaba 1.49 %mtopt)) {
4592     $el-><M::DISElement.preserveNodePath>;
4593 wakaba 1.50 __CODE{dv|createValueRef::
4594     $value_ref => {$el-><AG::SWCFGNode.valueRef>},
4595 wakaba 1.49 $base_type => {$base_type = <Q::lang:disdoc>},
4596 wakaba 1.50 $type => $new_value_type,
4597 wakaba 1.49 $result => $new_value,
4598 wakaba 1.60 $name => $prop_uri,
4599 wakaba 1.49 }__;
4600     $new_value-><AS::dv|DVNSValue.defaultNamespaceURIRef>
4601     ($el-><M::DISElement.getDefaultNamespaceURIRef>);
4602     $new_value-><AS::dv|DVNSValue.namespaceBindingList>
4603     ($el-><M::DISElement.getNamespaceBindingList> ($db));
4604     $new_value-><AS::dv|DVValue.sourceNodePath>
4605     ($el-><M::SWCFGNode.flag> ('nodePath'));
4606     } elsif ($el-><M::DISElement.mediaTypeMatch>
4607 wakaba 1.52 (<Q::dx|XCRef>,
4608     $mtopt{default_media_type}, %mtopt)) {
4609     my $x = $db-><M::DISDatabase.xcrefToResource>
4610     ($el-><M::SWCFGNode.value>,
4611 wakaba 1.59 $el, node => $el,
4612     for_arg => $self-><AG::DIS|DISAnyResource.forURI>);
4613 wakaba 1.52 __CODE{dv|createURI::
4614     $uri => {($x->[2] or $x->[1] or $x->[0])
4615     -><AG::DISAnyResource.uri>},
4616     $result => $new_value,
4617 wakaba 1.60 $name => $prop_uri,
4618 wakaba 1.52 }__;
4619     $new_value-><M::dv|DVURIValue.getResource> ($db)
4620     -><AS::DISAnyResource.isReferred> ($el);
4621     $new_value_type = <Q::DISCore:URI>;
4622     } elsif ($el-><M::DISElement.mediaTypeMatch>
4623     (<Q::DISLang|MemberRef>,
4624     $mtopt{default_media_type}, %mtopt)) {
4625     my $v = $el-><M::SWCFGNode.value>;
4626     $v =~ s/^\s+//; $v =~ s/\s+$//;
4627     my ($clsq, $mem, $gs) = split /\s*\.\s*/, $v, 3;
4628     my $res;
4629     if (defined $mem) {
4630     my $cls = $db-><M::DISDatabase.getResource>
4631     ($el-><M::DISElement.tfqnamesValueURI>
4632     ($clsq, $self-><AG::DISAnyResource.sourceNodeID>,
4633     $self-><AG::DISAnyResource.forURI>, node => $el));
4634     $cls-><AS::DISAnyResource.isReferred> ($el);
4635     $res = $cls-><M::DISResource.getChildResourceByNameAndType>
4636     ($mem, <Q::DISLang:AnyMethod>);
4637     unless ($res) {
4638     __UNDEEP{__EXCEPTION{DIS|RESOURCE_NOT_DEFINED_ERR::
4639     DIS:localName => {$mem},
4640     DIS:parentURI => {$cls-><AG::DISAnyResource.uri>},
4641     DIS:elementType => {$el-><AG::SWCFGElement
4642     .expandedURI>},
4643     DIS:sourceNode => {$el},
4644     DIS:sourceCode => {$v},
4645     DIS:expectedType => {
4646     defined $gs ? <Q::DISLang:Attribute>
4647     : <Q::DISLang:Method>
4648     },
4649     }__}__;
4650     }
4651     if (defined $gs) {
4652     $res = $res-><M::DISResource.getChildResourceByType>
4653     ($gs eq 'get' ? <Q::DISLang|AttributeGet>
4654     : <Q::DISLang|AttributeSet>);
4655     unless ($res) {
4656     __UNDEEP{__EXCEPTION{DIS|RESOURCE_NOT_DEFINED_ERR::
4657     DIS:parentURI => {$res-><AG::DISAnyResource.uri>},
4658     DIS:elementType => {$el-><AG::SWCFGElement
4659     .expandedURI>},
4660     DIS:sourceNode => {$el},
4661     DIS:sourceCode => {$v},
4662     DIS:expectedType => {
4663     $gs eq 'get' ? <Q::DISLang:AttributeGet>
4664     : <Q::DISLang:AttributeSet>
4665     },
4666     }__}__;
4667     }
4668     }
4669     } else {
4670     $res = $db-><M::DISDatabase.getResource>
4671     ($el-><M::DISElement.tfqnamesValueURI>
4672     ($clsq, $self-><AG::DISAnyResource.sourceNodeID>,
4673     $self-><AG::DISAnyResource.forURI>, node => $el));
4674     }
4675     $res-><AS::DISAnyResource.isReferred> ($el);
4676     __CODE{dv|createURI::
4677     $uri => {$el-><AG::DISAnyResource.uri>},
4678     $result => $new_value,
4679 wakaba 1.60 $name => $prop_uri,
4680 wakaba 1.52 }__;
4681     $new_value_type = <Q::DISCore:URI>;
4682 wakaba 1.100 } elsif ($el-><M::DISElement.mediaTypeMatch>
4683 wakaba 1.101 (<Q::lang|dcmodel>,
4684     $mtopt{default_media_type}, %mtopt)) {
4685     unless (defined $factory) {
4686 wakaba 1.107 $factory = $implementation->create_document;
4687 wakaba 1.101 }
4688     my $mt = $db-><M::DISDatabase.getResource>
4689     ($el-><M::DISElement.mediaTypeURI>);
4690     my $node = $mt-><M::DISAnyResource.parseString>
4691 wakaba 1.102 ($el-><M::SWCFGNode.value>, $el, $factory,
4692     for_arg => $for);
4693 wakaba 1.101 __CODE{dv|createXMLValue::
4694     $value => $node,
4695     $result => $new_value,
4696     $name => $prop_uri,
4697     }__;
4698     $new_value-><AS::dv|DVValue.sourceNodePath>
4699     ($el-><M::SWCFGNode.flag> ('nodePath'));
4700     } elsif ($el-><M::DISElement.mediaTypeMatch>
4701 wakaba 1.100 (<Q::DISCore:NSString>,
4702     $mtopt{default_media_type}, %mtopt)) {
4703     $el-><M::DISElement.preserveNodePath>;
4704     __CODE{dv|createValueRef::
4705     $value_ref => {$el-><AG::SWCFGNode.valueRef>},
4706     $base_type => {$base_type = <Q::DISCore:NSString>},
4707     $type => $new_value_type,
4708     $result => $new_value,
4709     $name => $prop_uri,
4710     }__;
4711     $new_value-><AS::dv|DVNSValue.defaultNamespaceURIRef>
4712     ($el-><M::DISElement.getDefaultNamespaceURIRef>);
4713     $new_value-><AS::dv|DVNSValue.namespaceBindingList>
4714     ($el-><M::DISElement.getNamespaceBindingList> ($db));
4715     $new_value-><AS::dv|DVValue.sourceNodePath>
4716     ($el-><M::SWCFGNode.flag> ('nodePath'));
4717 wakaba 1.52 } elsif ($el-><M::DISElement.mediaTypeMatch>
4718 wakaba 1.49 (<Q::lang:dis>, $mtopt{default_media_type},
4719     %mtopt)) {
4720     $copy_tree = true;
4721 wakaba 1.48 $el-><M::DISElement.preserveNodePath>;
4722     my $elc = $el->clone;
4723     __CODE{dv|createValue::
4724     $value => {$elc},
4725 wakaba 1.49 $base_type => {$base_type = <Q::lang:dis>},
4726 wakaba 1.50 $type => $new_value_type,
4727 wakaba 1.48 $result => $new_value,
4728 wakaba 1.60 $name => $prop_uri,
4729 wakaba 1.48 }__;
4730 wakaba 1.49 $elc-><M::DISElement.unlinkFromDocument> ($db);
4731 wakaba 1.64 } elsif ($el-><M::DISElement.mediaTypeMatch>
4732     (<Q::DISCore:Integer>,
4733     $mtopt{default_media_type}, %mtopt)) {
4734     my $v = $el-><M::SWCFGNode.value>;
4735     if ($v =~ /^0x/) {
4736     $v = hex $v;
4737     } else {
4738     $v += 0;
4739     }
4740     __CODE{dv|createValue::
4741     $value => $v,
4742 wakaba 1.78 $base_type => {$base_type = <Q::DISCore:Integer>},
4743     $type => $new_value_type,
4744     $result => $new_value,
4745     $name => $prop_uri,
4746     }__;
4747     } elsif ($el-><M::DISElement.mediaTypeMatch>
4748     (<Q::DISCore:UString>,
4749     $mtopt{default_media_type}, %mtopt)) {
4750     my $v = $el-><M::SWCFGNode.value>;
4751     $v =~ s/\$\x0D?\x0A//gs;
4752     $v =~ s/\$\z//;
4753     warn 'String |'.$el-><M::SWCFGNode.value>.'| contains '.
4754     'illegal |$| character' if $v =~ /\$(?![uU])/;
4755     ## TODO: Use error-handler
4756     $v =~ s{\$(u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})}{
4757     chr hex substr $1, 1
4758     }ge;
4759     __CODE{dv|createValue::
4760     $value => $v,
4761 wakaba 1.64 $base_type => {$base_type = <Q::DISCore:String>},
4762 wakaba 1.78 $type => {<Q::DISCore:String>},
4763 wakaba 1.64 $result => $new_value,
4764     $name => $prop_uri,
4765     }__;
4766 wakaba 1.78 ## NOTE: Since |type| is set to |DISCore:String|,
4767     ## what subtype of |DISCore:UString| it was originally
4768     ## is not preserved.
4769 wakaba 1.48 } else {
4770     __CODE{dv|createValue::
4771     $value => {$el-><M::SWCFGNode.value>},
4772     $base_type => {$base_type = <Q::DISCore:String>},
4773 wakaba 1.50 $type => $new_value_type,
4774 wakaba 1.48 $result => $new_value,
4775 wakaba 1.60 $name => $prop_uri,
4776 wakaba 1.48 }__;
4777     }
4778    
4779     unless ($copy_tree) {
4780     for my $ce (@{$el-><M::DISElement.disChildElements>
4781 wakaba 1.49 (for_arg => $for,
4782     forp_arg => $forp,
4783     database_arg => $db)}) {
4784 wakaba 1.48 my $xu = $ce-><AG::SWCFGElement.expandedURI>;
4785     if ({
4786     <Q::dis:AliasFor> => true,
4787     <Q::dis:For> => true,
4788     <Q::dis:ForCheck> => true,
4789     <Q::dis:ContentType> => true,
4790     <Q::dis:resourceFor> => true,
4791     }->{$xu}) {
4792     #
4793 wakaba 1.49 } elsif ($ce-><M::DISElement.isPropertyElement>
4794     (database_arg => $db)) {
4795 wakaba 1.48 my $pr;
4796     __DEEP{
4797     $pr = $add_prop->($self, $ce, $db);
4798     }__;
4799     if ($pr->{prop_mult} eq <Q::DISCore|OrderedList>) {
4800     my $cpv = $new_value-><M::dv|DVValue.getProperty> ($xu);
4801     if (not $cpv) {
4802     __CODE{dv|createOrderedList::
4803     $result => {$cpv},
4804     $type => {$mtopt{default_media_type}},
4805     $base_type => {<Q::DISCore:String>},
4806     }__;
4807     $new_value-><M::dv|DVValue.setProperty> ($xu => $cpv);
4808     }
4809     $cpv-><M::dv|DVList.addItem> ($pr->{new_value});
4810     } elsif ($pr->{prop_mult} eq <Q::DISCore|UnorderedList>) {
4811     my $cpv = $new_value-><M::dv|DVValue.getProperty> ($xu);
4812     if (not $cpv) {
4813     __CODE{dv|createUnorderedList::
4814     $result => {$cpv},
4815     $type => {$mtopt{default_media_type}},
4816     $base_type => {<Q::DISCore:String>},
4817     }__;
4818     $new_value-><M::dv|DVValue.setProperty> ($xu => $cpv);
4819     }
4820     $cpv-><M::dv|DVList.addItem> ($pr->{new_value});
4821     } else {
4822     $new_value-><M::dv|DVValue.setProperty>
4823     ($xu => $pr->{new_value});
4824     }
4825     } else {
4826     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4827     DIS:elementType => {$xu},
4828     DIS:sourceNode => {$ce},
4829     }__}__;
4830     }
4831     }} # copy_tree
4832    
4833     {new_value => $new_value, base_type => $base_type,
4834 wakaba 1.50 prop_uri => $prop_uri, prop_mult => $prop_mult,
4835     new_value_type => $new_value_type};
4836 wakaba 1.48 };
4837    
4838     my $pr;
4839     __DEEP{
4840 wakaba 1.49 $pr = $add_prop->($self, $el, $db);
4841 wakaba 1.48 }__;
4842     if ($pr->{prop_mult} eq <Q::DISCore|OrderedList>) {
4843     if (not $self->{$pr->{prop_uri}}) {
4844     __CODE{dv|createOrderedList::
4845     $result => {$self->{$pr->{prop_uri}}},
4846 wakaba 1.50 $type => {$pr->{new_value_type}},
4847 wakaba 1.48 $base_type => {$pr->{base_type} || <Q::DISCore:String>},
4848     }__;
4849     }
4850     $self->{$pr->{prop_uri}}-><M::dv|DVList.addItem>
4851     ($pr->{new_value});
4852     } elsif ($pr->{prop_mult} eq <Q::DISCore|UnorderedList>) {
4853     if (not $self->{$pr->{prop_uri}}) {
4854     __CODE{dv|createUnorderedList::
4855     $result => {$self->{$pr->{prop_uri}}},
4856 wakaba 1.50 $type => {$pr->{new_value_type}},
4857 wakaba 1.48 $base_type => {$pr->{base_type} || <Q::DISCore:String>},
4858     }__;
4859     }
4860     $self->{$pr->{prop_uri}}-><M::dv|DVList.addItem>
4861     ($pr->{new_value});
4862     } else {
4863     $self->{$pr->{prop_uri}} = $pr->{new_value};
4864     }
4865 wakaba 1.53
4866     if ($el-><M::DISElement.elementTypeMatch>
4867     (<Q::DISPerl:propHashKey>, database_arg => $db)) {
4868     $db-><M::dp|DISDatabasePerl.plAddHashKey>
4869     ($xu => $pr->{new_value}-><AG::dv|DVValue.stringValue>
4870     => $self);
4871     }
4872 wakaba 1.48 } elsif ($el-><AG::DISElement.isResourceElement>) {
4873     ## TODO: Should rdf:type be validated?
4874     } else {
4875     __UNDEEP{__EXCEPTION{UNSUPPORTED_ELEMENT_TYPE_ERR::
4876     DIS:elementType => {$xu},
4877     DIS:sourceNode => {$el},
4878     }__}__;
4879     }
4880 wakaba 1.6 }
4881 wakaba 1.48 CORE::delete $self->{src};
4882     ($onResourceRead or sub () {})->($self, $self);
4883 wakaba 1.6 }
4884     }__;
4885 wakaba 1.61
4886     @Method:
4887     @@Name: isTypeURI
4888     @@enDesc:
4889     Tests whether this resource is of a type or not.
4890     @@Param:
4891     @@@Name: typeURI
4892     @@@Type: ResourceURI
4893     @@@enDesc:
4894     A type URI reference to test.
4895     @@Return:
4896     @@@Type:
4897 wakaba 1.110 DOMMain:boolean
4898 wakaba 1.61 @@@TrueCase:
4899     @@@@enDesc:
4900     This is a <P::typeURI> resource.
4901     @@@FalseCase:
4902     @@@@enDesc:
4903     This is not a <P::typeURI> resource.
4904 wakaba 1.79 @@@PerlDef:
4905     __DEEP{
4906     $r = $self-><AG::DISAnyResource.typeResource>
4907     -><M::DISResource.isSubsetOfURI> ($typeURI);
4908     }__;
4909    
4910     @Attr:
4911     @@Name: revision
4912     @@enDesc:
4913     The revision number of the resource.
4914    
4915     {ISSUE::
4916     Is it necessary for revision numbers to hold some
4917     kind of globality?
4918     }
4919     @@Type: RevisionNumber
4920     @@Get:
4921     @@@PerlDef:
4922     $r = $self->{<H::DIS|revision>};
4923    
4924     @CODE:
4925     @@QName: setRevision
4926     @@enDesc:
4927     Sets new revision number to a resource.
4928     @@PerlDef:
4929     $resource->{<H::DIS|revision>} = time;
4930    
4931     @CODE:
4932     @@QName: updateRevision
4933     @@enDesc:
4934     Updates revision number of a resource.
4935    
4936     {ISSUE::
4937     How revision number should be increased?
4938     }
4939     @@PerlDef:
4940     $resource->{<H::DIS|revision>}++;
4941    
4942     @Method:
4943     @@Name: getTypeURIList
4944     @@enDesc:
4945     Returns a snapshot list of resource type URIs of the resource.
4946     @@Return:
4947     @@@Type: URIList
4948     @@@enDesc:
4949     A snapshot list of URIs.
4950     @@@PerlDef:
4951     __DEEP{
4952     $r = $self-><AG::DISAnyResource.typeResource>
4953     -><M::DISAnyResource.getSuperResourceURIList>;
4954     }__;
4955    
4956     @@Test:
4957     @@@QName: DISAnyResource.getTypeURIList.test
4958     @@@PerlDef:
4959     my $db;
4960     __CODE{createDISDBForTest:: $db => $db}__;
4961    
4962     $test->id ('module');
4963     my $mod1 = $db-><M::DISDatabase.getModule> ('about:module1');
4964     my %lm1 = map {$_ => true} @{$mod1-><M::DISAnyResource.getTypeURIList>};
4965    
4966     $test->assert_true ($lm1{<Q::DISCore|Module>});
4967     $test->assert_true ($lm1{<Q::DISCore|AnyResource>});
4968    
4969     $test->id ('for');
4970     my $for1 = $db-><M::DISDatabase.getFor> ('about:for1');
4971     my %lf1 = map {$_ => true} @{$for1-><M::DISAnyResource.getTypeURIList>};
4972    
4973     $test->assert_true ($lf1{<Q::DISCore|For>});
4974     $test->assert_true ($lf1{<Q::DISCore|AnyResource>});
4975    
4976     @@Test:
4977     @@@QName: DISAnyResource.resource.getTypeURIList.test
4978     @@@PerlDef:
4979     my $db;
4980     __CODE{createDISDBForTest:: $db => $db}__;
4981    
4982     $test->id ('resource');
4983     my $res1 = $db-><M::DISDatabase.getResource> ('about:resource1');
4984     my %lr1 = map {$_ => true} @{$res1-><M::DISAnyResource.getTypeURIList>};
4985    
4986     $test->assert_true ($lr1{<Q::DISCore|Resource>});
4987     $test->assert_true ($lr1{<Q::DISCore|AnyResource>});
4988    
4989     @Method:
4990     @@ForCheck: ManakaiDOM|ForIF
4991     @@Name: getSuperResourceURIList
4992     @@enDesc:
4993     Returns a snapshot list of super-resources URIs of the resource,
4994     including canonical and alias URIs of the resource itself.
4995     @@Return:
4996     @@@Type: URIList
4997     @@@enDesc:
4998     A snapshot list of URIs.
4999    
5000     @Attr:
5001     @@Name: typeResource
5002     @@enDesc:
5003     The most specific type of the resource.
5004     @@Type: DISResource
5005     @@Get:
5006     @@@PerlDef:
5007     __DEEP{
5008     $r = $self-><AG::DISAnyResource.database>
5009     -><M::DISDatabase.getResource> ($self->{<H::DIS|typeURI>});
5010     }__;
5011    
5012     @Method:
5013     @@Name: addTypeURI
5014     @@enDesc:
5015     Adds a URI to the list of types of the resource.
5016     @@Param:
5017     @@@Name: uri
5018     @@@Type: AnyResourceURI
5019     @@@enDesc:
5020     A URI to add.
5021 wakaba 1.93 @@NamedParam:
5022     @@@Name: srinfo
5023 wakaba 1.110 @@@Type: DISPerl|HASH
5024 wakaba 1.93 @@@enDesc:
5025     A hash returned by <M::DISDatabase.unloadModule>, to
5026     restore super-resource relationship.
5027     @@@nullCase:
5028     @@@@enDesc:
5029     If it is not the updating.
5030 wakaba 1.79 @@Return:
5031     @@@PerlDef:
5032     __DEEP{
5033     my $current_type = $self-><AG::DISAnyResource.typeResource>;
5034 wakaba 1.93 unless ($current_type-><M::DISResource.isSubsetOfURI>
5035     ($uri, srinfo => $srinfo)) {
5036 wakaba 1.79 my $db = $self-><AG::DISAnyResource.database>;
5037     my $res = $db-><M::DISDatabase.getResource> ($uri);
5038 wakaba 1.80 my $current_uri = $current_type-><AG::DISAnyResource.uri>;
5039 wakaba 1.93 if ($res-><M::DISResource.isSubsetOfURI>
5040     ($current_uri, srinfo => $srinfo)) {
5041 wakaba 1.80 $self->{<H::DIS|typeURI>} = $uri;
5042 wakaba 1.79 } else {
5043 wakaba 1.80 my $new_uri;
5044     __CODE{composeSubsetURI:: $input1 => $current_uri,
5045     $input2 => $uri,
5046     $output => $new_uri}__;
5047 wakaba 1.79 my $new_res = $db-><M::DISDatabase.getResource> ($new_uri);
5048 wakaba 1.80 unless ($new_res-><AG::DISAnyResource.isDefined>) {
5049     $new_res-><AS::DISAnyResource.isAnonymous> (true);
5050     $new_res-><AS::DISAnyResource.isDefined> (true);
5051 wakaba 1.93 $new_res-><M::DISResource.addSuperResource>
5052     ($current_type, srinfo => $srinfo);
5053     $new_res-><M::DISResource.addSuperResource>
5054     ($res, srinfo => $srinfo);
5055 wakaba 1.80 }
5056 wakaba 1.88 unless ($new_res-><AG::DISAnyResource.ownerModuleURIRef>) {
5057     $new_res-><AS::DISAnyResource.ownerModuleURIRef>
5058     ($res-><AG::DISAnyResource.ownerModuleURIRef>);
5059     }
5060 wakaba 1.79 $self->{<H::DIS|typeURI>} = $new_uri;
5061     }
5062     }
5063     }__;
5064    
5065     @@Test:
5066     @@@QName: DISAnyResource.addTypeURI.test
5067     @@@PerlDef:
5068     my $db;
5069     __CODE{createDISDBForTest:: $db => $db}__;
5070    
5071     my $res = $db-><M::DISDatabase.getResource> ('about:1');
5072     my $res2 = $db-><M::DISDatabase.getResource> ('about:2');
5073     $test->id ('initial.resource');
5074     $test->assert_true
5075     ($res-><M::DISAnyResource.isTypeURI> (<Q::DISCore|Resource>));
5076     $test->id ('initial.anyresource');
5077     $test->assert_true
5078     ($res-><M::DISAnyResource.isTypeURI>
5079     (<Q::DISCore|AnyResource>));
5080     $test->id ('initial.type1');
5081     $test->assert_false
5082     ($res-><M::DISAnyResource.isTypeURI> ('about:type1'));
5083    
5084     $res-><M::DISAnyResource.addTypeURI> ('about:type1');
5085    
5086     $test->id ('added.resource');
5087     $test->assert_true
5088     ($res-><M::DISAnyResource.isTypeURI> (<Q::DISCore|Resource>));
5089     $test->id ('added.anyresource');
5090     $test->assert_true
5091     ($res-><M::DISAnyResource.isTypeURI>
5092     (<Q::DISCore|AnyResource>));
5093     $test->id ('added.type1');
5094     $test->assert_true
5095     ($res-><M::DISAnyResource.isTypeURI> ('about:type1'));
5096    
5097     $test->id ('added2.resource');
5098     $test->assert_true
5099     ($res2-><M::DISAnyResource.isTypeURI>
5100     (<Q::DISCore|Resource>));
5101     $test->id ('added2.anyresource');
5102     $test->assert_true
5103     ($res2-><M::DISAnyResource.isTypeURI>
5104     (<Q::DISCore|AnyResource>));
5105     $test->id ('added2.type1');
5106     $test->assert_false
5107     ($res2-><M::DISAnyResource.isTypeURI> ('about:type1'));
5108 wakaba 1.81
5109     @CODE:
5110     @@QName: getMethodForType
5111     @@enDesc:
5112     Returns a method for a particular resource type.
5113    
5114 wakaba 1.95 In: <Perl::$type_resource>, <Perl::$method_name>
5115 wakaba 1.81
5116     Out: <Perl::$method>
5117     @@PerlDef:
5118 wakaba 1.95 my $__type_uri = $type_resource-><AG::DISAnyResource.uri>;
5119 wakaba 1.81 $method = $Message::Util::DIS::Method{$__type_uri}->{$method_name};
5120     unless ($method) {
5121     my %__methods;
5122 wakaba 1.95 for (@{$type_resource-><M::DISAnyResource.getSuperResourceURIList>}) {
5123 wakaba 1.81 $__methods{$_} = $Message::Util::DIS::Method{$_}->{$method_name}
5124     if $Message::Util::DIS::Method{$_}->{$method_name};
5125     }
5126 wakaba 1.95 my $__db = $type_resource-><AG::DISAnyResource.database>;
5127 wakaba 1.81 T1: for my $__t1_uri (keys %__methods) {
5128 wakaba 1.82 next T1 unless $__methods{$__t1_uri};
5129 wakaba 1.81 my $__t1 = $__db-><M::DISDatabase.getResource> ($__t1_uri);
5130     T2: for my $__t2_uri (keys %__methods) {
5131     next T2 if $__t1_uri eq $__t2_uri;
5132     if ($__t1-><M::DISResource.isSubsetOfURI> ($__t2_uri)) {
5133     delete $__methods{$__t2_uri};
5134 wakaba 1.82 next T2;
5135 wakaba 1.81 }
5136     if ($Message::Util::DIS::Method{$__t1_uri}->{$method_name}
5137     eq $Message::Util::DIS::Method{$__t2_uri}->{$method_name}) {
5138     delete $__methods{$__t2_uri};
5139 wakaba 1.82 next T2;
5140 wakaba 1.81 }
5141     }
5142     }
5143     if (keys %__methods > 1) {
5144     __c|ERROR{DIS|more-than-one-methods-for-a-type::
5145     DIS|uri => {$__type_uri},
5146     DIS|method-name => {$method_name},
5147     DIS|method-resource-types => {[keys %__methods]},
5148     }__;
5149     }
5150     $Message::Util::DIS::Method{$__type_uri}->{$method_name} =
5151     $method = $__methods{[keys %__methods]->[0]} if %__methods;
5152     }
5153    
5154     @IntMethod:
5155     @@Operator: ManakaiDOM|MUErrorHandler
5156     @@enDesc:
5157 wakaba 1.110 When a <IF::ecore|ErrorInterface> is <Perl::report>ed
5158 wakaba 1.81 with an <Perl::-object> of <IF::Node>, then this method is invoked.
5159    
5160     The method calls the <cfg::error-handler> if the error is of
5161     <IF::c|DOMError>. Otherwise, including the cases of <IF::c|DOMException>s,
5162     the error is rethrown so that appropriate <Perl::catch> clause
5163     can catch the error.
5164     @@Param:
5165     @@@Name: err
5166 wakaba 1.110 @@@Type: ecore|ErrorInterface
5167 wakaba 1.81 @@@enDesc:
5168     The reported error object.
5169     @@Return:
5170 wakaba 1.110 @@@Type: DISPerl|Any
5171 wakaba 1.81 @@@enDesc:
5172     If the <P::err> is a <IF::c|DOMError>, then the return value
5173     of the error handler.
5174    
5175     {NOTE:: If the error is thrown, the method never returns.
5176     }
5177     @@@nullCase:
5178     @@@@enDesc:
5179     No error handler.
5180     @@@PerlDef:
5181 wakaba 1.108 if ($err->isa (<IFName::c|DOMError>)) {
5182 wakaba 1.81 __DEEP{
5183     my $cfg = $self-><AG::DISAnyResource.database>
5184     -><AG::DISDatabase.domConfig>;
5185     my $h = $cfg-><M::DOMConfig.getParameter> ('error-handler');
5186 wakaba 1.110 $r = $h-><M::DOMCore|DOMErrorHandler.handleError> ($err);
5187 wakaba 1.81 }__;
5188     } else {
5189 wakaba 1.110 $err-><M::ecore|ErrorInterface.throw>;
5190 wakaba 1.81 }
5191 wakaba 1.84
5192     @Method:
5193     @@Name: getErrorInterfaceResource
5194     @@enDesc:
5195     Returns the <Q::ecore|ErrorInterface> resource
5196     to which the resource belongs.
5197     @@Return:
5198     @@@Type: DISAnyResource
5199     @@@enDesc:
5200     The interface resource.
5201     @@@nullCase:
5202     @@@@enDesc:
5203     If no resource found.
5204     @@@PerlDef:
5205     my $method;
5206 wakaba 1.95 my $tr = $self-><AG::DISAnyResource.typeResource>;
5207 wakaba 1.84 __CODE{DIS|getMethodForType::
5208 wakaba 1.95 $type_resource => $tr,
5209 wakaba 1.84 $method_name => 'get_error_interface_resource',
5210     $method => $method,
5211     }__;
5212     if ($method) {
5213     __DEEP{
5214     $r = $method->(@_);
5215     }__;
5216     } else {
5217     $r = null;
5218     }
5219    
5220     @Method:
5221     @@Name: getErrorCodeResource
5222     @@enDesc:
5223     Returns the <Q::dx|ErrorCode> resource
5224     to which the resource belongs.
5225     @@Return:
5226     @@@Type: DISAnyResource
5227     @@@enDesc:
5228     The interface resource.
5229     @@@nullCase:
5230     @@@@enDesc:
5231     If no resource found.
5232     @@@PerlDef:
5233     my $method;
5234 wakaba 1.95 my $tr = $self-><AG::DISAnyResource.typeResource>;
5235 wakaba 1.84 __CODE{DIS|getMethodForType::
5236 wakaba 1.95 $type_resource => $tr,
5237 wakaba 1.84 $method_name => 'get_error_code_resource',
5238     $method => $method,
5239     }__;
5240     if ($method) {
5241     __DEEP{
5242     $r = $method->(@_);
5243     }__;
5244     } else {
5245     $r = null;
5246     }
5247 wakaba 1.95
5248     @Method:
5249     @@Name: getDOMConfigurationParameterName
5250     @@enDesc:
5251     Returns the name of the DOM configuration parameter represented
5252     by the resource.
5253     @@Return:
5254     @@@Type: DISString
5255     @@@enDesc:
5256     The name.
5257     @@@nullCase:
5258     @@@@enDesc:
5259     If it is not a DOM configuration parameter or
5260     if it is an invalid configuration parameter and
5261     it has no name.
5262     @@@PerlDef:
5263     my $method;
5264     my $tr = $self-><AG::DISAnyResource.typeResource>;
5265     __CODE{DIS|getMethodForType::
5266     $type_resource => $tr,
5267     $method_name => 'get_dom_configuration_parameter_name',
5268     $method => $method,
5269     }__;
5270     if ($method) {
5271     __DEEP{
5272     $r = $method->(@_);
5273     }__;
5274     } else {
5275     $r = null;
5276     }
5277 wakaba 1.99
5278     @Method:
5279     @@Name: getNodeFromStorage
5280     @@enDesc:
5281     Returns a <IF::Node> from the storage associated
5282     to the resource.
5283     @@Param:
5284     @@@Name: key
5285     @@@Type: DISString
5286     @@@enDesc:
5287     A DOM URI that identifies the kind of the node.
5288     @@Param:
5289     @@@Name: hash
5290     @@@Type: DISString
5291     @@@enDesc:
5292     A short string that identifies the content of the node
5293     to retrieve. If it does not match to the one associated
5294     to the node in the storage, no node is returned.
5295     @@Param:
5296     @@@Name: factory
5297     @@@Type: Document
5298     @@@enDesc:
5299     The document to which the retrieved node belongs.
5300     @@Return:
5301     @@@Type: Node
5302     @@@enDesc:
5303     The retrieved node.
5304     @@@nullCase:
5305     @@@@enDesc:
5306     If no node is found.
5307     @@@PerlDef:
5308     require Message::DOM::TreeStore;
5309     my $mod = $self-><AG::DISAnyResource.ownerModule>;
5310     $mod-><M::dp|DISModulePerl.plLoadNodeStorage>
5311     unless defined $mod->{<H::DIS|nodeStorage>};
5312     my $st = $mod->{<H::DIS|nodeStorage>};
5313     if (defined $st->{$key} and $st->{$key}->[1] eq $hash) {
5314     $r = $factory->implementation
5315     ->get_feature (<Q::fe|TreeStore>)
5316     ->create_node_from_storable_object
5317     ($st->{$key}->[0], $factory);
5318     }
5319    
5320     @Method:
5321     @@Name: setNodeToStorage
5322     @@enDesc:
5323     Saves a copy of the <IF::Node> to the storage. Exactly
5324     when the physical storage is updated is implementation dependent.
5325     @@Param:
5326     @@@Name: key
5327     @@@Type: DISString
5328     @@@enDesc:
5329     A DOM URI that identifies the kind of the node.
5330     @@Param:
5331     @@@Name: hash
5332     @@@Type: DISString
5333     @@@enDesc:
5334     A short string that identifies the content of the node.
5335     If the <P::node> parameter is set to <DOM::null>,
5336     this value is ignored.
5337     @@Param:
5338     @@@Name: node
5339     @@@Type: Node
5340     @@@enDesc:
5341     The node to store. If there is already a node
5342     with the <P::key>, it is discarded.
5343     @@@nullCase:
5344     @@@@enDesc:
5345     The stored node, if any, is removed from the storage.
5346     @@Return:
5347     @@@PerlDef:
5348     require Message::DOM::TreeStore;
5349     my $mod = $self-><AG::DISAnyResource.ownerModule>;
5350     $mod-><M::dp|DISModulePerl.plLoadNodeStorage>
5351     unless defined $mod->{<H::DIS|nodeStorage>};
5352     my $st = $mod->{<H::DIS|nodeStorage>};
5353     if (defined $node) {
5354     $st->{$key}->[0] = [$node->owner_document
5355     ->implementation
5356     ->get_feature (<Q::fe|TreeStore>)
5357     ->create_storable_object_from_node
5358     ($node), $hash];
5359     } else {
5360     delete $st->{$key};
5361     }
5362     $mod->{<H::DIS|nodeStorageModified>} = true;
5363 wakaba 1.101
5364     @Method:
5365     @@Name: parseString
5366     @@enDesc:
5367     Parses a string assuming that this resource is a <Q::DISCore|LexicalType>.
5368     @@Param:
5369     @@@Name: s
5370     @@@Type: DISString
5371     @@@enDesc:
5372     The string to parse.
5373     @@Param:
5374     @@@Name: ns
5375     @@@Type: NSResolverDIS
5376     @@@enDesc:
5377     The namespace context object.
5378     @@Param:
5379     @@@Name: factory
5380     @@@Type: Document
5381     @@@enDesc:
5382     The <IF::Document> node to which the returned <IF::Node> belongs.
5383 wakaba 1.102 @@ForParam:
5384 wakaba 1.101 @@Return:
5385     @@@Type: Node
5386     @@@enDesc:
5387     The <IF::Node> object obtained as a result of parsing
5388     of <P::s> in the context of <P::ns>.
5389     @@@nullCase:
5390     @@@@enDesc:
5391     If this resource is not a <Q::DISCore|LexicalType>
5392     or if no parser is found.
5393     @@@PerlDef:
5394     my $method;
5395     __CODE{DIS|getMethodForType::
5396     $type_resource => $self,
5397     $method_name => 'parse_string',
5398     $method => $method,
5399     }__;
5400     if ($method) {
5401     __DEEP{
5402     $r = $method->(@_);
5403     }__;
5404     } else {
5405     $r = null;
5406     }
5407 wakaba 1.48 ##DISAnyResource
5408 wakaba 1.99
5409     PropDef:
5410     @QName: DIS|nodeStorage
5411     @DIS:key: nst
5412    
5413     PropDef:
5414     @QName: DIS|nodeStorageModified
5415     @DIS:key: nstmod
5416    
5417     ResourceDef:
5418     @QName: Node
5419 wakaba 1.110 @AliasFor: tc|Node
5420 wakaba 1.99
5421     ResourceDef:
5422     @QName: Document
5423 wakaba 1.110 @AliasFor: td|Document
5424 wakaba 1.101
5425     ResourceDef:
5426     @QName: Element
5427 wakaba 1.110 @AliasFor: te|Element
5428 wakaba 1.48
5429 wakaba 1.81 ResourceDef:
5430     @QName: DOMConfig
5431 wakaba 1.110 @AliasFor: DOMCore|DOMConfiguration
5432 wakaba 1.81
5433     ErrDef:
5434     @QName: DIS|more-than-one-methods-for-a-type
5435     @enDesc:
5436     If more than one different method implementations are defined
5437     for a resource type.
5438     @enMufDef:
5439     Method |%p (name => {<Q::DIS|method-name>});| for
5440     resource <%p (name => {<Q::DIS|uri>});> has multiple definitions
5441 wakaba 1.110 @c:severity: DOMCore|SEVERITY_WARNING
5442 wakaba 1.81 @ecore:hasParameter:
5443     @@@: DIS|uri
5444     @@enDesc:
5445     A URI of the type.
5446     @ecore:hasParameter:
5447     @@@: DIS|method-name
5448     @@enDesc:
5449     The name of the method.
5450     @ecore:hasParameter:
5451     @@@: DIS|method-resource-types
5452     @@enDesc:
5453     The snapshot list of types for which methods are defined.
5454    
5455     XParamDef:
5456 wakaba 1.88 @QName: DIS|fileName
5457     @enDesc:
5458     The name of the file.
5459    
5460     XParamDef:
5461 wakaba 1.81 @QName: DIS|method-name
5462     @enDesc:
5463     The name of the method in question.
5464    
5465     XParamDef:
5466     @QName: DIS|method-resource-types
5467     @enDesc:
5468     The snapshot list of types for which methods are defined.
5469    
5470 wakaba 1.87 XParamDef:
5471     @QName: DIS|forURI
5472    
5473 wakaba 1.81 ElementTypeBinding:
5474     @Name: ErrDef
5475     @ElementType:
5476     dis:ResourceDef
5477     @ShadowContent:
5478     @@DISCore:resourceType: DOMCore|DOMErrorType
5479 wakaba 1.110 @@ecore:textFormatter: ecore|MUErrorFormatter
5480 wakaba 1.81
5481 wakaba 1.79 URITypeDef:
5482     @QName: AnyResourceURI
5483     @enDesc:
5484     A URI that identifies a <Q::DISCore|AnyResource>.
5485    
5486     DataTypeDef:
5487     @QName: AnyResourceURIList
5488     @enDesc:
5489     A snapshot list of URIs that identify <Q::DISCore|AnyResource>s.
5490     @rdfs:subClassOf: DISPerl|ARRAY
5491    
5492     PropDef:
5493     @QName: DIS|typeURI
5494     @enDesc:
5495     The URI of the most specific type of the resource.
5496     @DIS:key: tu
5497    
5498 wakaba 1.48 IFClsDef:
5499     @IFQName: DISModule
5500     @ClsQName: ManakaiDISModuleDefinition
5501    
5502     @ClsISA: ManakaiDISPropertyAccessor
5503     @ClsISA: ManakaiDISPerlModuleDefinition
5504     @ClsISA: dp|ManakaiDISModulePerl
5505     @ClsISA: dp|ManakaiDISAnyResourcePerl
5506     @ClsISA: ManakaiDISAnyResource
5507    
5508     @enDesc:
5509     <QUOTE::dis> module definitions.
5510    
5511     @enDesc:
5512     @@ForCheck: ManakaiDOM|ForIF
5513     @@@:
5514     The objects implementing the <IF::DISModule> interface <kwd:MUST>
5515     also implement the <IF::DISAnyResource> interface.
5516    
5517     @Attr:
5518     @@ForCheck: ManakaiDOM|ForClass
5519     @@Name: uris
5520     @@Type:
5521 wakaba 1.110 DISPerl:Array
5522 wakaba 1.7 @@enDesc:
5523 wakaba 1.48 A reference to the snapshot array containing the URI reference
5524     of the module.
5525     @@Get:
5526 wakaba 1.7 @@@PerlDef:
5527 wakaba 1.48 $r = [$self->{uri}];
5528 wakaba 1.8
5529     @Attr:
5530 wakaba 1.48 @@ForCheck: ManakaiDOM|ForClass
5531     @@Name: ownerModule
5532     @@ManakaiDOM:isRedefining:1
5533 wakaba 1.8 @@enDesc:
5534 wakaba 1.48 This module itself.
5535     @@Get:
5536     @@@Type: DISModule
5537     @@@clsActualType: ManakaiDISModuleDefinition
5538     @@@nullCase:
5539     @@@@enDesc:
5540     The resource is not part of any module since
5541     its definition is not read (<IF::DISModule.isDefined> is <DOM::false>).
5542     @@@PerlDef: $r = $self;
5543    
5544     @Method:
5545 wakaba 1.55 @@Name: addResourceList
5546     @@enDesc:
5547     Adds a resource to the list of resources belongs to the module.
5548     @@Param:
5549     @@@Name: disResource
5550     @@@Type: DIS|DISResource
5551     @@@enDesc: The resource to add.
5552     @@Return:
5553     @@@PerlDef:
5554     __DEEP{
5555     push @{$self->{<H::DIS|resource>}||=[]},
5556 wakaba 1.85 map {\$_} @{$disResource-><AG::DIS|DISAnyResource.uris>};
5557 wakaba 1.55 }__;
5558 wakaba 1.86
5559     @Method:
5560     @@Name: addResourceURI
5561     @@enDesc:
5562     Adds a resource URI to the list of resources belongs to the module.
5563     @@Param:
5564     @@@Name: uri
5565     @@@Type: DISString
5566     @@@enDesc:
5567     The URI to add.
5568     @@Return:
5569     @@@PerlDef:
5570     push @{$self->{<H::DIS|resource>}||=[]}, \$uri;
5571    
5572     @Method:
5573     @@Name: getResourceURIList
5574     @@enDesc:
5575     Returns the list of URIs of resources belongs to the module.
5576     @@Return:
5577     @@@Type: AnyResourceURIList
5578     @@@enDesc:
5579     The snapshot list of URIs.
5580     @@@PerlDef:
5581     $r = [map {$$_} @{$self->{<H::DIS|resource>} or []}];
5582 wakaba 1.55
5583     @Method:
5584     @@Name: getResourceList
5585     @@enDesc:
5586     Returns the list of resources belongs to the module.
5587     @@Return:
5588     @@@Type: DIS|ResourceList
5589     @@@enDesc:
5590     The current snapshot of children.
5591     @@@PerlDef:
5592     __DEEP{
5593     my $db = $self-><AG::DIS|DISAnyResource.database>;
5594     $r = [map {
5595     $db-><M::DIS|DISDatabase.getResource> ($$_)
5596     } @{$self->{<H::DIS|resource>}}];
5597     }__;
5598 wakaba 1.57
5599 wakaba 1.85 @Method:
5600     @@Name: addForResource
5601     @@enDesc:
5602     Adds a <QUOTE::for> resource to the list of <QUOTE::for>
5603     resources belongs to the module.
5604     @@Param:
5605     @@@Name: disResource
5606     @@@Type: DISFor
5607     @@@enDesc: The resource to add.
5608     @@Return:
5609     @@@PerlDef:
5610     __DEEP{
5611     push @{$self->{<H::DIS|forList>}||=[]},
5612     $disResource-><AG::DISAnyResource.uriRef>;
5613     }__;
5614    
5615     @Method:
5616     @@Name: getForResourceList
5617     @@enDesc:
5618     Returns the list of <QUOTE::for> resources belongs to the module.
5619     @@Return:
5620     @@@Type: ResourceList
5621     @@@enDesc:
5622     The current snapshot list of <QUOTE::for> resources,
5623     which may or may not contains dupulications.
5624     @@@PerlDef:
5625     __DEEP{
5626     my $db = $self-><AG::DIS|DISAnyResource.database>;
5627     $r = [map {
5628     $db-><M::DIS|DISDatabase.getFor> ($$_)
5629     } @{$self->{<H::DIS|forList>}}];
5630     }__;
5631    
5632 wakaba 1.57 @Attr:
5633     @@Name: targetNamespaceURI
5634     @@enDesc:
5635     The default namespace URI of the resources defined in the module.
5636     @@Type: DIS|AnyURI
5637     @@Get:
5638     @@@PerlDef:
5639     $r = defined $self->{<H::DIS|defaultNamespaceURI>}
5640     ? ${$self->{<H::DIS|defaultNamespaceURI>}} : null;
5641     @@Set:
5642     @@@ForCheck: ManakaiDOM|ForClass
5643     @@@PerlDef:
5644     if (defined $given) {
5645     $self->{<H::DIS|defaultNamespaceURI>} = \$given;
5646     } else {
5647     CORE::delete $self->{<H::DIS|defaultNamespaceURI>};
5648     }
5649 wakaba 1.61
5650 wakaba 1.79 @CMethod:
5651     @@Name: getSuperResourceURIList
5652 wakaba 1.61 @@enDesc:
5653 wakaba 1.79 Returns a snapshot list of super-resources URIs of the resource,
5654     including canonical and alias URIs of the resource itself.
5655     @@Return:
5656     @@@Type: URIList
5657 wakaba 1.61 @@@enDesc:
5658 wakaba 1.79 A snapshot list of URIs.
5659     @@@PerlDef:
5660     $r = [$self->{uri}];
5661    
5662     @@Test:
5663     @@@QName: DISModule.getSuperResourceURIList.test
5664 wakaba 1.61 @@@PerlDef:
5665 wakaba 1.79 my $db;
5666     __CODE{createDISDBForTest:: $db => $db}__;
5667    
5668     my $res = $db-><M::DISDatabase.getModule> ('about:1');
5669    
5670     my %list = map {$_ => true} @{$res-><M::DISAnyResource
5671     .getSuperResourceURIList>};
5672    
5673     $test->assert_true ($list{'about:1'});
5674     $test->assert_false ($list{'about:2'});
5675 wakaba 1.87
5676     @Method:
5677     @@Name: getReferringModuleURIList
5678     @@enDesc:
5679     Reurns a snapshot list of the name URIs of modules referenced
5680     from the module.
5681     @@Return:
5682     @@@Type: URIList
5683     @@@enDesc:
5684     The snapshot list of URIs.
5685     @@@PerlDef:
5686     $r = [grep {$self->{<H::DIS|referringModule>}->{$_}}
5687     keys %{$self->{<H::DIS|referringModule>} or {}}];
5688    
5689     @Method:
5690     @@Name: addReferringModuleURI
5691     @@enDesc:
5692     Adds a URI to the list of modules referenced from the module.
5693     @@Param:
5694     @@@Name: uri
5695     @@@Type: DISString
5696     @@@enDesc:
5697     The URI to add.
5698     @@Return:
5699     @@@PerlDef:
5700     $self->{<H::DIS|referringModule>}->{$uri} = true;
5701 wakaba 1.48 ##DISModule
5702 wakaba 1.87
5703     PropDef:
5704     @QName: DIS|referringModule
5705     @DIS:key: ref
5706 wakaba 1.55
5707 wakaba 1.85 PropDef:
5708     @QName: DIS|forList
5709     @enDesc:
5710     A list of references to URIs of <QUOTE::for> resources
5711     belongs to the module.
5712    
5713 wakaba 1.55 ClsDef:
5714     @ClsQName: ManakaiDISModuleLite
5715    
5716     @Implement: DIS|DISResourceProp
5717     @Implement: dp|DISAnyResourcePerl
5718     @Implement: dp|DISModulePerl
5719     @Implement: dp|DISResourcePerlModule
5720    
5721     @enDesc:
5722     The <Class::ManakaiDISModuleLite> class provides very small
5723     subset of <Class::ManakaiDISModuleDefinition> class. If a
5724     method or attribute which is not implemented by the class, then
5725     the object is updated to the <Class::ManakaiDISModuleDefinition>
5726     by reading additional properties from the <QUOTE::dis> database.
5727    
5728     @Attr:
5729 wakaba 1.88 @@Name: uri
5730     @@Type: AnyURI
5731     @@Description:
5732     @@@lang:en
5733     @@@@:
5734     The URI reference of the resource.
5735     @@Get:
5736     @@@enDesc:
5737     The representive URI reference of the resource.
5738    
5739     {NOTE:: The URI might be non-persistent if the
5740     resource is not assigned a URI in <QUOTE::dis> source file,
5741     in which case a URI is randomly-generated at the
5742     time of object generation.
5743     }
5744     @@@PerlDef:
5745     $r = $self->{uri};
5746    
5747     @Attr:
5748     @@Name: uriRef
5749 wakaba 1.110 @@Type: DISPerl|SCALAR
5750 wakaba 1.88 @@enDesc:
5751     A reference to the URI of the resource.
5752    
5753     {NOTE:: Applications <kwd:MUST-NOT> modify the referenced
5754     value directly.
5755     }
5756     @@Get:
5757     @@@PerlDef: $r = \ ($self->{uri});
5758    
5759     @Attr:
5760 wakaba 1.55 @@ForCheck: ManakaiDOM|ForClass
5761     @@Name: uris
5762     @@Type:
5763 wakaba 1.110 DISPerl:Array
5764 wakaba 1.55 @@enDesc:
5765     A reference to the snapshot array containing the URI reference
5766     of the module.
5767     @@Get:
5768     @@@PerlDef:
5769     $r = [$self->{uri}];
5770    
5771 wakaba 1.88 @Method:
5772     @@Name: isSameResource
5773     @@Operator:
5774     @@@@:eq
5775     @@@ContentType:
5776     lang:Perl
5777     @@enDesc:
5778     Whether two resources are same or not. Two resources are
5779     same if and only if their <A::DISAnyResource.uri> are
5780     equivalent as strings (i.e. in character-by-character based matching).
5781     @@Param:
5782     @@@Name: anotherResource
5783     @@@Type: DISAnyResource
5784     @@@enDesc:
5785     Another resource object to compare.
5786     @@Return:
5787     @@@Type:
5788 wakaba 1.110 DOMMain:boolean
5789 wakaba 1.88 @@@enDesc:
5790     Whether two resources are same or not.
5791     @@@TrueCase:
5792     @@@@enDesc: Two resources are same.
5793     @@@FalseCase:
5794     @@@@enDesc: Two resources are different.
5795     @@@PerlDef:
5796     if (UNIVERSAL::isa ($anotherResource,
5797     <ClassName::ManakaiDISAnyResource>)) {
5798     $r = $self->{uri} eq $anotherResource->{uri};
5799     }
5800    
5801     @Attr:
5802     @@Name: nameURI
5803     @@Type: NameURI
5804     @@enDesc:
5805     The URI reference of this module, without
5806     <QUOTE::for> identifier.
5807     @@Get:
5808     @@@enDesc:
5809     The name URI of the resource.
5810     @@@nullCase:
5811     @@@@enDesc:
5812     The resource has no name URI.
5813    
5814     {NOTE:: A resource has no URI if and only if the resource
5815     has no local name.
5816     }
5817     @@@PerlDef:
5818     if (defined $self->{localName}) {
5819     $r = defined $self->{namespaceURI}
5820     ? ${$self->{namespaceURI}} . ${$self->{localName}}
5821     : ${$self->{localName}};
5822     }
5823    
5824     @Attr:
5825     @@Name: localName
5826     @@enDesc:
5827     The local name of this module.
5828    
5829     {NOTE:: <QUOTE::for> resources has no local name.
5830     }
5831     @@Type:
5832 wakaba 1.110 DISCore:LocalName
5833 wakaba 1.88 @@Get:
5834     @@@PerlDef:
5835     $r = defined $self->{localName} ? ${$self->{localName}} : null;
5836    
5837     @Attr:
5838     @@Name: namespaceURI
5839     @@Type: AnyURI
5840     @@enDesc:
5841     The namespace URI of the name of this resource.
5842    
5843     {NOTE:: <QUOTE::for> resources has no namespace URI.
5844     }
5845     @@Get:
5846     @@@PerlDef:
5847     $r = defined $self->{namespaceURI} ? ${$self->{namespaceURI}} : null;
5848    
5849     @Attr:
5850     @@Name: forURI
5851     @@Type: ForURI
5852     @@enDesc:
5853     The <QUOTE::for> URI reference for which this module is defined.
5854     @@Get:
5855     @@@PerlDef:
5856     $r = defined $self->{for} ? ${$self->{for}} : null;
5857    
5858     @Attr:
5859     @@Name: forpURI
5860     @@enDesc:
5861     The <QUOTE::for+> URI references for which this resource is defined.
5862    
5863     {NOTE:: <QUOTE::for> resources has no <QUOTE::for+> URI.
5864     }
5865     @@Type: ForURIList
5866     @@Get:
5867     @@@enDesc:
5868     List of <QUOTE::for> URI references. Note that this list is
5869     <QUOTE::dead>.
5870     @@@PerlDef:
5871     $r = [@{$self->{forp}}];
5872    
5873     @Method:
5874     @@Name: isForURI
5875     @@enDesc:
5876     Tests whether this resource is defined for a <QUOTE::for>
5877     or <QUOTE::for+> URI reference or not.
5878     @@Param:
5879     @@@Name:forURI
5880     @@@Type:ForURI
5881     @@@enDesc:
5882     A <QUOTE::for> URI reference to test.
5883     @@Return:
5884     @@@Type:
5885 wakaba 1.110 DOMMain:boolean
5886 wakaba 1.88 @@@TrueCase:
5887     @@@@enDesc:
5888     This resource is for <P::forURI>.
5889     @@@FalseCase:
5890     @@@@enDesc:
5891     This resource is not for <P::forURI>.
5892     @@@PerlDef:
5893     __DEEP{
5894     C: for my $this_for_uri (${$self->{for}||\''}, @{$self->{forp}||[]}) {
5895     if ($this_for_uri eq $forURI) { ## Shortcut
5896     $r = true;
5897     last C;
5898     }
5899 wakaba 1.98 my $this_for = $self-><AG::DISAnyResource.database>
5900     -><M::DIS|DISDatabase.getFor>
5901 wakaba 1.88 ($this_for_uri);
5902     if ($this_for-><M::DIS|DISFor.isaURI> ($forURI)) {
5903     $r = true;
5904     last C;
5905     }
5906     }
5907     }__;
5908    
5909     @Attr:
5910     @@Name: isDefined
5911     @@Description:
5912     @@@lang:en
5913     @@@@:
5914     Whether this module is defined or not.
5915     @@Type:
5916 wakaba 1.110 DOMMain:boolean
5917 wakaba 1.88 @@Get:
5918     @@@PerlDef:
5919     $r = $self->{<H::DIS|isDefined>};
5920     @@Set:
5921     @@@PerlDef:
5922     $self->{<H::DIS|isDefined>} = $given;
5923    
5924 wakaba 1.55 @Attr:
5925     @@ForCheck: ManakaiDOM|ForClass
5926     @@Name: ownerModule
5927     @@ManakaiDOM:isRedefining:1
5928     @@enDesc:
5929     This module itself.
5930     @@Get:
5931     @@@Type: DISModule
5932     @@@clsActualType: ManakaiDISModuleDefinition
5933     @@@nullCase:
5934     @@@@enDesc:
5935     The resource is not part of any module since
5936     its definition is not read (<IF::DISModule.isDefined> is <DOM::false>).
5937     @@@PerlDef: $r = $self;
5938    
5939 wakaba 1.88 @Attr:
5940     @@Name: ownerModuleURI
5941     @@enDesc:
5942     A URI of the owner module of the resource.
5943     @@Type: DIS|AnyURI
5944     @@nullCase:
5945     @@@enDesc:
5946     The resource does not belong to any module since the
5947     resource definition is not read yet or since
5948     it is created in memory.
5949     @@Get:
5950     @@@PerlDef:
5951     $r = $self->{uri};
5952    
5953     @Attr:
5954     @@Name: ownerModuleURIRef
5955     @@enDesc:
5956     A reference to a URI of the owner module of the resource.
5957 wakaba 1.110 @@Type: DISPerl|SCALAR
5958 wakaba 1.88 @@nullCase:
5959     @@@enDesc:
5960     The resource does not belong to any module since the
5961     resource definition is not read yet or since
5962     it is created in memory.
5963     @@Get:
5964     @@@PerlDef:
5965     $r = \ ($self->{uri});
5966     @@Set:
5967     @@@PerlDef: # no effect
5968    
5969     @Attr:
5970     @@Name: database
5971     @@enDesc:
5972     The <QUOTE::dis> database to which the resource belongs.
5973     @@Type: DISDatabase
5974     @@clsActualType: ManakaiDISDatabase
5975     @@Get:
5976     @@@PerlDef:
5977     $r = $self->{db};
5978    
5979 wakaba 1.55 @Method:
5980     @@Operator:
5981     @@@@: AUTOLOAD
5982     @@@ContentType: lang|Perl
5983     @@Return:
5984     @@@PerlDef:
5985 wakaba 1.57 my $al = our $AUTOLOAD;
5986     $al =~ s/.+:://;
5987     if ($al ne 'DESTROY') {
5988    
5989 wakaba 1.55 __DEEP{
5990     $self-><AG::DIS|DISAnyResource.database>
5991     -><M::dp|ManakaiDISDatabasePerl.plLoadDISDatabaseModule> ($self);
5992     }__;
5993     if (ref $self eq <ClassName::ManakaiDISModuleLite>) {
5994     __EXCEPTION{DIS|RESOURCE_NOT_DEFINED_ERR::
5995     DIS:uri => {$self-><AG::DIS|DISAnyResource.uri>},
5996     DIS:moduleURI => {$self-><AG::DIS|DISAnyResource.uri>},
5997     }__;
5998     }
5999    
6000     my $code = $self->can ($al);
6001     if ($code) {
6002     goto &$code;
6003     } else {
6004     require Carp;
6005 wakaba 1.67 local $Carp::CarpLevel = $Error::Depth;
6006 wakaba 1.55 Carp::croak (qq<Can't locate method "$AUTOLOAD">);
6007     }
6008 wakaba 1.57
6009     } # $al
6010    
6011     @Attr:
6012     @@Name: targetNamespaceURI
6013     @@enDesc:
6014     The default namespace URI of the resources defined in the module.
6015     @@Type: DIS|AnyURI
6016     @@Get:
6017     @@@PerlDef:
6018     $r = defined $self->{<H::DIS|defaultNamespaceURI>}
6019     ? ${$self->{<H::DIS|defaultNamespaceURI>}} : null;
6020 wakaba 1.55 ##DISModuleLite
6021 wakaba 1.48
6022     IFClsDef:
6023     @IFQName: DISFor
6024     @ClsQName: ManakaiDISForDefinition
6025    
6026     @ClsISA: dp|ManakaiDISAnyResourcePerl
6027 wakaba 1.79 @ClsISA: ManakaiDISPropertyAccessor
6028 wakaba 1.48 @ClsISA: ManakaiDISAnyResource
6029    
6030     @Description:
6031     @@lang:en
6032     @@@:
6033     <QUOTE::dis> <QUOTE::for> definitions.
6034 wakaba 1.8
6035     @Attr:
6036 wakaba 1.48 @@ForCheck: ManakaiDOM|ForClass
6037     @@Name: uris
6038     @@Type:
6039 wakaba 1.110 DISPerl:Array
6040 wakaba 1.48 @@actualType: ForURIList
6041 wakaba 1.15 @@enDesc:
6042 wakaba 1.48 A reference to the snapshot array containing the URI reference
6043     of the <QUOTE::for>.
6044 wakaba 1.15 @@Get:
6045     @@@PerlDef:
6046 wakaba 1.48 $r = [$self->{uri}];
6047 wakaba 1.18
6048 wakaba 1.48 @Method:
6049     @@Name: isaURI
6050     @@Description:
6051     @@@lang:en
6052     @@@@:
6053     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
6054     @@Param:
6055     @@@Name: superURI
6056     @@@Type: ForURI
6057     @@@Description:
6058     @@@@lang:en
6059     @@@@@:
6060     Another <QUOTE::for> URI reference to test.
6061     @@Return:
6062     @@@Type:
6063 wakaba 1.110 DOMMain:boolean
6064 wakaba 1.48 @@@TrueCase:
6065     @@@@enDesc:
6066     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
6067     @@@FalseCase:
6068     @@@@enDesc:
6069     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
6070 wakaba 1.18 @@@PerlDef:
6071 wakaba 1.48 $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
6072 wakaba 1.15
6073 wakaba 1.48 @Method:
6074     @@Name: addISA
6075 wakaba 1.8 @@enDesc:
6076 wakaba 1.48 Adds a <QUOTE::for> to the list of super-<QUOTE::for> of this
6077     <QUOTE::for>.
6078     @@Param:
6079     @@@Name: superFor
6080     @@@Type: DISFor
6081     @@@clsActualType: ManakaiDISForDefinition
6082 wakaba 1.8 @@@enDesc:
6083 wakaba 1.48 A <QUOTE::for> definition object.
6084     @@Return:
6085 wakaba 1.8 @@@PerlDef:
6086 wakaba 1.48 my @from = ($self->{uri},
6087     grep {$self->{revISA}->{$_}} keys %{$self->{revISA}});
6088     my @to = ($superFor->{uri},
6089     grep {$superFor->{isa}->{$_}} keys %{$superFor->{isa}});
6090 wakaba 1.8 __DEEP{
6091 wakaba 1.48 for my $from (@from) {
6092     for my $to (@to) {
6093     $self->{db}-><M::ManakaiDISDatabase.getFor>
6094     ($from)->{isa}->{$to} = true;
6095     $self->{db}-><M::ManakaiDISDatabase.getFor>
6096     ($to)->{revISA}->{$from} = true;
6097 wakaba 1.8 }
6098     }
6099     }__;
6100    
6101     @Attr:
6102 wakaba 1.48 @@ForCheck: ManakaiDOM|ForClass
6103     @@Name: forURI
6104     @@Type: ForURI
6105 wakaba 1.8 @@enDesc:
6106 wakaba 1.48 The <QUOTE::for> URI reference for which this module is defined.
6107 wakaba 1.8 @@Get:
6108 wakaba 1.48 @@@InCase:
6109     @@@@Value:
6110     @@@@@@: ManakaiDOM|all
6111 wakaba 1.68 @@@@@ContentType: DISCore|QName
6112 wakaba 1.8 @@@@enDesc:
6113 wakaba 1.48 The attribute value is always <Q::ManakaiDOM|all> for a
6114     <QUOTE::for> resource.
6115 wakaba 1.8 @@@PerlDef:
6116 wakaba 1.48 $r = <Q::ManakaiDOM|all>;
6117 wakaba 1.8
6118     @Attr:
6119 wakaba 1.48 @@Name: forpURI
6120 wakaba 1.8 @@enDesc:
6121 wakaba 1.48 The <QUOTE::for+> URI references for which this resource is defined.
6122     @@Type: ForURIList
6123 wakaba 1.8 @@Get:
6124 wakaba 1.48 @@@enDesc:
6125     List of <QUOTE::for> URI references. Note that this list is
6126     <QUOTE::dead>.
6127     @@@InCase:
6128     @@@@Value:
6129     @@@@@@: []
6130     @@@@@ContentType: lang|Perl
6131 wakaba 1.8 @@@@enDesc:
6132 wakaba 1.48 The attribute value is always an empty array reference
6133     for a <QUOTE::for> resource.
6134     @@@PerlDef: $r = [];
6135 wakaba 1.9
6136 wakaba 1.48 @Method:
6137     @@Name: isForURI
6138 wakaba 1.9 @@enDesc:
6139 wakaba 1.48 Tests whether this resource is defined for a <QUOTE::for>
6140     or <QUOTE::for+> URI reference or not.
6141 wakaba 1.9 @@Param:
6142 wakaba 1.48 @@@Name:forURI
6143     @@@Type:ForURI
6144     @@@enDesc:
6145     A <QUOTE::for> URI reference to test.
6146 wakaba 1.9 @@Return:
6147     @@@Type:
6148 wakaba 1.110 DOMMain:boolean
6149 wakaba 1.48 @@@TrueCase:
6150     @@@@enDesc:
6151     This resource is for <P::forURI>. The attribute
6152     always takes this value for <QUOTE::for> resources.
6153     @@@PerlDef: $r = true;
6154 wakaba 1.12
6155     @Attr:
6156 wakaba 1.48 @@ForCheck: ManakaiDOM|ForClass
6157     @@Name: nameURI
6158     @@Type: NameURI
6159 wakaba 1.12 @@enDesc:
6160 wakaba 1.48 The URI reference of this module, without
6161     <QUOTE::for> identifier.
6162 wakaba 1.12 @@Get:
6163 wakaba 1.49 @@@enDesc:
6164     The attribute value is always equals to
6165     <A::DISAnyResource.uri> for <QUOTE::for> resources.
6166     @@@PerlDef: $r = $self->{uri};
6167 wakaba 1.61
6168 wakaba 1.79 @CMethod:
6169     @@Name: getSuperResourceURIList
6170 wakaba 1.61 @@enDesc:
6171 wakaba 1.79 Returns a snapshot list of super-resources URIs of the resource,
6172     including canonical and alias URIs of the resource itself.
6173     @@Return:
6174     @@@Type: URIList
6175 wakaba 1.61 @@@enDesc:
6176 wakaba 1.79 A snapshot list of URIs.
6177     @@@PerlDef:
6178     $r = [
6179     (grep {$self->{isa}->{$_}} keys %{$self->{isa}}),
6180     (grep {$self->{aliasURI}->{$_}} keys %{$self->{aliasURI}}),
6181     ($self->{uri}),
6182     ];
6183    
6184     @@Test:
6185     @@@QName: DISFor.getSuperResourceURIList.test
6186 wakaba 1.61 @@@PerlDef:
6187 wakaba 1.79 my $db;
6188     __CODE{createDISDBForTest:: $db => $db}__;
6189    
6190     my $res1 = $db-><M::DISDatabase.getFor> ('about:1');
6191    
6192     my %list1 = map {$_ => true} @{$res1-><M::DISAnyResource
6193     .getSuperResourceURIList>};
6194    
6195     $test->assert_true ($list1{'about:1'});
6196     $test->assert_false ($list1{'about:2'});
6197     $test->assert_true ($list1{<Q::ManakaiDOM:all>});
6198    
6199     my $res2 = $db-><M::DISDatabase.getFor> ('about:2');
6200     $res1-><M::DISFor.addISA> ($res2);
6201    
6202     my %list1_2 = map {$_ => true} @{$res1-><M::DISAnyResource
6203     .getSuperResourceURIList>};
6204    
6205     $test->assert_true ($list1_2{'about:1'});
6206     $test->assert_true ($list1_2{'about:2'});
6207     $test->assert_true ($list1_2{<Q::ManakaiDOM:all>});
6208    
6209     my %list2 = map {$_ => true} @{$res2-><M::DISAnyResource
6210     .getSuperResourceURIList>};
6211    
6212     $test->assert_false ($list2{'about:1'});
6213     $test->assert_true ($list2{'about:2'});
6214     $test->assert_true ($list2{<Q::ManakaiDOM:all>});
6215 wakaba 1.48 ##DISFor
6216 wakaba 1.18
6217 wakaba 1.48 IFClsDef:
6218     @IFQName: DISResource
6219     @ClsQName: ManakaiDISResourceDefinition
6220 wakaba 1.19
6221 wakaba 1.48 @ClsISA: ManakaiDISResourceMV
6222     @ClsISA: dp|ManakaiDISResourcePerl
6223     @ClsISA: ManakaiDISPerlModuleDefinition
6224     @ClsISA: dp|ManakaiDISAnyResourcePerl
6225     @ClsISA: ManakaiDISPropertyAccessor
6226     @ClsISA: ManakaiDISAnyResource
6227 wakaba 1.19
6228 wakaba 1.48 @enDesc:
6229     <QUOTE::dis> resource definitions.
6230 wakaba 1.19
6231 wakaba 1.48 @enDesc:
6232     @@ForCheck: ManakaiDOM|ForIF
6233     @@@:
6234     The objects implementing the <IF::DISResource> interface
6235     <kwd:MUST> also implement the <IF::DISAnyResource> interface.
6236 wakaba 1.12
6237 wakaba 1.46 @Attr:
6238 wakaba 1.48 @@ForCheck: ManakaiDOM|ForClass
6239     @@Name: uris
6240     @@Type:
6241 wakaba 1.110 DISPerl:Array
6242 wakaba 1.46 @@enDesc:
6243 wakaba 1.48 Returns the current <EM::snapshot> of the URI references
6244     for this resource, including the alias URI references.
6245 wakaba 1.46 @@Get:
6246     @@@PerlDef:
6247 wakaba 1.48 $r = [grep {$self->{aliasURI}->{$_}} keys %{$self->{aliasURI}}];
6248 wakaba 1.46
6249 wakaba 1.12 @Method:
6250 wakaba 1.48 @@Name: isSubsetOfURI
6251     @@Description:
6252 wakaba 1.37 @@@lang:en
6253     @@@@:
6254 wakaba 1.48 Whether this resource is a subset of another resource or not.
6255     @@Param:
6256     @@@Name: superURI
6257     @@@Type: ResourceURI
6258     @@@Description:
6259     @@@@lang:en
6260     @@@@@:
6261     Another resource URI reference to test.
6262 wakaba 1.89 @@NamedParam:
6263     @@@Name: srinfo
6264 wakaba 1.110 @@@Type: DISPerl|HASH
6265 wakaba 1.89 @@@enDesc:
6266     The <CODE::srinfo> hash.
6267     @@@nullCase:
6268     @@@@enDesc:
6269     No <CODE::srinfo>.
6270 wakaba 1.12 @@Return:
6271 wakaba 1.48 @@@Type:
6272 wakaba 1.110 DOMMain:boolean
6273 wakaba 1.48 @@@TrueCase:
6274     @@@@enDesc:
6275     <P::superURI> is a super-resource of this resource.
6276     @@@FalseCase:
6277 wakaba 1.12 @@@@enDesc:
6278 wakaba 1.48 <P::superURI> is not a super-resource of this resource.
6279 wakaba 1.12 @@@PerlDef:
6280 wakaba 1.48 $r = $self->{aliasURI}->{$superURI} || $self->{subOf}->{$superURI};
6281 wakaba 1.89 if (not $r and $srinfo) {
6282     A: {
6283     if ($srinfo->{resource}->{$superURI}) {
6284     for my $this_uri (grep {$self->{aliasURI}->{$_}}
6285     keys %{$self->{aliasURI}}) {
6286     if ($srinfo->{resource}->{$superURI}->{aliasURI}->{$this_uri}) {
6287     $r = true;
6288     last A;
6289     }
6290     if ($srinfo->{resource}->{$superURI}->{supOf}->{$this_uri}) {
6291     $r = true;
6292     last A;
6293     }
6294     }
6295     }
6296     for my $this_uri (grep {$self->{aliasURI}->{$_}}
6297     keys %{$self->{aliasURI}}) {
6298     if ($srinfo->{resource}->{$this_uri}) {
6299     if ($srinfo->{resource}->{$this_uri}->{aliasURI}->{$superURI}) {
6300     $r = true;
6301     last A;
6302     }
6303     }
6304     }
6305     } # A
6306     }
6307 wakaba 1.13
6308     @Method:
6309 wakaba 1.48 @@Name: addSuperResource
6310 wakaba 1.13 @@enDesc:
6311 wakaba 1.48 Adds a <QUOTE::dis> resource to the list of super-resource
6312     of this <QUOTE::dis> resource.
6313 wakaba 1.13 @@Param:
6314 wakaba 1.48 @@@Name: superRes
6315 wakaba 1.47 @@@Type: DISResource
6316     @@@clsActualType: ManakaiDISResourceDefinition
6317 wakaba 1.13 @@@enDesc:
6318 wakaba 1.48 A <QUOTE::dis> resource definition object.
6319 wakaba 1.89 @@NamedParam:
6320     @@@Name: srinfo
6321 wakaba 1.110 @@@Type: DISPerl|HASH
6322 wakaba 1.89 @@@enDesc:
6323     The <CODE::srinfo> hash.
6324     @@@nullCase:
6325     @@@@enDesc:
6326     No <CODE::srinfo>.
6327 wakaba 1.48 @@Return:
6328 wakaba 1.13 @@@PerlDef:
6329 wakaba 1.48 my @from = ($self->{uri},
6330 wakaba 1.50 grep {$self->{supOf}->{$_}} keys %{$self->{supOf}||{}});
6331 wakaba 1.48 my @to = ($superRes->{uri},
6332 wakaba 1.50 grep {$superRes->{subOf}->{$_}} keys %{$superRes->{subOf}||{}});
6333 wakaba 1.13 __DEEP{
6334 wakaba 1.48 for my $from (@from) {
6335     for my $to (@to) {
6336     $self->{db}-><M::ManakaiDISDatabase.getResource>
6337     ($from)->{subOf}->{$to} = true;
6338 wakaba 1.89 $srinfo->{resource}->{$from}->{subOf}->{$to} = true;
6339 wakaba 1.48 $self->{db}-><M::ManakaiDISDatabase.getResource>
6340     ($to)->{supOf}->{$from} = true;
6341 wakaba 1.89 $srinfo->{resource}->{$to}->{supOf}->{$from} = true;
6342 wakaba 1.13 }
6343     }
6344     }__;
6345 wakaba 1.48
6346 wakaba 1.13 @Method:
6347 wakaba 1.48 @@Name: mergeAsAlias
6348 wakaba 1.13 @@enDesc:
6349 wakaba 1.48 Merges another resource definition as an alias of this resource.
6350 wakaba 1.13 @@Param:
6351 wakaba 1.48 @@@Name: aliasResource
6352 wakaba 1.47 @@@Type: DISResource
6353     @@@clsActualType: ManakaiDISResourceDefinition
6354 wakaba 1.13 @@@enDesc:
6355 wakaba 1.48 A resource to merge.
6356     \
6357     {NOTE:: After merging all references to <P::aliasResource>
6358     should be discarded.
6359     \
6360     }
6361     @@NodeParam:
6362 wakaba 1.88 @@NamedParam:
6363     @@@Name: noEqualityCheck
6364 wakaba 1.110 @@@Type: idl|boolean
6365 wakaba 1.88 @@@enDesc:
6366     Don't throw <X::MERGE_ITSELF_ERR> exception.
6367 wakaba 1.89 @@NamedParam:
6368     @@@Name: srinfo
6369 wakaba 1.110 @@@Type: DISPerl|HASH
6370 wakaba 1.89 @@@enDesc:
6371     The <CODE::srinfo> hash.
6372     @@@nullCase:
6373     @@@@enDesc:
6374     No <CODE::srinfo>.
6375 wakaba 1.48 @@Return:
6376     @@@RaiseException:
6377     @@@@@:MERGE_ITSELF_ERR
6378     @@@@@@enDesc:
6379     An attempt is made to merge this resource itself.
6380 wakaba 1.13 @@@PerlDef:
6381 wakaba 1.88 if (not $noEqualityCheck and $self eq $aliasResource) {
6382 wakaba 1.48 __EXCEPTION{MERGE_ITSELF_ERR::
6383 wakaba 1.89 DIS:uri => {$self-><AG::DISAnyResource.uri>},
6384 wakaba 1.48 DIS:sourceNode => {$node},
6385     }__;
6386     }
6387     for my $uri ($aliasResource->{uri},
6388     grep {$aliasResource->{aliasURI}->{$_}}
6389     keys %{$aliasResource->{aliasURI}}) {
6390     $self->{aliasURI}->{$uri} = true;
6391     $self->{db}->{resDef}->{$uri} = $self;
6392     $self->{subOf}->{$uri} = true;
6393     $self->{supOf}->{$uri} = true;
6394     }
6395     for my $uri (grep {$aliasResource->{subOf}->{$_}}
6396 wakaba 1.50 keys %{$aliasResource->{subOf}||{}}) {
6397 wakaba 1.48 $self->{subOf}->{$uri} = true;
6398     }
6399     for my $uri (grep {$aliasResource->{supOf}->{$_}}
6400 wakaba 1.50 keys %{$aliasResource->{supOf}||{}}) {
6401 wakaba 1.48 $self->{supOf}->{$uri} = true;
6402     }
6403 wakaba 1.50 my @from = grep {$self->{supOf}->{$_}} keys %{$self->{supOf}||{}};
6404     my @to = grep {$self->{subOf}->{$_}} keys %{$self->{subOf}||{}};
6405 wakaba 1.13 __DEEP{
6406 wakaba 1.48 for my $from (@from) {
6407     for my $to (@to) {
6408     $self->{db}-><M::ManakaiDISDatabase.getResource>
6409     ($from)->{subOf}->{$to} = true;
6410 wakaba 1.89 $srinfo->{resource}->{$from}->{subOf}->{$to} = true;
6411 wakaba 1.48 $self->{db}-><M::ManakaiDISDatabase.getResource>
6412     ($to)->{supOf}->{$from} = true;
6413 wakaba 1.89 $srinfo->{resource}->{$to}->{supOf}->{$from} = true;
6414 wakaba 1.13 }
6415     }
6416     }__;
6417 wakaba 1.15
6418 wakaba 1.48 @Attr:
6419     @@Name: disDataTypeResource
6420     @@enDesc:
6421     The resource referenced by <Q::dis:Type> property.
6422 wakaba 1.15
6423 wakaba 1.48 = If the resource has the <Q::dis:Type> property,
6424     then its value references the data type resource.
6425 wakaba 1.15
6426 wakaba 1.48 = If the resource has no <Q::dis:Type> property but
6427     the dynamic parent resource has the <Q::dis:Type> property,
6428     then its value references the data type resource.
6429    
6430     = Otherwise, the resource has no associated data type resoruce;
6431     this method throws a <X::NO_DIS_TYPE_ERR> exception.
6432     @@Type: DISResource
6433     @@clsActualType: ManakaiDISResourceDefinition
6434     @@Get:
6435     @@@RaiseException:
6436     @@@@@:NO_DIS_TYPE_ERR
6437 wakaba 1.16 @@@@enDesc:
6438 wakaba 1.48 <Q::dis:Type> attribute is not specified.
6439 wakaba 1.13 @@@PerlDef:
6440 wakaba 1.48 __DEEP{
6441     if (UNIVERSAL::isa ($self->{<Q::dis:Type>}, <IFName::dv|DVURIValue>)) {
6442     $r = $self->{<Q::dis:Type>}-><M::dv|DVURIValue.getResource>
6443     ($self-><AG::DISAnyResource.database>);
6444     } else {
6445 wakaba 1.54 my $pr = $self-><AG::DIS|DISResource.dynamicParentResource>;
6446 wakaba 1.48 $r = $pr-><AG::DISResource.disDataTypeResource> if $pr;
6447     }
6448     }__;
6449     unless ($r) {
6450     __EXCEPTION{NO_DIS_TYPE_ERR::
6451     DIS:uri => {$self-><AG::DISAnyResource.uri>},
6452     DIS:sourceNode => {$self-><AG::DISAnyResource.sourceElement>},
6453 wakaba 1.13 }__;
6454     }
6455 wakaba 1.48
6456     @Attr:
6457     @@Name: disDataTypeValue
6458     @@enDesc:
6459     The <Q::dis:Type> property value for the resource.
6460     @@Get:
6461     @@@Type: dv|DVURIValue
6462     @@@clsActualType: dv|ManakaiDVURIValue
6463     @@@RaiseException:
6464     @@@@@:NO_DIS_TYPE_ERR
6465     @@@@enDesc:
6466     <Q::dis:Type> attribute is not specified.
6467     @@@PerlDef:
6468 wakaba 1.13 __DEEP{
6469 wakaba 1.48 if (UNIVERSAL::isa ($self->{<Q::dis:Type>}, <IFName::dv|DVURIValue>)) {
6470     $r = $self->{<Q::dis:Type>};
6471 wakaba 1.16 } else {
6472 wakaba 1.54 my $pr = $self-><AG::DIS|DISResource.dynamicParentResource>;
6473 wakaba 1.48 $r = $pr-><AG::DISResource.disDataTypeValue> if $pr;
6474 wakaba 1.16 }
6475 wakaba 1.48 }__;
6476     unless ($r) {
6477     __EXCEPTION{NO_DIS_TYPE_ERR::
6478     DIS:uri => {$self-><AG::DISAnyResource.uri>},
6479     DIS:sourceNode => {$self-><AG::DISAnyResource.sourceElement>},
6480     }__;
6481     }
6482 wakaba 1.13
6483     @Attr:
6484 wakaba 1.48 @@Name: disActualDataTypeResource
6485 wakaba 1.13 @@enDesc:
6486 wakaba 1.48 <Q::dis:actualType> attribute value of this resource.
6487     @@Type: DISResource
6488     @@clsActualType: ManakaiDISResourceDefinition
6489 wakaba 1.13 @@Get:
6490 wakaba 1.48 @@@RaiseException:
6491     @@@@@:NO_DIS_TYPE_ERR
6492 wakaba 1.13 @@@@enDesc:
6493 wakaba 1.48 <Q::dis:actualType> attribute is not specified,
6494     and <Q::dis:Type> attribute, neigher.
6495 wakaba 1.13 @@@PerlDef:
6496 wakaba 1.48 __DEEP{
6497     if (UNIVERSAL::isa ($self->{<Q::dis:actualType>},
6498     <IFName::dv|DVURIValue>)) {
6499     $r = $self->{<Q::dis:actualType>}-><M::dv|DVURIValue.getResource>
6500     ($self-><AG::DISAnyResource.database>);
6501     } elsif (UNIVERSAL::isa ($self->{<Q::dis:Type>},
6502     <IFName::dv|DVURIValue>)) {
6503     $r = $self->{<Q::dis:Type>}-><M::dv|DVURIValue.getResource>
6504     ($self-><AG::DISAnyResource.database>);
6505     } else {
6506 wakaba 1.54 my $pr = $self-><AG::DIS|DISResource.dynamicParentResource>;
6507 wakaba 1.48 $r = $pr-><AG::DISResource.disActualDataTypeResource> if $pr;
6508     }
6509     }__;
6510     unless ($r) {
6511     __EXCEPTION{NO_DIS_TYPE_ERR::
6512     DIS:uri => {$self-><AG::DISAnyResource.uri>},
6513     DIS:sourceNode => {$self-><AG::DISAnyResource.sourceElement>},
6514 wakaba 1.13 }__;
6515     }
6516 wakaba 1.48
6517     @Attr:
6518     @@Name: disActualDataTypeValue
6519 wakaba 1.13 @@enDesc:
6520 wakaba 1.48 <Q::dis:actualType> node for this resource.
6521     @@Get:
6522     @@@Type: DISElement
6523     @@@clsActualType: ManakaiDISElement
6524 wakaba 1.13 @@@RaiseException:
6525 wakaba 1.48 @@@@@:NO_DIS_TYPE_ERR
6526 wakaba 1.13 @@@@enDesc:
6527 wakaba 1.48 <Q::dis:actualType> attribute is not specified,
6528     and <Q::dis:Type> attribute, neigher.
6529 wakaba 1.13 @@@PerlDef:
6530 wakaba 1.48 __DEEP{
6531     if (UNIVERSAL::isa ($self->{<Q::dis:actualType>},
6532     <IFName::dv|DVURIValue>)) {
6533     $r = $self->{<Q::dis:actualType>};
6534     } elsif (UNIVERSAL::isa ($self->{<Q::dis:Type>},
6535     <IFName::dv|DVURIValue>)) {
6536     $r = $self->{<Q::dis:Type>};
6537 wakaba 1.13 } else {
6538 wakaba 1.54 my $pr = $self-><AG::DIS|DISResource.dynamicParentResource>;
6539 wakaba 1.48 $r = $pr-><AG::DISResource.disActualDataTypeValue> if $pr;
6540 wakaba 1.13 }
6541 wakaba 1.48 }__;
6542     unless ($r) {
6543     __EXCEPTION{NO_DIS_TYPE_ERR::
6544     DIS:uri => {$self-><AG::DISAnyResource.uri>},
6545     DIS:sourceNode => {$self-><AG::DISAnyResource.sourceElement>},
6546 wakaba 1.13 }__;
6547     }
6548    
6549 wakaba 1.15 @IntMethod:
6550 wakaba 1.48 @@Operator:
6551     @@@@: <=>
6552     @@@ContentType:
6553     lang:Perl
6554 wakaba 1.15 @@enDesc:
6555 wakaba 1.54 Compares two resources. If the first character of the
6556     node in the source tree by which the resource is defined
6557     occures before the other resource's first character, then
6558     the former resource is <DFN::less> than the later resource.
6559     If two resources are the same resource, they are <DFN::equal>.
6560     Otherwise, the former resource is <DFN::greater> than
6561     the later resource.
6562    
6563     There are two exceptions. If two resources belongs to
6564     two different modules, i.e. their <A::DIS|DISAnyResource.ownerModule>s
6565     are different, the order is not defined. Also, if
6566     one of resources is not yet defined, i.e. one's
6567     <A::DIS|DISAnyResource.isDefined> takes <DOM::false> value,
6568     then the order is not defined. Even in these cases, two
6569     calls for the method with the same parameter would return
6570     the same result while the resources are left unchanged.
6571 wakaba 1.48 @@Param:
6572     @@@Name: anotherResource
6573     @@@Type: DISResource
6574     @@@enDesc: Another resource to compare.
6575 wakaba 1.15 @@Return:
6576     @@@Type:
6577 wakaba 1.110 DOMMain:unsigned-long
6578 wakaba 1.15 @@@PerlDef:
6579 wakaba 1.48 if (UNIVERSAL::isa ($anotherResource,
6580     <ClassName::ManakaiDISResourceDefinition>)) {
6581     $r = $self->{seq} <=> $anotherResource->{seq};
6582     } else {
6583 wakaba 1.54 $r = $self->{uri} <=> $anotherResource;
6584 wakaba 1.48 }
6585 wakaba 1.15
6586     @Method:
6587 wakaba 1.54 @@ForCheck: ManakaiDOM|ForClass
6588     @@ManakaiDOM:isForInternal:1
6589     @@Name: addChildResource
6590     @@enDesc:
6591     Registers a resource as a static child of the resource.
6592     @@Param:
6593     @@@Name: disResource
6594     @@@Type: DIS|DISResource
6595     @@@enDesc:
6596     The resurce to add.
6597     @@Return:
6598     @@@PerlDef:
6599     __DEEP{
6600     push @{$self->{<H::DIS|childResource>}||=[]},
6601     $disResource-><AG::DIS|DISAnyResource.uriRef>;
6602     }__;
6603    
6604     @Method:
6605     @@ForCheck: ManakaiDOM|ForClass
6606     @@ManakaiDOM:isForInternal:1
6607     @@Name: addDynamicChildResource
6608     @@enDesc:
6609     Registers a resource as a dynamic child of the resource.
6610     @@Param:
6611     @@@Name: disResource
6612     @@@Type: DIS|DISResource
6613     @@@enDesc:
6614     The resurce to add.
6615     @@Return:
6616     @@@PerlDef:
6617     __DEEP{
6618     push @{$self->{<H::DIS|dynamicChildResource>}||=[]},
6619     $disResource-><AG::DIS|DISAnyResource.uriRef>;
6620     }__;
6621    
6622     @Method:
6623     @@Name: getChildResourceList
6624     @@enDesc:
6625     Returns the list of static child resources of the resource.
6626     @@Return:
6627     @@@Type: DIS|ResourceList
6628     @@@enDesc:
6629     The current snapshot of children.
6630     @@@PerlDef:
6631     __DEEP{
6632     my $db = $self-><AG::DIS|DISAnyResource.database>;
6633     $r = [map {
6634     $db-><M::DIS|DISDatabase.getResource> ($$_)
6635     } @{$self->{<H::DIS|childResource>}}];
6636     }__;
6637    
6638     @Method:
6639     @@Name: getDynamicChildResourceList
6640     @@enDesc:
6641     Returns the list of dynamic child resources of the resource.
6642     @@Return:
6643     @@@Type: DIS|ResourceList
6644     @@@enDesc:
6645     The current snapshot of children.
6646     @@@PerlDef:
6647     __DEEP{
6648     my $db = $self-><AG::DIS|DISAnyResource.database>;
6649     $r = [map {
6650     $db-><M::DIS|DISDatabase.getResource> ($$_)
6651     } @{$self->{<H::DIS|dynamicChildResource>}}];
6652     }__;
6653    
6654     @Method:
6655 wakaba 1.48 @@Name: getChildResourceByType
6656 wakaba 1.15 @@enDesc:
6657 wakaba 1.48 Gets a static child resource selected by its type.
6658     @@Param:
6659     @@@Name:typeURI
6660     @@@Type:ResourceURI
6661     @@@enDesc:
6662     A URI reference identifying a resource type.
6663     @@ImplNote:
6664     @@@lang:en
6665     @@@@:
6666 wakaba 1.54 {ISSUE:: Some inheritance tracing required for
6667 wakaba 1.48 e.g. <Q::DISLang:InputProcessor> and <Q::DOMMain:ReflectGet>?
6668 wakaba 1.54 }
6669 wakaba 1.15 @@Return:
6670 wakaba 1.47 @@@Type: DISResource
6671     @@@clsActualType: ManakaiDISResourceDefinition
6672 wakaba 1.15 @@@enDesc:
6673 wakaba 1.48 The first child resource (in document order) whose
6674     type matches with <P::typeURI>.
6675 wakaba 1.15 @@@nullCase:
6676     @@@@enDesc:
6677 wakaba 1.48 There is no resource whose type is <P::typeURI>.
6678 wakaba 1.15 @@@PerlDef:
6679 wakaba 1.48 __DEEP{
6680 wakaba 1.54 my $db = $self-><AG::DIS|DISAnyResource.database>;
6681     C: for my $cr_uri (@{$self->{<H::DIS:childResource>}||[]}) {
6682     my $cr = $db-><M::DIS|DISDatabase.getResource> ($$cr_uri);
6683 wakaba 1.79 if ($cr-><M::DIS|DISAnyResource.isTypeURI> ($typeURI)) {
6684 wakaba 1.48 $r = $cr;
6685 wakaba 1.54 last C;
6686 wakaba 1.48 }
6687 wakaba 1.15 }
6688 wakaba 1.48 }__;
6689 wakaba 1.15
6690 wakaba 1.48 @Method:
6691 wakaba 1.54 @@Name: getChildResourceListByType
6692     @@enDesc:
6693     Returns a list of child resources of a specific type.
6694     @@Param:
6695     @@@Name: typeURI
6696     @@@Type: DIS|AnyURI
6697     @@@enDesc:
6698     A URI of the type.
6699     @@Return:
6700     @@@Type: DIS|ResourceList
6701     @@@enDesc:
6702     The current snapshot of the child resources of type <P::typeURI>.
6703     @@@PerlDef:
6704     __DEEP{
6705     my $db = $self-><AG::DIS|DISAnyResource.database>;
6706     $r = [grep {
6707 wakaba 1.79 $_-><M::DIS|DISAnyResource.isTypeURI> ($typeURI)
6708 wakaba 1.54 } map {
6709     $db-><M::DIS|DISDatabase.getResource> ($$_)
6710     } @{$self->{<H::DIS|childResource>}||[]}];
6711     }__;
6712    
6713     @Method:
6714 wakaba 1.48 @@Name: getChildResourceByNameAndType
6715 wakaba 1.15 @@enDesc:
6716 wakaba 1.48 Gets a static child resource selected by its local name and type.
6717 wakaba 1.15 @@Param:
6718 wakaba 1.48 @@@Name: localName
6719     @@@Type:
6720 wakaba 1.110 DISCore:LocalName
6721 wakaba 1.15 @@@enDesc:
6722 wakaba 1.48 A local name.
6723 wakaba 1.15 @@Param:
6724 wakaba 1.48 @@@Name:typeURI
6725     @@@Type:ResourceURI
6726 wakaba 1.15 @@@enDesc:
6727 wakaba 1.48 A URI reference identifying a resource type.
6728     @@Return:
6729 wakaba 1.47 @@@Type: DISResource
6730     @@@clsActualType: ManakaiDISResourceDefinition
6731 wakaba 1.15 @@@enDesc:
6732 wakaba 1.48 The first (by document order) child resource whose
6733     type matches for <P::localName> and <P::typeURI>.
6734 wakaba 1.15 @@@nullCase:
6735     @@@@enDesc:
6736 wakaba 1.48 There is no resource whose name is <P::localName> and
6737     whose type is <P::typeURI>.
6738     @@@PerlDef:
6739     __DEEP{
6740 wakaba 1.54 my $db = $self-><AG::DIS|DISAnyResource.database>;
6741     C: for my $cr_uri (@{$self->{<H::DIS:childResource>}||[]}) {
6742     my $cr = $db-><M::DIS|DISDatabase.getResource> ($$cr_uri);
6743     my $ln = $cr-><AG::DIS|DISAnyResource.localName>;
6744 wakaba 1.48 if (defined $ln and $ln eq $localName and
6745 wakaba 1.79 $cr-><M::DIS|DISAnyResource.isTypeURI> ($typeURI)) {
6746 wakaba 1.48 $r = $cr;
6747 wakaba 1.54 last C;
6748 wakaba 1.48 }
6749     }
6750     }__;
6751    
6752     @Method:
6753     @@Name: getConstResourceByName
6754     @@enDesc:
6755     Gets a constant value resource by its local name.
6756 wakaba 1.15 @@Param:
6757 wakaba 1.48 @@@Name:localName
6758 wakaba 1.15 @@@Type:
6759 wakaba 1.110 DISLang:String
6760 wakaba 1.15 @@@enDesc:
6761 wakaba 1.48 Constant name.
6762 wakaba 1.15 @@Return:
6763 wakaba 1.48 @@@Type: DISResource
6764     @@@clsActualType: ManakaiDISResourceDefinition
6765     @@@enDesc:
6766     The constant resource identified by <P::localName>.
6767     @@@nullCase:
6768 wakaba 1.16 @@@@enDesc:
6769 wakaba 1.48 There is no such constant resource.
6770 wakaba 1.15 @@@PerlDef:
6771 wakaba 1.48 __DEEP{
6772     my @constGroup;
6773 wakaba 1.54 my $db = $self-><AG::DIS|DISAnyResource.database>;
6774     C: for my $cr_uri (@{$self->{<H::DIS:childResource>}||[]}) {
6775     my $cr = $db-><M::DIS|DISDatabase.getResource> ($$cr_uri);
6776     my $ln = $cr-><AG::DIS|DISAnyResource.localName>;
6777 wakaba 1.48 if ($ln and $ln eq $localName and
6778 wakaba 1.79 $cr-><M::DIS|DISAnyResource.isTypeURI> (<Q::DISLang:Const>)) {
6779 wakaba 1.48 $r = $cr;
6780 wakaba 1.54 last C;
6781 wakaba 1.79 } elsif ($cr-><M::DIS|DISAnyResource.isTypeURI>
6782 wakaba 1.54 (<Q::DISLang:ConstGroup>)) {
6783 wakaba 1.48 push @constGroup, $cr;
6784     }
6785     }
6786     unless ($r) {
6787 wakaba 1.54 D: for my $cg (@constGroup) {
6788     $r = $cg-><M::DIS|DISResource.getChildResourceByNameAndType>
6789     ($localName, <Q::DISLang:Const>);
6790     last D if $r;
6791 wakaba 1.15 }
6792     }
6793 wakaba 1.48 }__;
6794 wakaba 1.15
6795 wakaba 1.18 @Attr:
6796 wakaba 1.54 @@Name: parentResource
6797     @@enDesc:
6798     The static parent resource of the resource.
6799     @@Type: DIS|DISResource
6800     @@nullCase:
6801     @@@enDesc: No parent resource.
6802     @@Get:
6803     @@@PerlDef:
6804     __DEEP{
6805     if ($self->{<H::DIS|parentResource>}) {
6806     $r = $self-><AG::DIS|DISAnyResource.database>
6807     -><M::DIS|DISDatabase.getResource>
6808     (${$self->{<H::DIS|parentResource>}});
6809     }
6810     }__;
6811     @@Set:
6812     @@@ForCheck: ManakaiDOM|ForClass
6813     @@@PerlDef:
6814     __DEEP{
6815     if ($given) {
6816     $self->{<H::DIS|parentResource>}
6817     = $given-><AG::DIS|DISAnyResource.uriRef>;
6818     } else {
6819     CORE::delete $self->{<H::DIS|parentResource>};
6820     }
6821     }__;
6822    
6823     @Attr:
6824     @@Name: dynamicParentResource
6825     @@enDesc:
6826     The dynamic parent resource of the resource.
6827     @@Type: DIS|DISResource
6828     @@nullCase:
6829     @@@enDesc: No parent resource.
6830     @@Get:
6831     @@@PerlDef:
6832     __DEEP{
6833     if ($self->{<H::DIS|dynamicParentResource>}) {
6834     $r = $self-><AG::DIS|DISAnyResource.database>
6835     -><M::DIS|DISDatabase.getResource>
6836     (${$self->{<H::DIS|dynamicParentResource>}});
6837     }
6838     }__;
6839     @@Set:
6840     @@@ForCheck: ManakaiDOM|ForClass
6841     @@@PerlDef:
6842     __DEEP{
6843     if ($given) {
6844     $self->{<H::DIS|dynamicParentResource>}
6845     = $given-><AG::DIS|DISAnyResource.uriRef>;
6846     } else {
6847     CORE::delete $self->{<H::DIS|dynamicParentResource>};
6848     }
6849     }__;
6850    
6851     @Attr:
6852 wakaba 1.48 @@Name: ownerClassNodeURI
6853 wakaba 1.18 @@enDesc:
6854 wakaba 1.48 The node URI reference of the class resource this resource
6855     belongs to.
6856     @@Type: ResourceURI
6857 wakaba 1.18 @@Get:
6858 wakaba 1.48 @@@enDesc:
6859     The URI reference of the <Q::ManakaiDOM:Class> resource.
6860     If this resource is a class, then the URI reference
6861     of this resource is returned.
6862     @@@nullCase:
6863 wakaba 1.18 @@@@enDesc:
6864 wakaba 1.48 This resource does not belong to any class.
6865 wakaba 1.18 @@@PerlDef:
6866 wakaba 1.53 if (exists $self->{<H::DIS:ownerClass>}) {
6867     $r = $self->{<H::DIS:ownerClass>};
6868 wakaba 1.48 } else {
6869     my $res = $self;
6870     __DEEP{
6871     RES: {
6872 wakaba 1.79 if ($res-><M::DISAnyResource.isTypeURI>
6873 wakaba 1.48 (<Q::ManakaiDOM:Class>)) {
6874     $r = $res-><AG::DISAnyResource.sourceNodeID>;
6875     } else {
6876 wakaba 1.54 $res = $res-><AG::DIS|DISResource.parentResource>;
6877 wakaba 1.48 redo RES if $res;
6878     }
6879 wakaba 1.18 }
6880 wakaba 1.48 }__;
6881 wakaba 1.53 $self->{<H::DIS:ownerClass>} = $r;
6882 wakaba 1.48 }
6883 wakaba 1.18
6884     @Attr:
6885     @@Name: disIsNullValue
6886     @@enDesc:
6887     Whether this resource have <DOM::null> value or not.
6888     A resource have <DOM::null> value iff it has
6889     <Q::dis:Value> attribute node that in turn has
6890     <Q::dis:is-null> attribute whose value set to <DOM::true>.
6891     @@Type:
6892 wakaba 1.110 DOMMain:boolean
6893 wakaba 1.18 @@Get:
6894     @@@PerlDef:
6895 wakaba 1.51 if ($self->{<Q::dis:Value>}) {
6896     $r = $self->{<Q::dis:Value>}-><AG::dv|DVValue.isNull>;
6897 wakaba 1.18 }
6898 wakaba 1.24
6899     @Attr:
6900     @@Name: featureNameList
6901     @@enDesc:
6902     The list of the names of the feature defined by this resource.
6903 wakaba 1.48
6904     = If the resource has one or more <Q::dis:AppName> attributes,
6905     their text values are feature names.
6906    
6907     = If there is no <Q::dis:AppName> attributes but the resource
6908     is a <Q::DOMFeature:instanceOf> another feature, then
6909     the set of the feature names of the resource is equal
6910     to the one of another feature's feature names.
6911    
6912     {OLI:: If two operation above does not result in one or more
6913     feature names,
6914    
6915     = and if the resource has a name (the <A::DISAnyResource
6916     .isAnonymous> attribute returns <DOM::false>), then
6917     the <A::DISAnyResource.nameURI> of the resource is
6918     a feature name.
6919    
6920     = otherwise, i.e. <A::DISAnyResource.isAnonymous> is
6921     <DOM::true>, then the <A::DISAnyResource.localName>
6922     of the resource, if non-<DOM::null>, is a feature name.
6923    
6924     }
6925    
6926 wakaba 1.24 @@Type:
6927 wakaba 1.110 DISPerl:ARRAY
6928 wakaba 1.24 @@Get:
6929 wakaba 1.48 @@@enDesc:
6930     A reference to the array containing feature names.
6931     Note that the order in the array is <EM::not> significant.
6932     The array might be empty if the resource has no feature name.
6933     This array is dead.
6934    
6935     {NOTE:: The attribute value array might be non-empty
6936     even if the resource is not of type <Q::DOMFeature:Feature>
6937     as far as the algorithm defined above returns
6938     some feature names.
6939     }
6940 wakaba 1.24 @@@RaiseException:
6941     @@@@@: NO_SOURCE_NODE_ERR
6942     @@@@enDesc:
6943     This resource definition does not have associated node
6944     in the source tree.
6945     @@@PerlDef:
6946     __DEEP{
6947 wakaba 1.49 $r = [map {lc} @{$self-><M::DISResourceProp.getPropertyTextList>
6948 wakaba 1.52 (<Q::DOMFeature:name>)}];
6949 wakaba 1.24 unless (@$r) {
6950 wakaba 1.48 ## TODO: instance feature
6951 wakaba 1.54 my $pr = $self-><AG::DIS|DISResource.parentResource>;
6952 wakaba 1.28 if ($pr) {
6953 wakaba 1.79 if ($pr-><M::DISAnyResource.isTypeURI> (<Q::DOMFeature:Feature>) and
6954 wakaba 1.48 not $pr-><AG::DISAnyResource.isAnonymous>) {
6955     push @$r, @{$pr-><AG::DISResource.featureNameList>};
6956 wakaba 1.28 }
6957     }
6958     }
6959     unless (@$r) {
6960 wakaba 1.48 if ($self-><AG::DISAnyResource.isAnonymous>) {
6961     my $ln = $self-><AG::DISAnyResource.localName>;
6962 wakaba 1.28 push @$r, lc $ln if defined $ln;
6963 wakaba 1.24 } else {
6964 wakaba 1.48 push @$r, lc $self-><AG::DISAnyResource.nameURI>;
6965     }
6966     }
6967     }__;
6968    
6969     @Attr:
6970     @@Name: multiplePropertiesURI
6971     @@enDesc:
6972     Whether the property allows multiple occurence of the attribute
6973     in the <QUOTE::dis> source tree.
6974 wakaba 1.110 @@Type: DISLang|String
6975 wakaba 1.48 @@Get:
6976     @@@PerlDef:
6977     __DEEP{
6978     if ($self->{<Q::dis|multipleProperties>}) {
6979     $r = $self->{<Q::dis|multipleProperties>}
6980     -><M::dv|DVURIValue.getResource>
6981     ($self-><AG::DISAnyResource.database>)
6982     -><AG::DISAnyResource.uri>;
6983     } else {
6984     $r = <Q::DISCore|OrderedList>;
6985     }
6986     }__;
6987    
6988     @Attr:
6989     @@Name: defaultLextypeURI
6990     @@enDesc:
6991     The URI of the default lexical type for the <QUOTE::dis> attribute.
6992 wakaba 1.110 @@Type: DISLang|String
6993 wakaba 1.48 @@Get:
6994     @@@PerlDef:
6995     __DEEP{
6996     if ($self->{<Q::dis:dataType>}) {
6997     $r = $self->{<Q::dis:dataType>}
6998     -><M::dv|DVURIValue.getResource>
6999     ($self-><AG::DISAnyResource.database>)
7000     -><AG::DISAnyResource.uri>;
7001     } else {
7002     $r = <Q::DISCore|String>;
7003     }
7004 wakaba 1.24 }__;
7005 wakaba 1.79
7006     @CMethod:
7007     @@Name: getSuperResourceURIList
7008     @@enDesc:
7009     Returns a snapshot list of super-resources URIs of the resource,
7010     including canonical and alias URIs of the resource itself.
7011     @@Return:
7012     @@@Type: URIList
7013     @@@enDesc:
7014     A snapshot list of URIs.
7015     @@@PerlDef:
7016     $r = [
7017     (grep {$self->{subOf}->{$_}} keys %{$self->{subOf}}),
7018     (grep {$self->{aliasURI}->{$_}} keys %{$self->{aliasURI}}),
7019     ];
7020    
7021     @@Test:
7022     @@@QName: DISResource.getSuperResourceURIList.test
7023     @@@PerlDef:
7024     my $db;
7025     __CODE{createDISDBForTest:: $db => $db}__;
7026    
7027     my $res1 = $db->get_resource ('about:test1');
7028     my $res2 = $db->get_resource ('about:test2');
7029     $res1->add_super_resource ($res2);
7030    
7031     my %list1 = map {$_ => true} @{$res1->get_super_resource_uri_list};
7032     $test->id ('res1.itself');
7033     $test->assert_true ($list1{'about:test1'});
7034     $test->id ('res1.res2');
7035     $test->assert_true ($list1{'about:test2'});
7036    
7037     my %list2 = map {$_ => true} @{$res2->get_super_resource_uri_list};
7038     $test->id ('res2.itself');
7039     $test->assert_true ($list2{'about:test2'});
7040     $test->id ('res2.res1');
7041     $test->assert_false ($list2{'about:test1'});
7042    
7043     @Method:
7044     @@ForCheck: ManakaiDOM|ForIF
7045     @@Name: isTypeURI
7046     @@enImplNote: For compatibility with old code.
7047 wakaba 1.48 ##DISResource
7048    
7049 wakaba 1.79 ResourceDef:
7050     @QName: String
7051 wakaba 1.110 @AliasFor: DISLang|String
7052 wakaba 1.79
7053     ResourceDef:
7054     @QName: RevisionNumber
7055 wakaba 1.110 @AliasFor: idl|unsignedLong
7056 wakaba 1.79 @enImplNote:
7057     {ISSUE::
7058 wakaba 1.110 Should be <Q::idl|unsignedLongLong>?
7059 wakaba 1.79 }
7060    
7061     PropDef:
7062     @QName: DIS|revision
7063     @DIS:key: r
7064    
7065     ElementTypeBinding:
7066     @Name: Test
7067     @ElementType:
7068     dis:ResourceDef
7069     @ShadowContent:
7070     @@rdf:type: test|StandaloneTest
7071     @@ForCheck: ManakaiDOM|ForClass
7072    
7073     DataTypeDef:
7074     @QName: URIList
7075 wakaba 1.110 @rdfs:subClassOf: DISPerl|ARRAY
7076 wakaba 1.79
7077 wakaba 1.48 IFClsDef:
7078     @IFQName: DISResourceMV
7079     @ClsQName: ManakaiDISResourceMV
7080    
7081     @enDesc:
7082     The objects implementing the <IF::DISResourceMV> <kwd:MUST>
7083     also implement the <IF::DISResource> interface.
7084 wakaba 1.32
7085     @Attr:
7086     @@Name: mvLocalName
7087     @@enDesc:
7088     The local name of the markup vocabulary element defined by this
7089     resource.
7090     @@Type:
7091 wakaba 1.110 DISLang:String
7092 wakaba 1.32 @@Get:
7093     @@@nullCase:
7094     @@@@enDesc:
7095     Either this resource does not define a markup vocabulary element
7096     or it does define an element but it does not have a local name.
7097     @@@PerlDef:
7098     __DEEP{
7099 wakaba 1.48 if (UNIVERSAL::isa ($self->{<Q::dis|AppName>},
7100     <IFName::dv|DVQNameValue>)) {
7101     $r = $self->{<Q::dis|AppName>}-><AG::dv|DVQNameValue.localName>;
7102 wakaba 1.96 } elsif (defined $self->{<Q::dis|AppName>}) {
7103     $r = $self->{<Q::dis|AppName>}-><AG::dv|DVValue.stringValue>;
7104 wakaba 1.43 } else {
7105 wakaba 1.59 $r = $self-><AG::DIS|DISAnyResource.localName>;
7106 wakaba 1.43 }
7107     }__;
7108    
7109     @Attr:
7110     @@Name: mvPrefix
7111     @@enDesc:
7112     A typical namespace prefix of the markup vocabulary element defined
7113     by this resource.
7114     @@Type:
7115 wakaba 1.110 DISLang:String
7116 wakaba 1.43 @@Get:
7117     @@@nullCase:
7118     @@@@enDesc:
7119     Either this resource does not define a markup vocabulary element
7120     or it does define an element but it does not have a namespace URI.
7121     @@@PerlDef:
7122     __DEEP{
7123 wakaba 1.48 if (UNIVERSAL::isa ($self->{<Q::dis|AppName>},
7124     <IFName::dv|DVQNameValue>)) {
7125     $r = $self->{<Q::dis|AppName>}-><AG::dv|DVQNameValue.prefix>;
7126 wakaba 1.43 }
7127     unless (defined $r) {
7128 wakaba 1.48 my $nsuri = $self-><AG::DISResourceMV.mvNamespaceURI>;
7129 wakaba 1.43 if (defined $nsuri and $nsuri =~ /([A-Za-z]\w*)\W*$/) {
7130 wakaba 1.53 $r = $1;
7131 wakaba 1.43 } elsif (defined $nsuri) {
7132 wakaba 1.53 $r = 'ns';
7133 wakaba 1.43 }
7134 wakaba 1.32 }
7135     }__;
7136    
7137     @Attr:
7138     @@Name: mvNamespaceURI
7139     @@enDesc:
7140     The namespace URI of the markup vocabulary element defined by this
7141     resource.
7142     @@Type: AnyURI
7143     @@Get:
7144     @@@nullCase:
7145     @@@@enDesc:
7146     Either this resource does not define a markup vocabulary element
7147     or it does define an element but it does not have a namespace URI.
7148     @@@PerlDef:
7149     __DEEP{
7150 wakaba 1.48 if (UNIVERSAL::isa ($self->{<Q::dis|AppName>},
7151     <IFName::dv|DVQNameValue>)) {
7152     $r = $self->{<Q::dis|AppName>}-><AG::dv|DVQNameValue.namespaceURI>;
7153 wakaba 1.96 } elsif (defined $self->{<Q::dis|AppName>}) {
7154     $r = null;
7155 wakaba 1.32 } else {
7156 wakaba 1.59 $r = $self-><AG::DIS|DISAnyResource.namespaceURI>;
7157 wakaba 1.32 }
7158     }__;
7159    
7160     @Attr:
7161     @@Name: mvOwnerElementResource
7162     @@enDesc:
7163     An <QUOTE::owner element> resource of the markup vocabulary
7164     element defined by this resource.
7165 wakaba 1.47 @@Type: DISResource
7166     @@clsActualType: ManakaiDISResourceDefinition
7167 wakaba 1.32 @@Get:
7168     @@@nullCase:
7169     @@@@enDesc:
7170     Either this resource does not define a markup vocabulary element
7171     or it does define an element but it does not have an owner.
7172     @@@PerlDef:
7173     __DEEP{
7174 wakaba 1.53 if (exists $self->{<H::DIS:mvOwnerElementURI>}) {
7175 wakaba 1.98 $r = $self-><AG::DISAnyResource.database>
7176     -><M::DISDatabase.getResource>
7177 wakaba 1.53 ($self->{<H::DIS:mvOwnerElementURI>})
7178     if defined $self->{<H::DIS:mvOwnerElementURI>};
7179 wakaba 1.54 } else {
7180     $r = $self-><AG::DIS|DISResource.parentResource>;
7181 wakaba 1.90 undef $r if $r and not $r-><M::DIS|DISAnyResource
7182 wakaba 1.32 .isTypeURI> (<Q::s:AnyOwnerElement>);
7183 wakaba 1.98 $self->{<H::DIS:mvOwnerElementURI>} = $r-><AG::DISAnyResource.uri>
7184     if $r;
7185 wakaba 1.32 }
7186 wakaba 1.48 }__;
7187     ##DISResourceMV
7188 wakaba 1.27
7189     PropDef:
7190 wakaba 1.32 @QName: mvLocalName
7191     @enDesc:
7192     <A::ManakaiDISResourceDefinition.mvLocalName>.
7193    
7194     PropDef:
7195 wakaba 1.43 @QName: mvPrefix
7196     @enDesc:
7197     <A::ManakaiDISResourceDefinition.mvPrerix>.
7198    
7199     PropDef:
7200 wakaba 1.32 @QName: mvNamespaceURI
7201     @enDesc:
7202     <A::ManakaiDISResourceDefinition.mvNamespaceURI>.
7203    
7204     PropDef:
7205     @QName: mvOwnerElementURI
7206     @enDesc:
7207     <A::ManakaiDISResourceDefinition.mvOwnerElementResource>
7208     (<QUOTE::dis> resource URI reference).
7209    
7210     PropDef:
7211 wakaba 1.13 @QName: ownerClass
7212     @enDesc:
7213     The class to which this resource belongs.
7214     @Type: ResourceURI
7215     @rdfs:range:
7216     rdf:Resource
7217     @rdfs:domain:
7218     ManakaiDOM:Class
7219 wakaba 1.20
7220     ResourceDef:
7221 wakaba 1.12 @QName: SWCFGNode
7222     @AliasFor:
7223 wakaba 1.110 swcfg21:SWCFGNode
7224 wakaba 1.12
7225     ResourceDef:
7226 wakaba 1.48 @QName: SWCFGElement
7227     @AliasFor:
7228 wakaba 1.110 swcfg21:SWCFGElement
7229 wakaba 1.48
7230     ResourceDef:
7231 wakaba 1.12 @QName: SWCFGDoc
7232     @AliasFor:
7233 wakaba 1.110 swcfg21:SWCFGDocument
7234 wakaba 1.12
7235 wakaba 1.101 ResourceDef:
7236     @QName: DOMImpl
7237 wakaba 1.110 @AliasFor: c|DOMImplementation
7238 wakaba 1.101
7239 wakaba 1.12 XParamDef:
7240 wakaba 1.48 @QName: sourceNodePath
7241     @enDesc:
7242     A node path string of the source node.
7243    
7244     XParamDef:
7245 wakaba 1.12 @QName: errResource
7246     @enDesc:
7247     A resource on which an error has occurred.
7248    
7249 wakaba 1.8 XParamDef:
7250     @QName: generatedName
7251     @enDesc:
7252     A generated name.
7253    
7254 wakaba 1.47 IFClsDef:
7255     @IFQName: DISResourceProp
7256 wakaba 1.2 @ClsQName: ManakaiDISPropertyAccessor
7257 wakaba 1.47
7258 wakaba 1.3 @enDesc:
7259 wakaba 1.2 Accessor methods for resource or module properties.
7260 wakaba 1.48
7261     @Method:
7262     @@Name: getPropertyValue
7263 wakaba 1.22 @@enDesc:
7264 wakaba 1.48 Returns a property value object.
7265     @@PropNameParam:
7266     @@Return:
7267     @@@Type: dv|DVValue
7268     @@@enDesc: The property value.
7269 wakaba 1.22 @@@nullCase:
7270     @@@@enDesc:
7271 wakaba 1.48 The property has no value.
7272 wakaba 1.22 @@@PerlDef:
7273 wakaba 1.52 if ($self->{$propName}) {
7274 wakaba 1.54 $r = $self->{$propName}->[0];
7275 wakaba 1.52 } else {
7276     my $pr = $self-><AG::DISAnyResource.database>
7277     -><M::DISDatabase.getResource> ($propName);
7278 wakaba 1.53 A: for (grep {$pr->{aliasURI}->{$_} or $pr->{supOf}->{$_}}
7279     (keys %{$pr->{aliasURI}}, keys %{$pr->{supOf}||{}})) {
7280 wakaba 1.52 my $v = $self->{$_};
7281     if ($v) {
7282     $r = $v->[0];
7283     last A;
7284     }
7285     }
7286     }
7287 wakaba 1.22
7288 wakaba 1.48 @Method:
7289     @@Name: getPropertyValueList
7290 wakaba 1.22 @@enDesc:
7291 wakaba 1.48 Returns a property value objects.
7292     @@PropNameParam:
7293     @@Return:
7294 wakaba 1.110 @@@Type: DISPerl|ARRAY
7295 wakaba 1.48 @@@enDesc: The property value.
7296     @@@PerlDef:
7297     my $pr = $self-><AG::DISAnyResource.database>
7298     -><M::DISDatabase.getResource> ($propName);
7299     $r = [map {@$_}
7300 wakaba 1.49 grep {defined $_}
7301 wakaba 1.48 map {$self->{$_}}
7302 wakaba 1.53 grep {$pr->{aliasURI}->{$_} or $pr->{supOf}->{$_}}
7303     (keys %{$pr->{aliasURI}}, keys %{$pr->{supOf}||{}})];
7304 wakaba 1.22
7305 wakaba 1.2 @Method:
7306 wakaba 1.8 @@Name: getPropertyBoolean
7307     @@enDesc:
7308     Gets boolean property value.
7309     @@PropNameParam:
7310     @@Param:
7311     @@@Name:default
7312     @@@Type:
7313 wakaba 1.110 DOMMain:boolean
7314 wakaba 1.8 @@@enDesc:
7315     The default value that is returned if no explicit property
7316     value specification found for this resource.
7317     @@Return:
7318     @@@Type:
7319 wakaba 1.110 DOMMain:boolean
7320 wakaba 1.8 @@@enDesc:
7321     The property value.
7322     @@@PerlDef:
7323 wakaba 1.48 if (ref $self->{$propName}) {
7324     $r = $self->{$propName}-><AG::dv|DVValue.value> ? true : false;
7325 wakaba 1.8 $r = $default unless defined $r;
7326     } else {
7327 wakaba 1.48 my $pr = $self-><AG::DISAnyResource.database>
7328     -><M::DISDatabase.getResource> ($propName);
7329     C: {
7330     for (map {$self->{$_}}
7331 wakaba 1.53 grep {$pr->{aliasURI}->{$_} or $pr->{supOf}->{$_}}
7332     (keys %{$pr->{aliasURI}}, keys %{$pr->{supOf}||{}})) {
7333 wakaba 1.48 if (defined $_) {
7334     $r = $_-><AG::dv|DVValue.value> ? true : false;
7335     last C;
7336     }
7337     }
7338     $r = $default;
7339     } # C
7340 wakaba 1.8 }
7341    
7342     @Method:
7343 wakaba 1.2 @@Name: getPropertyText
7344     @@enDesc:
7345     Gets property value text.
7346     @@PropNameParam:
7347     @@Param:
7348     @@@Name:default
7349     @@@Type:
7350 wakaba 1.110 swcfg21:SWCFGString
7351 wakaba 1.2 @@@enDesc:
7352     The default value that is returned if no explicit property
7353     value specification found for this resource.
7354     @@@nullCase:
7355     @@@@enDesc:
7356     No default value supplied; <DOM::null> is returned if
7357     no value specified.
7358     @@Return:
7359     @@@Type:
7360 wakaba 1.110 swcfg21:SWCFGString
7361 wakaba 1.2 @@@enDesc:
7362     The property value string.
7363     @@@nullCase:
7364     @@@@enDesc:
7365     No value nor default value has specified.
7366     @@@PerlDef:
7367 wakaba 1.48 if (defined $self->{$propName}) {
7368     $r = $self->{$propName}-><AG::dv|DVValue.stringValue>;
7369     $r = $default unless defined $r;
7370     } else {
7371     my $pr = $self-><AG::DISAnyResource.database>
7372     -><M::DISDatabase.getResource> ($propName);
7373     C: {
7374     for (map {$self->{$_}}
7375 wakaba 1.53 grep {$pr->{aliasURI}->{$_} or $pr->{supOf}->{$_}}
7376     (keys %{$pr->{aliasURI}}, keys %{$pr->{supOf}||{}})) {
7377 wakaba 1.48 if (defined $_) {
7378     $r = $_-><AG::dv|DVValue.stringValue>;
7379     last C;
7380     }
7381     }
7382 wakaba 1.8 $r = $default;
7383 wakaba 1.48 } # C
7384 wakaba 1.2 }
7385    
7386     @Method:
7387 wakaba 1.48 @@Name: getPropertyTextList
7388     @@enDesc:
7389     Returns a list of property value text.
7390     @@PropNameParam:
7391     @@MediaTypeDefaultParam:
7392     @@Return:
7393 wakaba 1.110 @@@Type: DISPerl|ARRAY
7394 wakaba 1.48 @@@enDesc:
7395     A list of the property value strings.
7396     @@@PerlDef:
7397     my $pr = $self-><AG::DISAnyResource.database>
7398     -><M::DISDatabase.getResource> ($propName);
7399     $r = [map {$_-><AG::dv|DVValue.stringValue>}
7400     map {@$_}
7401     grep {$_}
7402     map {$self->{$_}}
7403 wakaba 1.53 grep {$pr->{aliasURI}->{$_} or $pr->{supOf}->{$_}}
7404     (keys %{$pr->{aliasURI}}, keys %{$pr->{supOf}||{}})];
7405 wakaba 1.48
7406     @Method:
7407 wakaba 1.2 @@Name: getPropertyResource
7408     @@enDesc:
7409     Gets property value resource.
7410     @@PropNameParam:
7411 wakaba 1.10 @@NamedParam:
7412     @@@Name: defaultMediaType
7413     @@@Type: ResourceURI
7414     @@@enDesc:
7415     The URI reference of the default media type which is used
7416     when the property value is retrieved from the source tree
7417     and the source tree element does not have its <Q::dis:ContentType>
7418     attribute specified.
7419     @@@nullCase:
7420     @@@@enDesc:
7421 wakaba 1.68 Defaulted to <Q::DISCore:QName>.
7422 wakaba 1.2 @@Return:
7423 wakaba 1.61 @@@Type: DIS|DISAnyResource
7424 wakaba 1.2 @@@enDesc:
7425     The property value resource.
7426     @@@nullCase:
7427     @@@@enDesc:
7428     No value has specified.
7429 wakaba 1.8 @@@UndeclaredPrefixException:
7430 wakaba 1.2 @@@PerlDef:
7431 wakaba 1.48 __DEEP{
7432     my $v = $self-><M::DISResourceProp.getPropertyValue>
7433     ($propName);
7434     if (UNIVERSAL::isa ($v, <IFName::dv|DVURIValue>)) {
7435 wakaba 1.62 $r = $v-><M::dv|DVURIValue.getResource>
7436 wakaba 1.48 ($self-><AG::DISAnyResource.database>);
7437     }
7438     }__;
7439 wakaba 1.2
7440     @Method:
7441 wakaba 1.10 @@Name: getPropertyResourceList
7442     @@enDesc:
7443     Gets property value resource list.
7444     @@PropNameParam:
7445     @@NamedParam:
7446 wakaba 1.24 @@@Name: recursive
7447     @@@Type:
7448 wakaba 1.110 DOMMain:boolean
7449 wakaba 1.24 @@@enDesc:
7450     Whether property resource values of this resource
7451     should also be included to the returned list or not.
7452     @@NamedParam:
7453 wakaba 1.10 @@@Name: recursiveISA
7454     @@@Type:
7455 wakaba 1.110 DOMMain:boolean
7456 wakaba 1.10 @@@enDesc:
7457 wakaba 1.26 Whether the <Q::dis:ISA> ancestors of the resources
7458     that are property values should also be included in the returned list
7459     or not.
7460     @@@TrueCase:
7461     @@@@enDesc:
7462     If a property value is a resource <VAR::R> and
7463 wakaba 1.103 the resource <VAR::R> does <P::recursiveISAPropName> <VAR::S>, then
7464 wakaba 1.26 the resource <VAR::S> is also a value in the list.
7465     @@@FalseCase:
7466     @@@@enDesc:
7467     Only the resources directly specified as property values is returned.
7468     @@NamedParam:
7469 wakaba 1.103 @@@Name: recursiveISAPropName
7470     @@@Type: DISString
7471     @@@enDesc:
7472     The URI of the property used when the <P::recursiveISA>
7473     option is enabled.
7474     @@@nullCase:
7475     @@@@enDesc:
7476     The default value, <Q::dis|ISA>, is used.
7477     @@NamedParam:
7478 wakaba 1.26 @@@Name: isaRecursive
7479     @@@Type:
7480 wakaba 1.110 DOMMain:boolean
7481 wakaba 1.26 @@@enDesc:
7482     Whether property resource values of <Q::dis:ISA> resources
7483     of this resource should also be included to the returned list or not.
7484     @@@TrueCase:
7485     @@@@enDesc:
7486 wakaba 1.103 If this resource does <P::isaRecursivePropName> another resource
7487 wakaba 1.26 <VAR::S> and the <VAR::S> resource has a <P::propName>
7488     property value of <VAR::R>, then the resource <VAR::R>
7489     is also a value in the list.
7490     @@@FalseCase:
7491     @@@@enDesc:
7492     Only the resource directly specified is the returned.
7493 wakaba 1.10 @@NamedParam:
7494 wakaba 1.103 @@@Name: isaRecursivePropName
7495     @@@Type: DISString
7496 wakaba 1.10 @@@enDesc:
7497 wakaba 1.103 The URI of the property used when the <P::isaRecursive>
7498     option is enabled.
7499 wakaba 1.10 @@@nullCase:
7500     @@@@enDesc:
7501 wakaba 1.103 The default value, <Q::dis|ISA>, is used.
7502 wakaba 1.10 @@Return:
7503     @@@Type: ResourceList
7504     @@@enDesc:
7505     An array reference of the property value resources.
7506     \
7507     {NOTE:: This list is <QUOTE::dead>.
7508     \
7509     }
7510     @@@UndeclaredPrefixException:
7511     @@@PerlDef:
7512     $r = [];
7513 wakaba 1.48 __DEEP{
7514     my $v = $self-><M::DISResourceProp.getPropertyValueList> ($propName);
7515     my $db = $self-><AG::DISAnyResource.database>;
7516     for my $a (@$v) {
7517     if ($a->isa (<IFName::dv|DVURIValue>)) {
7518 wakaba 1.62 push @$r, $a-><M::dv|DVURIValue.getResource> ($db);
7519 wakaba 1.48 }
7520     if ($isaRecursive) {
7521     my $b = $a-><M::dv|DVValue.getProperty>
7522     (<Q::DISCore:stopISARecursive>);
7523     if ($b and $b-><AG::dv|DVValue.value>) {
7524     $isaRecursive = false;
7525 wakaba 1.32 }
7526 wakaba 1.10 }
7527 wakaba 1.48 }
7528     }__;
7529    
7530 wakaba 1.24 if ($recursive) {
7531     __DEEP{
7532 wakaba 1.98 $opt{___recursive_isa_done} ||= {$self-><AG::anyres.uri> => true};
7533 wakaba 1.24 my @p_res = @$r;
7534     for my $p_res (@p_res) {
7535 wakaba 1.98 my $p_res_uri = $p_res-><AG::anyres.uri>;
7536     next if $opt{___recursive_isa_done}->{$p_res_uri};
7537     $opt{___recursive_isa_done}->{$p_res_uri} = true;
7538 wakaba 1.48 push @$r, @{$p_res-><M::DISResourceProp.getPropertyResourceList>
7539 wakaba 1.24 ($propName, recursive => true,
7540     recursive_isa => $recursiveISA,
7541 wakaba 1.103 ___recursive_isa_done => $opt{___recursive_isa_done})};
7542 wakaba 1.24 }
7543     }__;
7544     }
7545 wakaba 1.10 if ($recursiveISA) {
7546     __DEEP{
7547 wakaba 1.103 $recursiveISAPropName = <Q::dis|ISA>
7548     unless defined $recursiveISAPropName;
7549 wakaba 1.98 $opt{___recursive_isa_done} ||= {$self-><AG::anyres.uri> => true};
7550 wakaba 1.10 my @p_res = @$r;
7551     for my $p_res (@p_res) {
7552 wakaba 1.98 my $p_res_uri = $p_res-><AG::anyres.uri>;
7553     next if $opt{___recursive_isa_done}->{$p_res_uri};
7554     $opt{___recursive_isa_done}->{$p_res_uri} = true;
7555 wakaba 1.48 push @$r, @{$p_res-><M::DISResourceProp.getPropertyResourceList>
7556 wakaba 1.103 ($recursiveISAPropName,
7557 wakaba 1.33 recursive => true,
7558 wakaba 1.103 ___recursive_isa_done => $opt{___recursive_isa_done})};
7559 wakaba 1.10 }
7560     }__;
7561     }
7562 wakaba 1.26 if ($isaRecursive) {
7563 wakaba 1.25 __DEEP{
7564 wakaba 1.103 $isaRecursivePropName = <Q::dis|ISA>
7565     unless defined $isaRecursivePropName;
7566 wakaba 1.98 my $self_uri = $self-><AG::anyres.uri>;
7567     $opt{___recursive_isa_done} ||= {$self_uri => true};
7568     $opt{___isa_recursive_done} ||= {$self_uri => true};
7569 wakaba 1.48 my @p_res = @{$self-><M::DISResourceProp.getPropertyResourceList>
7570 wakaba 1.103 ($isaRecursivePropName, recursive_isa => false,
7571 wakaba 1.37 recursive => false,
7572 wakaba 1.26 default_media_type => <Q::dis:TFQNames>)};
7573 wakaba 1.25 for my $p_res (@p_res) {
7574 wakaba 1.98 my $p_res_uri = $p_res-><AG::anyres.uri>;
7575     next if $opt{___isa_recursive_done}->{$p_res_uri};
7576     $opt{___isa_recursive_done}->{$p_res_uri} = true;
7577 wakaba 1.48 push @$r, @{$p_res-><M::DISResourceProp.getPropertyResourceList>
7578 wakaba 1.26 ($propName, recursive_isa => false,
7579     recursive => false,
7580 wakaba 1.37 isa_recursive => true,
7581     ___isa_recursive_done =>
7582 wakaba 1.103 $opt{___isa_recursive_done})};
7583 wakaba 1.25 }
7584     }__;
7585     }
7586 wakaba 1.60
7587     @Method:
7588 wakaba 1.2 @@Name: addPropertyResourceList
7589     @@enDesc:
7590     Adds a resource to a resource-list property value.
7591     \
7592     {ISSUE:: Should an exception be thrown if the property is
7593     not of list?
7594     \
7595     }
7596 wakaba 1.10 \
7597     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
7598     an item clears the list --- i.e. the property values
7599     in the source tree will be ignored. Call
7600     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
7601     before adding to avoid this behavior.
7602     \
7603     }
7604 wakaba 1.2 @@PropNameParam:
7605     @@Param:
7606     @@@Name: res
7607 wakaba 1.47 @@@Type: DISResource
7608     @@@clsActualType: ManakaiDISResourceDefinition
7609 wakaba 1.2 @@@enDesc:
7610     A resource to add.
7611     @@Return:
7612     @@@PerlDef:
7613 wakaba 1.48 if ($self->{$propName}) {
7614     my $uriv;
7615     __CODE{dv|createURI::
7616     $uri => {$res-><AG::DISAnyResource.uri>},
7617     $result => $uriv,
7618 wakaba 1.60 $name => $propName,
7619 wakaba 1.48 }__;
7620     $self->{$propName}-><M::dv|DVList.addItem> ($uriv);
7621     } else {
7622     __CODE{dv|createOrderedList::
7623     $result => {$self->{$propName}},
7624     $type => {<Q::DISCore:URI>},
7625     $base_type => {<Q::DISCore:URI>},
7626     }__;
7627     my $uriv;
7628     __CODE{dv|createURI::
7629     $uri => {$res-><AG::DISAnyResource.uri>},
7630     $result => $uriv,
7631 wakaba 1.60 $name => $propName,
7632 wakaba 1.48 }__;
7633     $self->{$propName}-><M::dv|DVList.addItem> ($uriv);
7634     }
7635    
7636     @Method:
7637     @@Name: addPropertyResourceUList
7638 wakaba 1.52 @@plMName: add_property_resource_ulist
7639 wakaba 1.48 @@enDesc:
7640     Adds a resource to a resource-list property value.
7641     \
7642     {ISSUE:: Should an exception be thrown if the property is
7643     not of list?
7644     \
7645     }
7646     \
7647     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
7648     an item clears the list --- i.e. the property values
7649     in the source tree will be ignored. Call
7650     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
7651     before adding to avoid this behavior.
7652     \
7653     }
7654     @@PropNameParam:
7655     @@Param:
7656     @@@Name: res
7657     @@@Type: DISResource
7658     @@@clsActualType: ManakaiDISResourceDefinition
7659     @@@enDesc:
7660     A resource to add.
7661     @@Return:
7662     @@@PerlDef:
7663     if ($self->{$propName}) {
7664     my $uriv;
7665     __CODE{dv|createURI::
7666     $uri => {$res-><AG::DISAnyResource.uri>},
7667     $result => $uriv,
7668 wakaba 1.60 $name => $propName,
7669 wakaba 1.48 }__;
7670     $self->{$propName}-><M::dv|DVList.addItem> ($uriv);
7671 wakaba 1.25 } else {
7672 wakaba 1.48 __CODE{dv|createUnorderedList::
7673     $result => {$self->{$propName}},
7674     $type => {<Q::DISCore:URI>},
7675     $base_type => {<Q::DISCore:URI>},
7676     }__;
7677     my $uriv;
7678     __CODE{dv|createURI::
7679     $uri => {$res-><AG::DISAnyResource.uri>},
7680     $result => $uriv,
7681 wakaba 1.60 $name => $propName,
7682 wakaba 1.25 }__;
7683 wakaba 1.48 $self->{$propName}-><M::dv|DVList.addItem> ($uriv);
7684 wakaba 1.2 }
7685    
7686 wakaba 1.48 @Method:
7687     @@Name: addPropertyURIUList
7688 wakaba 1.52 @@plMName: add_peoperty_uri_ulist
7689 wakaba 1.48 @@enDesc:
7690     Adds a resource to a resource-list property value.
7691     \
7692     {ISSUE:: Should an exception be thrown if the property is
7693     not of list?
7694     \
7695     }
7696     \
7697     {NOTE:: If the property is not <QUOTE::get>ten ever, adding
7698     an item clears the list --- i.e. the property values
7699     in the source tree will be ignored. Call
7700     <M::ManakaiDISPropertyAccessor.getPropertyResourceList>
7701     before adding to avoid this behavior.
7702     \
7703     }
7704     @@PropNameParam:
7705     @@Param:
7706     @@@Name: uri
7707     @@@Type: AnyURI
7708     @@@enDesc:
7709     A resource to add.
7710     @@Return:
7711     @@@PerlDef:
7712     __DEEP{
7713     if ($self->{$propName}) {
7714     my $uriv;
7715     __CODE{dv|createURI::
7716     $uri => $uri,
7717     $result => $uriv,
7718 wakaba 1.60 $name => $propName,
7719 wakaba 1.48 }__;
7720     $self->{$propName}-><M::dv|DVList.addItem> ($uriv);
7721     } else {
7722     __CODE{dv|createUnorderedList::
7723     $result => {$self->{$propName}},
7724     $type => {<Q::DISCore|URI>},
7725     $base_type => {<Q::DISCore:URI>},
7726     }__;
7727     my $uriv;
7728     __CODE{dv|createURI::
7729     $uri => $uri,
7730     $result => $uriv,
7731 wakaba 1.60 $name => $propName,
7732 wakaba 1.48 }__;
7733     $self->{$propName}-><M::dv|DVList.addItem> ($uriv);
7734     }
7735     }__;
7736     ##DISResourceProp
7737 wakaba 1.84
7738    
7739     ElementTypeBinding:
7740     @Name: TMethods
7741     @ElementType:
7742     dis:ResourceDef
7743     @ShadowContent:
7744     @@DISCore:resourceType:
7745     @@@@: dis|MultipleResource
7746     @@@ForCheck: !ManakaiDOM|ForClass
7747     @@resourceFor: ManakaiDOM|ForClass
7748     @@DISCore:resourceType: DISCore|Resource
7749    
7750     ElementTypeBinding:
7751     @Name: TMethod
7752     @ElementType:
7753     dis:ResourceDef
7754     @ShadowContent:
7755     @@ForCheck: ManakaiDOM|ForClass
7756     @@DISCore:resourceType: DIS|Method
7757    
7758     ElementTypeBinding:
7759     @Name: TAttr
7760     @ElementType:
7761     dis:ResourceDef
7762     @ShadowContent:
7763     @@ForCheck: ManakaiDOM|ForClass
7764     @@DISCore:resourceType: DIS|Attribute
7765 wakaba 1.85
7766    
7767     TMethods:
7768     @TMethod:
7769     @@Name: getErrorInterfaceResource
7770     @@DIS:targetType: dx|Interface
7771     @@Return:
7772     @@@Type: DISAnyResource
7773     @@@PerlDef:
7774     __DEEP{
7775     $r = $self;
7776     }__;
7777     ##dx:Interface
7778 wakaba 1.84
7779     TMethods:
7780     @TMethod:
7781     @@Name: getErrorInterfaceResource
7782     @@DIS:targetType: DISLang|ConstGroup
7783     @@Return:
7784     @@@Type: DISAnyResource
7785     @@@PerlDef:
7786     __DEEP{
7787     my $parent = $self-><AG::DISResource.parentResource>;
7788     if ($parent and
7789     $parent-><M::DISAnyResource.isTypeURI> (<Q::Err|ErrorAny>)) {
7790     $r = $parent;
7791     }
7792     }__;
7793     ##DISLang:ConstGroup
7794 wakaba 1.95
7795     TMethods:
7796     @TMethod:
7797     @@Name: getDOMConfigurationParameterName
7798     @@DIS:targetType: DOMCore|DOMConfigurationParameter
7799     @@Return:
7800     @@@Type: DISString
7801     @@@PerlDef:
7802     __DEEP{
7803     $r = $self-><M::DIS|DISResourceProp.getPropertyText>
7804     (<Q::DOMCore:domConfigurationParameterName>);
7805     unless (defined $r) {
7806     $r = $self-><AG::DISAnyResource.nameURI>;
7807     }
7808     $r = lc $r if defined $r;
7809     }__;
7810     ##DOMCore|DOMConfigurationParameter
7811    
7812     TMethods:
7813     @TMethod:
7814     @@Name: getDOMConfigurationParameterName
7815     @@DIS:targetType: DOMCore|DOMConfigurationParameterApplication
7816     @@Return:
7817     @@@Type: DISString
7818     @@@PerlDef:
7819     __DEEP{
7820     my $cp = $self-><M::DISResourceProp.getPropertyResource>
7821     (<Q::DOMCore:domConfigurationParameter>);
7822     if (defined $cp) {
7823     $r = $cp-><M::DIS|DISResourceProp.getPropertyText>
7824     (<Q::DOMCore:domConfigurationParameterName>);
7825     unless (defined $r) {
7826     $r = $cp-><AG::DISAnyResource.nameURI>;
7827     }
7828     $r = lc $r if defined $r;
7829     } else {
7830     $r = null; # error
7831     }
7832     }__;
7833     ##DOMCore|DOMConfigurationParameterApplication
7834 wakaba 1.84
7835     TMethods:
7836     @TMethod:
7837     @@Name: getErrorInterfaceResource
7838     @@DIS:targetType: dx|ErrorCode
7839     @@Return:
7840     @@@Type: DISAnyResource
7841     @@@PerlDef:
7842     __DEEP{
7843     my $parent = $self-><AG::DISResource.parentResource>;
7844     if ($parent) {
7845     $r = $parent-><M::DISAnyResource.getErrorInterfaceResource>;
7846     }
7847     }__;
7848     ##dx:ErrorCode
7849    
7850     TMethods:
7851     @TMethod:
7852     @@Name: getErrorInterfaceResource
7853     @@DIS:targetType: dx|ErrorSubCode
7854     @@Return:
7855     @@@Type: DISAnyResource
7856     @@@PerlDef:
7857     __DEEP{
7858     my $parent = $self-><M::DISAnyResource.getErrorCodeResource>;
7859     if ($parent) {
7860     $r = $parent-><M::DISAnyResource.getErrorInterfaceResource>;
7861     }
7862     }__;
7863    
7864     @TMethod:
7865     @@Name: getErrorCodeResource
7866     @@DIS:targetType: dx|ErrorSubCode
7867     @@Return:
7868     @@@Type: DISAnyResource
7869     @@@PerlDef:
7870     __DEEP{
7871     my $parent = $self-><AG::DISResource.parentResource>;
7872     if ($parent and $parent-><M::DISAnyResource.isTypeURI>
7873     (<Q::dx|ErrorCode>)) {
7874     $r = $parent;
7875     }
7876     }__;
7877     ##dx:ErrorSubCode
7878 wakaba 1.101
7879     TMethods:
7880     @TMethod:
7881     @@Name: parseString
7882     @@DIS:targetType: lang|dcmodel
7883     @@Param:
7884     @@@Name: s
7885     @@@Type: DISString
7886     @@Param:
7887     @@@Name: ns
7888     @@@Type: NSResolverDIS
7889     @@Param:
7890     @@@Name: factory
7891     @@@Type: Document
7892 wakaba 1.102 @@ForParam:
7893 wakaba 1.101 @@Return:
7894     @@@Type: Node
7895     @@@PerlDef:
7896     __DEEP{
7897     $s =~ s/^\s+//;
7898     if ($s =~ s/^([^\s(][^\s+*?]*)\s*//) {
7899     $r = $factory-><M::Document.createElementNS>
7900     (<Q::lang|dcmodel:>, 'terminal');
7901     my $uri = $ns-><M::NSResolverDIS.tfqnamesToURI>
7902 wakaba 1.102 ($1, null, $forArg);
7903 wakaba 1.101 $r-><AS::Node.textContent> ($uri);
7904     if ($s =~ s/^([+*?])\s*//) {
7905     $r-><M::Element.setAttributeNS> (null, 'occurence', $1);
7906     }
7907     } else {
7908     $s =~ s/^\(\s*//;
7909     $r = $factory-><M::Document.createElementNS>
7910     (<Q::lang|dcmodel:>, 'group');
7911     my $current = $r;
7912     my $last;
7913     while (length $s) {
7914     if ($s =~ s/^([^\s()+*?|,&][^\s)+*?,&]*|[+*?|,&][^\s)+*?,&]+)\s*//) {
7915     my $el = $factory-><M::Document.createElementNS>
7916     (<Q::lang|dcmodel:>, 'terminal');
7917 wakaba 1.102 my $uri = $ns-><M::NSResolverDIS.tfqnamesToURI>
7918     ($1, null, $forArg, node => $ns);
7919 wakaba 1.101 $el-><AS::Node.textContent> ($uri);
7920     $current-><M::Node.appendChild> ($el);
7921     $last = $el;
7922     } elsif ($s =~ s/^([+*?])\s*//) {
7923     if (defined $last) {
7924     $last-><M::Element.setAttributeNS> (null, 'occurence', $1);
7925     $last = null;
7926     }
7927     } elsif ($s =~ s/^([|,&])\s*//) {
7928     $current-><M::Element.setAttributeNS> (null, 'connector', $1);
7929     $last = null;
7930     } elsif ($s =~ s/^\(\s*//) {
7931     my $el = $factory-><M::Document.createElementNS>
7932     (<Q::lang|dcmodel:>, 'group');
7933     $current = $current-><M::Node.appendChild> ($el);
7934     $last = null;
7935     } elsif ($s =~ s/^\)\s*//) {
7936     $last = $current;
7937     $current = $current-><AG::Node.parentNode>;
7938     $current = $last unless defined $current; # error
7939     } else {
7940     last; # error
7941     }
7942     }
7943     }
7944     }__;
7945     ##lang:dcmodel
7946 wakaba 1.48
7947 wakaba 1.3 ElementTypeBinding:
7948     @Name: PropNameParam
7949     @ElementType:
7950     dis:ResourceDef
7951     @ShadowContent:
7952     @@rdf:type:
7953     DISLang:MethodParameter
7954     @@Name: propName
7955     @@Type: ResourceURI
7956     @@Description:
7957     @@@lang:en
7958     @@@@:
7959     The name of the property.
7960    
7961 wakaba 1.2 PropDef:
7962     @QName:isAnon
7963     @Description:
7964     @@lang:en
7965     @@@:
7966     Whether the subject resource is anonymous or not.
7967     @Type:
7968 wakaba 1.110 DOMMain:boolean
7969 wakaba 1.2
7970     PropDef:
7971     @QName:isDefined
7972     @Description:
7973     @@lang:en
7974     @@@:
7975     Whether the subject resource is defined or not.
7976    
7977     PropDef:
7978 wakaba 1.3 @QName:isReferred
7979 wakaba 1.2 @Description:
7980     @@lang:en
7981     @@@:
7982     Whether the subject resource is referred or not.
7983     @Type:
7984     DOMMain:any
7985    
7986     PropDef:
7987     @QName:definingModule
7988     @Description:
7989     @@lang:en
7990     @@@:
7991     The <QUOTE::dis> module in which the subject resource is defined.
7992 wakaba 1.22 \
7993     {NOTE:: The local name should have been <QUOTE::ownerModule> or some.
7994     \
7995     }
7996 wakaba 1.2 @rdfs:domain:
7997     DISCore:Module
7998 wakaba 1.1
7999     ## -- Datatypes
8000    
8001     URITypeDef:
8002 wakaba 1.3 @QName: AnyURI
8003     @Description:
8004     @@lang:en
8005     @@@:
8006     Any URI references.
8007    
8008     URITypeDef:
8009     @QName: FileURI
8010     @enDesc:
8011     URI references identifying file.
8012    
8013     URITypeDef:
8014 wakaba 1.1 @QName: ForURI
8015     @Description:
8016     @@lang:en
8017     @@@:
8018     <QUOTE::For> URI references.
8019    
8020     DataTypeDef:
8021     @QName: ForURIList
8022     @Description:
8023     @@lang:en
8024     @@@:
8025     References to the array containing <QUOTE::for> URI references.
8026    
8027     URITypeDef:
8028 wakaba 1.3 @QName: ResourceURI
8029     @Description:
8030     @@lang:en
8031     @@@:
8032     A URI reference for a <QUOTE::dis> resource.
8033    
8034     URITypeDef:
8035 wakaba 1.1 @QName: MediaTypeURI
8036     @Description:
8037     @@lang:en
8038     @@@:
8039     Media type URI references.
8040 wakaba 1.3 @rdfs:subClassOf: ResourceURI
8041    
8042     URITypeDef:
8043     @QName: ModuleURI
8044     @enDesc:
8045 wakaba 1.47 URI references for <QUOTE::dis> modules.
8046 wakaba 1.3 @rdfs:subClassOf: ResourceURI
8047    
8048     URITypeDef:
8049     @QName: NameURI
8050     @enDesc:
8051     URI references identifying a resource.
8052     @rdfs:subClassOf: ResourceURI
8053 wakaba 1.10
8054     DataTypeDef:
8055     @QName: ResourceList
8056     @enDesc:
8057     References to array containing resource definition objects.
8058     @rdfs:subClassOf:
8059 wakaba 1.110 DISPerl:ARRAY
8060 wakaba 1.3
8061     ElementTypeBinding:
8062     @Name: DataTypeDef
8063     @ElementType:
8064     dis:ResourceDef
8065     @ShadowContent:
8066     @@rdf:type:
8067     ManakaiDOM:DataType
8068    
8069     ElementTypeBinding:
8070     @Name: URITypeDef
8071     @ElementType:
8072     dis:ResourceDef
8073     @ShadowContent:
8074     @@rdf:type:
8075     ManakaiDOM:DataType
8076     @@rdfs:subClassOf: AnyURI
8077 wakaba 1.1
8078     ## -- Exceptions
8079    
8080     XParamDef:
8081 wakaba 1.5 @QName: anotherSourceNode
8082     @enDesc:
8083     Another source node in which an error has occurred. In cases
8084     of <QUOTE::already defined> errors, it is the node that
8085     defines the resource first.
8086     @Type: ManakaiDISNode
8087 wakaba 1.3
8088 wakaba 1.12 ResourceDef:
8089 wakaba 1.98 @QName: anyres
8090     @AliasFor: DISAnyResource
8091    
8092     ResourceDef:
8093 wakaba 1.47 @rdf:type:
8094     @@@: dis|MultipleResource
8095     @@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass
8096     @resourceFor: ManakaiDOM|ForIF
8097     @resourceFor:
8098     @@@: ManakaiDOM|ForClass
8099    
8100     @rdf:type:
8101 wakaba 1.63 @@@: dx|Interface
8102 wakaba 1.47 @@ForCheck: ManakaiDOM|ForIF
8103    
8104     @rdf:type:
8105 wakaba 1.63 @@@: dx|Class
8106 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
8107    
8108     @Implement:
8109 wakaba 1.110 @@@: ||+||ManakaiDOM|ForIF
8110 wakaba 1.47 @@ContentType: DISCore|TFPQNames
8111 wakaba 1.110 @@ForCheck: ManakaiDOM|ForClass
8112     @dx:implementedBy: ||+||ManakaiDOM|ForClass
8113 wakaba 1.47
8114 wakaba 1.63 @f:implements:
8115 wakaba 1.47 @@@: CoreFeature10
8116    
8117     @ISA:
8118 wakaba 1.110 @@@: dx|Exception
8119 wakaba 1.47 @@ForCheck: ManakaiDOM|ForClass
8120    
8121     @IFQName: DISException
8122 wakaba 1.3 @ClsQName: ManakaiDISException
8123 wakaba 1.47
8124     @Description:
8125     @@lang:en
8126     @@@:
8127     Exceptions for the <QUOTE::dis> operations.
8128    
8129     @ResourceDef:
8130 wakaba 1.63 @@rdf:type: DISLang|ConstGroup
8131 wakaba 1.110 @@ForCheck: ManakaiDOM|ForIF
8132 wakaba 1.47
8133     @@IFQName: DISExceptionCode
8134    
8135 wakaba 1.110 @@rdfs:subClassOf: idl|unsignedShort
8136     @@Type: idl|unsignedShort
8137 wakaba 1.47
8138 wakaba 1.3 @@enDesc:
8139 wakaba 1.63 Exception codes for <Class::DISException>.
8140 wakaba 1.47
8141 wakaba 1.3 @@XConstDef:
8142 wakaba 1.11 @@@Name: HIERARCHY_REQUEST_ERR
8143 wakaba 1.49 @@@Value:
8144     @@@@@:3
8145     @@@@ContentType: DISCore|Integer
8146 wakaba 1.11 @@@enDesc:
8147     An attempt is made to break the hierarchy.
8148     @@@XSubTypeDef:
8149     @@@@QName: MERGE_ITSELF_ERR
8150     @@@@enDesc:
8151     An attempt is made to merge the resource to itself.
8152     @@@@XSourceNodeParam:
8153     @@@@XParam:
8154     @@@@@QName:uri
8155     @@@@@enDesc:
8156     The URI reference of the resource to merge.
8157     @@@@enMufDef:
8158     An attempt is made to merge the resource <%p (name => {<Q::DIS:uri>}
8159     );> to itself
8160     @@XConstDef:
8161 wakaba 1.8 @@@Name: NOT_SUPPORTED_ERR
8162 wakaba 1.49 @@@Value:
8163     @@@@@:9
8164     @@@@ContentType: DISCore|Integer
8165 wakaba 1.8 @@@enDesc:
8166     An attempt is made to do something the implementation does not support.
8167     @@@XSubTypeDef:
8168     @@@@QName: UNSUPPORTED_MEDIA_TYPE_ERR
8169     @@@@enDesc:
8170     The implementation does not support the media type.
8171     @@@@XParam:
8172     @@@@@QName: uri
8173     @@@@@enDesc:
8174     The URI reference of the media type that is not supported.
8175     @@@@XSourceNodeParam:
8176 wakaba 1.30 @@@@XParam:
8177     @@@@@QName:elementType
8178     @@@@@enDesc:
8179     The URI reference of the element type of the element
8180     in which the media type is referenced.
8181 wakaba 1.12 @@@@enMufDef:
8182 wakaba 1.30 %p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": }
8183     );%p (name => {<Q::DIS:elementType>}, prefix => { (Element type: <},
8184     suffix => {>) }
8185     );Media type <%p (name => {<Q::DIS:uri>});> is not supported
8186 wakaba 1.3 @@@XSubTypeDef:
8187 wakaba 1.13 @@@@QName: UNSUPPORTED_ELEMENT_TYPE_ERR
8188     @@@@enDesc:
8189     An unsupported type of element is encounted.
8190     @@@@XSourceNodeParam:
8191     @@@@XParam:
8192     @@@@@QName:elementType
8193     @@@@@enDesc:
8194     The element type URI reference of the element.
8195 wakaba 1.16 @@@@enMufDef:
8196     Element type "%p (name => {<Q::DIS:elementType>});" is not supported
8197 wakaba 1.3 @@XConstDef:
8198     @@@Name: INVALID_STATE_ERR
8199 wakaba 1.49 @@@Value:
8200     @@@@@:11
8201     @@@@ContentType: DISCore|Integer
8202 wakaba 1.3 @@@enDesc:
8203     An attempt is made to use an object that is not (or no longer) usable.
8204     @@@XSubTypeDef:
8205     @@@@QName: NO_ASSOCIATED_DB_ERR
8206     @@@@enDesc:
8207     No <QUOTE::dis> database has been associated with this document.
8208 wakaba 1.4 @@XConstDef:
8209     @@@Name: INVALID_SOURCE_ERR
8210 wakaba 1.49 @@@Value:
8211 wakaba 1.63 @@@@@: 501
8212 wakaba 1.49 @@@@ContentType: DISCore|Integer
8213 wakaba 1.4 @@@enDesc:
8214     The source input is well-formed but invalid.
8215     @@@XSubTypeDef:
8216     @@@@QName: NO_MODULE_QNAME_ERR
8217     @@@@enDesc:
8218     The <Q::dis:Module> element must have its <Q::dis:QName>
8219     attribute.
8220 wakaba 1.8 @@@@XSourceNodeParam:
8221     @@@XSubTypeDef:
8222     @@@@QName: NO_LOCAL_NAME_ERR
8223     @@@@enDesc:
8224     The resource does not have a local name.
8225     @@@@XSourceNodeParam:
8226 wakaba 1.4 @@@XSubTypeDef:
8227     @@@@QName: UNABLE_TO_GET_MODULE_ERR
8228     @@@@enDesc:
8229     The implementation is unable to get the module source.
8230 wakaba 1.68 @@@@enMufDef:
8231 wakaba 1.4 Unable to get the module source of <%p (name => {<Q::DIS:uri>});>
8232     @@@@XParam:
8233     @@@@@QName: uri
8234     @@@@@enDesc:
8235     The URI reference of the module.
8236     @@@@XParam:
8237     @@@@@QName: namespaceURI
8238     @@@@@enDesc:
8239     The namespace URI of the module name.
8240     @@@@XParam:
8241     @@@@@QName: localName
8242     @@@@@enDesc:
8243     The local name of the module name.
8244     @@@@XParam:
8245     @@@@@QName: for
8246     @@@@@enDesc:
8247     The <QUOTE::for> of the module.
8248 wakaba 1.5 @@@XSubTypeDef:
8249     @@@@QName: NO_FOR_QNAME_ERR
8250     @@@@enDesc:
8251     A <Q::dis:ForDef> element must have <Q::dis:QName> attribute.
8252     @@@@XSourceNodeParam:
8253     @@@XSubTypeDef:
8254     @@@@QName: FOR_ALREADY_DEFINED_ERR
8255     @@@@enDesc:
8256     The <QUOTE::for> named as the same URI reference has
8257     already defined.
8258     @@@@XSourceNodeParam:
8259     @@@@XParam:
8260     @@@@@QName: anotherSourceNode
8261     @@@@@enDesc:
8262     The node that defines the <QUOTE::for> URI reference before.
8263 wakaba 1.7 @@@@XParam:
8264     @@@@@Name: uri
8265     @@@@@enDesc:
8266     The URI reference of the <QUOTE::for> attempted to define.
8267     @@@@enMufDef:
8268     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is already defined
8269 wakaba 1.5 @@@XSubTypeDef:
8270     @@@@QName: RESOURCE_ALREADY_DEFINED_ERR
8271     @@@@enDesc:
8272     The <QUOTE::dis> resource named as the same URI reference has
8273     already defined.
8274     @@@@XSourceNodeParam:
8275     @@@@XParam:
8276 wakaba 1.54 @@@@@@: anotherSourceNode
8277 wakaba 1.5 @@@@@enDesc:
8278     The node that defines the <QUOTE::for> URI reference before.
8279 wakaba 1.7 @@@@XParam:
8280 wakaba 1.54 @@@@@@: uri
8281 wakaba 1.7 @@@@@enDesc:
8282     The URI reference of the resource attempted to define.
8283 wakaba 1.54 @@@@XParam:
8284     @@@@@@: moduleURI
8285     @@@@@enDesc:
8286     A URI of the module in which the <Q::DIS|uri> resource is
8287     defined.
8288 wakaba 1.7 @@@@enMufDef:
8289 wakaba 1.54 %p (name => {<Q::DIS:moduleURI>}, prefix => {Module <},
8290     suffix => {>: })
8291     ;Resource <%p (name => {<Q::DIS:uri>});> is already defined
8292 wakaba 1.5 @@@XSubTypeDef:
8293     @@@@QName: ELEMENT_NOT_ALLOWED_ERR
8294     @@@@enDesc:
8295     An element has occured where it is not allowed.
8296     @@@@enMufDef:
8297     Module <%p (name => {<Q::DIS:uri>});>:
8298     Element of type <%p (name => {<Q::DIS:elementType>});>
8299     is not allowed here
8300     @@@@XSourceNodeParam:
8301     @@@@XParam:
8302     @@@@@QName: elementType
8303     @@@@@enDesc:
8304     The expanded element type name of the element.
8305     @@@@XParam:
8306     @@@@@QName: uri
8307     @@@@@enDesc:
8308     The URI reference of the module.
8309 wakaba 1.7 @@@XSubTypeDef:
8310     @@@@QName: NO_REQUIRED_ATTR_ERR
8311     @@@@enDesc:
8312     A required attribute is not specified.
8313     @@@@XSourceNodeParam:
8314     @@@@XParam:
8315     @@@@@QName: elementType
8316     @@@@@enDesc:
8317     The expanded URI reference of the attribute name.
8318     @@@@enMufDef:
8319     Attribute <%p (name => {<Q::DIS:elementType>});> must be specified
8320 wakaba 1.8 @@@XSubTypeDef:
8321     @@@@QName: FOR_NOT_DEFINED_ERR
8322     @@@@enDesc:
8323     A <QUOTE::for> is referred but not defined.
8324     @@@@XSourceNodeParam:
8325     @@@@XParam:
8326     @@@@@QName: uri
8327     @@@@@enDesc:
8328     The URI reference of the <QUOTE::for> that is not defined.
8329     @@@@enMufDef:
8330     <QUOTE::For> <%p (name => {<Q::DIS:uri>});> is not defined
8331     @@@XSubTypeDef:
8332     @@@@QName: RESOURCE_NOT_DEFINED_ERR
8333     @@@@enDesc:
8334 wakaba 1.13 A <QUOTE::dis> resource is referred but not defined
8335     or the resource referred does not have the type expected.
8336 wakaba 1.8 @@@@XSourceNodeParam:
8337     @@@@XParam:
8338 wakaba 1.48 @@@@@@: sourceNodePath
8339     @@@@@enDesc:
8340     A node path string of the source node.
8341     @@@@XParam:
8342 wakaba 1.8 @@@@@QName: uri
8343     @@@@@enDesc:
8344     The URI reference of the resource that is not defined.
8345 wakaba 1.13 @@@@XParam:
8346     @@@@@QName: elementType
8347     @@@@@enDesc:
8348     <QUOTE::dis> element type (either tree element type
8349     or preprocessing element type) of the element
8350     in which a reference to the undefined resource is contained.
8351     @@@@XParam:
8352 wakaba 1.30 @@@@@QName:parentURI
8353     @@@@@enDesc:
8354     The URI reference of the resource from whose child resources
8355     a resource is tried to find.
8356     @@@@XParam:
8357 wakaba 1.54 @@@@@QName: moduleURI
8358     @@@@@enDesc:
8359     The URI of the module in which the resourece should be included.
8360     @@@@XParam:
8361 wakaba 1.13 @@@@@QName: localName
8362     @@@@@enDesc:
8363     The local name of the undefined resource.
8364     @@@@XParam:
8365     @@@@QName: sourceCode
8366     @@@@enDesc:
8367     Source code fragment that referres this resource.
8368     @@@@XParam:
8369     @@@@@QName:expectedType
8370     @@@@@enDesc:
8371     Expected resource type.
8372 wakaba 1.8 @@@@enMufDef:
8373 wakaba 1.54 %p (name => {<Q::DIS:moduleURI>}, prefix => {Module <},
8374     suffix => {>: })
8375     ;%p (name => {<Q::DIS:sourceNodePath>}, suffix => {: })
8376     ;%p (name => {<Q::DIS:sourceCode>}, prefix => {"}, suffix => {": })
8377     ;%p (name => {<Q::DIS:parentURI>}, prefix => {(In <}, suffix => {>) })
8378     ;Resource%p (name => {<Q::DIS:uri>}, prefix => { <},
8379 wakaba 1.13 suffix => {>});%p (name => {<Q::DIS:localName>},
8380     prefix => { "}, suffix => {"}); is not defined or wrong type%p
8381     (name => {<Q::DIS:expectedType>}, prefix => { (<},
8382     suffix => {> is expected)});
8383     @@@XSubTypeDef:
8384     @@@@QName: NO_SOURCE_NODE_ERR
8385     @@@@enDesc:
8386     A resource does not have associated node in the source tree.
8387     @@@@XSourceNodeParam:
8388     @@@@XParam:
8389     @@@@@QName:uri
8390     @@@@@enDesc:
8391     The URI reference of the resource.
8392 wakaba 1.8 @@@XSubTypeDef:
8393     @@@@QName: RESERVED_PERL_METHOD_NAME_ERR
8394     @@@@enDesc:
8395     A reserved Perl method name is used.
8396     @@@@XParam:
8397     @@@@@QName:uri
8398     @@@@@enDesc:
8399     The URI reference of the method resource.
8400     @@@@XSourceNodeParam:
8401     @@@@XParam:
8402     @@@@@QName: generatedName
8403     @@@@@enDesc:
8404     A reserved method name.
8405     @@@XSubTypeDef:
8406     @@@@QName: NO_DIS_TYPE_ERR
8407     @@@@enDesc:
8408     <Q::dis:Type> attribute is not found.
8409     @@@@XSourceNodeParam:
8410 wakaba 1.48 @@@@enMufDef:
8411     Resource "%t (name => {<Q::DIS:uri>});" has no "dis:Type" attribute
8412 wakaba 1.12 @@@XSubTypeDef:
8413     @@@@QName: NO_METHOD_RETURN_ERR
8414     @@@@enDesc:
8415     A <Q::DISLang:Method> resource does not have any
8416     <Q::DISLang:MethodReturn> child.
8417     @@@@XSourceNodeParam:
8418 wakaba 1.22 @@@@XParam:
8419     @@@@@QName:errResource
8420     @@@@@enDesc: The method resource.
8421     @@@@XParam:
8422     @@@@@QName:uri
8423     @@@@@enDesc:
8424     The URI reference of the method.
8425     @@@@XParam:
8426     @@@@@QName:localName
8427     @@@@@enDesc:
8428     The local name of the resource.
8429     @@@@enMufDef:
8430     Method "%p (name => {<Q::DIS:localName>});" does not have
8431     "Return" child
8432 wakaba 1.12 @@@XSubTypeDef:
8433     @@@@QName: NO_ATTR_GET_ERR
8434     @@@@enDesc:
8435     A <Q::DISLang:Attribute> resource does not have any
8436     <Q::DISLang:AttributeGet> child.
8437     @@@@XSourceNodeParam:
8438 wakaba 1.13 @@@XSubTypeDef:
8439     @@@@QName:INTERFACE_CLASS_METHOD_ERR
8440     @@@@enDesc:
8441     An attempt is made to call a static (class) method
8442     from an interface.
8443     @@@@XSourceNodeParam:
8444     @@@@XParam:
8445     @@@@@QName:uri
8446     @@@@@enDesc:
8447     The URI reference of the interface.
8448     @@@@XParam:
8449     @@@@@QName:sourceCode
8450     @@@@@enDesc:
8451     Source code fragment that calls a class method.
8452     @@@@XParam:
8453     @@@@@QName:elementType
8454     @@@@@enDesc:
8455     The element type URI reference of the element
8456     that calls a method.
8457     @@@XSubTypeDef:
8458     @@@@QName: BROKEN_PARAM_SPEC_ERR
8459     @@@@enDesc:
8460     A parameter specification is broken.
8461     @@@@XParam:
8462     @@@@@QName: sourceCode
8463     @@@@@enDesc:
8464     Source code fragment that contains the broken parameter
8465     specification.
8466     @@@@XSourceNodeParam:
8467 wakaba 1.15 @@@@enMufDef:
8468     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
8469     suffix => {": });Broken parameter specification
8470 wakaba 1.13 @@@XSubTypeDef:
8471     @@@@QName:PERL_PREPROCESS_NO_ELEMENT_TYPE_ERR
8472     @@@@enDesc:
8473     A preprocessing instruction does not have its element
8474     type.
8475     @@@@XSourceNodeParam:
8476     @@@@XParam:
8477     @@@@@QName:sourceCode
8478     @@@@@enDesc:
8479     Source code fragment.
8480 wakaba 1.16 @@@@enMufDef:
8481     %p (name => {<Q::DIS:sourceCode>}, prefix => {"},
8482     suffix => {": });Element type name is not specified
8483 wakaba 1.13 @@@XSubTypeDef:
8484 wakaba 1.15 @@@@QName: NO_PERL_PACKAGE_NAME_ERR
8485 wakaba 1.13 @@@@enDesc:
8486 wakaba 1.15 No Perl package name is defined for the resource referred.
8487 wakaba 1.13 @@@@XSourceNodeParam:
8488     @@@@XParam:
8489 wakaba 1.15 @@@@@QName:sourceCode
8490 wakaba 1.13 @@@@@enDesc:
8491     Source code fragment.
8492     @@@@XParam:
8493 wakaba 1.15 @@@@@QName:uri
8494     @@@@@enDesc:
8495     THe URI reference of the resource referred.
8496     @@@@XParam:
8497     @@@@@QName:elementType
8498     @@@@@enDesc:
8499     The element type of Perl preprocessing instruction
8500     in which the resource is referred.
8501     @@@@enMufDef:
8502     %p (name => {<Q::DIS:uri>}, prefix => {<}, suffix => {>: });Perl
8503     package name is not defined
8504     @@@XSubTypeDef:
8505     @@@@QName: PERL_PREPROCESS_NO_EXCEPTION_TYPE_ERR
8506     @@@@enDesc:
8507     An exception type specification is required.
8508     @@@@XSourceNodeParam:
8509     @@@@XSourceCodeParam:
8510     @@@@XParam:
8511     @@@@@QName:elementType
8512     @@@@@enDesc:
8513     The element type of the preprocessing instruction.
8514     @@@XSubTypeDef:
8515     @@@@QName: PERL_PREPROCESS_NO_CODE_NAME_ERR
8516     @@@@enDesc:
8517     A code name specification is required.
8518     @@@@XSourceNodeParam:
8519     @@@@XSourceCodeParam:
8520     @@@@XParam:
8521 wakaba 1.13 @@@@@QName:elementType
8522     @@@@@enDesc:
8523 wakaba 1.15 The element type of the preprocessing instruction.
8524 wakaba 1.13 @@@XSubTypeDef:
8525     @@@@QName: PERL_CODE_NOT_DEFINED_ERR
8526     @@@@enDesc:
8527 wakaba 1.15 The specified resource does not have its Perl definition.
8528 wakaba 1.13 @@@@XSourceNodeParam:
8529 wakaba 1.15 @@@@XSourceCodeParam:
8530 wakaba 1.13 @@@@XParam:
8531 wakaba 1.15 @@@@@QName:elementType
8532     @@@@@enDesc:
8533     The element type of the preprocessing instruction.
8534     @@@@XParam:
8535     @@@@@QName:uri
8536 wakaba 1.13 @@@@@enDesc:
8537 wakaba 1.15 The URI reference of the resource referred.
8538 wakaba 1.13 @@@@XParam:
8539     @@@@@QName:localName
8540     @@@@@enDesc:
8541     The local name of the resource referred.
8542 wakaba 1.51 @@@@enMufDef:
8543     Resource%p (name => {<Q::DIS:uri>}, prefix => { "}, suffix => {"});
8544     has no Perl code definition
8545 wakaba 1.15 @@@XSubTypeDef:
8546     @@@@QName: PERL_PREPROCESS_NO_METHOD_ERR
8547     @@@@enDesc:
8548     A preprocessing instruction which is only allowed in
8549     method definitions is used in a code which is not a method.
8550     @@@@XSourceNodeParam:
8551     @@@@XSourceCodeParam:
8552 wakaba 1.13 @@@@XParam:
8553 wakaba 1.15 @@@@@QName:elementType
8554 wakaba 1.13 @@@@@enDesc:
8555 wakaba 1.15 The element type of the preprocessing instruction.
8556 wakaba 1.14 @@@XSubTypeDef:
8557 wakaba 1.15 @@@@QName: PERL_PREPROCESS_NO_FOR_ERR
8558 wakaba 1.14 @@@@enDesc:
8559 wakaba 1.15 A <QUOTE::for> specification is required.
8560 wakaba 1.14 @@@@XSourceNodeParam:
8561 wakaba 1.15 @@@@XSourceCodeParam:
8562 wakaba 1.14 @@@@XParam:
8563 wakaba 1.15 @@@@@QName:elementType
8564 wakaba 1.14 @@@@@enDesc:
8565 wakaba 1.15 The element type of the preprocessing instruction.
8566     @@@XSubTypeDef:
8567     @@@@QName: PERL_PREPROCESS_NO_ASSERT_TYPE_ERR
8568     @@@@enDesc:
8569     An assertion type specification is required.
8570     @@@@XSourceNodeParam:
8571     @@@@XSourceCodeParam:
8572 wakaba 1.14 @@@@XParam:
8573 wakaba 1.15 @@@@@QName:elementType
8574 wakaba 1.14 @@@@@enDesc:
8575 wakaba 1.15 The element type of the preprocessing instruction.
8576     @@@XSubTypeDef:
8577     @@@@QName: PERL_PREPROCESS_BLOCK_NOT_ALLOWED_ERR
8578     @@@@enDesc:
8579     A preprocessing instruction block occurred with
8580     element type which does not allow it.
8581     @@@@XSourceNodeParam:
8582     @@@@XSourceCodeParam:
8583 wakaba 1.14 @@@@XParam:
8584     @@@@@QName:elementType
8585     @@@@@enDesc:
8586 wakaba 1.15 The element type of the preprocessing instruction.
8587 wakaba 1.18 @@@XSubTypeDef:
8588     @@@@QName: NON_NAMED_PARAMETER_AFTER_NAMED_ERR
8589     @@@@enDesc:
8590     A non-named method parameter following
8591     any named method parameter is occurred.
8592     @@@@XSourceNodeParam:
8593     @@@@XParam:
8594     @@@@@QName:uri
8595     @@@@@enDesc:
8596     The URI reference of the non-named method parameter resource.
8597     @@@@XParam:
8598     @@@@@QName:localName
8599     @@@@@enDesc:
8600     The local name of the non-named method parameter.
8601 wakaba 1.19 @@@XSubTypeDef:
8602     @@@@QName:DISPERL_NO_VALUE_ALLOWED_ERR
8603     @@@@enDesc:
8604     An element node have a value but the definition
8605     of that element type does not allow it.
8606     @@@@XSourceNodeParam:
8607     @@@@XParam:
8608     @@@@@QName:elementType
8609     @@@@@enDesc:
8610     The element type URI reference of the element.
8611     @@@XSubTypeDef:
8612     @@@@QName:NO_CONST_VALUE_ERR
8613     @@@@enDesc:
8614     The source element node for a constant value resource
8615     does not have <Q::dis:Value> attribute.
8616     @@@@XSourceNodeParam:
8617     @@@@XParam:
8618     @@@@@QName:elemntType
8619     @@@@@enDesc:
8620     The element type URI reference of the element from which
8621     a constant value resource is referred.
8622     @@@@XParam:
8623     @@@@@QName:uri
8624     @@@@@enDesc:
8625     The resource URI reference of the constant value resource.
8626     @@@@XParam:
8627     @@@@@QName:localName
8628     @@@@@enDesc:
8629     The local name of the constant value resource.
8630     @@@XSubTypeDef:
8631     @@@@QName:NO_ATTR_SET_ERR
8632     @@@@enDesc:
8633     An attribute setter is referred but the attribute
8634     does not define any setter.
8635     @@@@XSourceNodeParam:
8636     @@@@XParam:
8637     @@@@@QName:errResource
8638     @@@@@enDesc:
8639     The attribute resource.
8640     @@@@XParam:
8641     @@@@@QName:elementType
8642     @@@@@enDesc:
8643     The type of the element by which this attribute
8644     is referred.
8645 wakaba 1.20 @@@XSubTypeDef:
8646     @@@@QName: PERL_SUBROUTINE_ALREADY_DEFINED_ERR
8647     @@@@enDesc:
8648     A resource defines a Perl subroutine whose name is
8649     same as another subroutine.
8650     @@@@XSourceNodeParam:
8651     @@@@XParam:
8652     @@@@@QName:uri
8653     @@@@@enDesc:
8654     The URI reference of the resource that defines the Perl subroutine.
8655     @@@@XParam:
8656     @@@@@QName:
8657     PerlCode:localName
8658     @@@@@enDesc:
8659     The name of the Perl subroutine.
8660     @@@XSubTypeDef:
8661     @@@@QName: PERL_OPERATOR_ALREADY_OVERLOADED_ERR
8662     @@@@enDesc:
8663     A resource is defined to overload a Perl operator which
8664     is already overloaded by another resource.
8665     @@@@XSourceNodeParam:
8666     @@@@XParam:
8667     @@@@@QName:uri
8668     @@@@@enDesc:
8669     The URI reference of the resource that defines the overloading.
8670     @@@@XParam:
8671     @@@@@QName:
8672     PerlCode:operator
8673     @@@@@enDesc:
8674     The operator.
8675     @@@XSubTypeDef:
8676     @@@@QName: PERL_UNUSED_SUBROUTINE_ERR
8677     @@@@enDesc:
8678     A resource defines a Perl subroutine but it is not used.
8679     @@@@XSourceNodeParam:
8680     @@@@XParam:
8681     @@@@@QName:uri
8682     @@@@@enDesc:
8683     The URI reference of the resource.
8684 wakaba 1.22 @@@XSubTypeDef:
8685     @@@@QName: NO_LICENSE_ATTR_ERR
8686     @@@@enDesc:
8687     The <Q::dis:Module> element does not have the
8688     <Q::dis:License> attribute.
8689     @@@@XSourceNodeParam:
8690     @@@@XParam:
8691     @@@@@QName:uri
8692     @@@@@enDesc:
8693     The URI reference of the module.
8694 wakaba 1.25 @@@XSubTypeDef:
8695     @@@@QName: UNSUPPORTED_ROLE_ERR
8696     @@@@enDesc:
8697     A <Q::dis:Role> is not supported.
8698     @@@@XSourceNodeParam:
8699     @@@@XParam:
8700     @@@@@QName:uri
8701     @@@@@enDesc:
8702     The URI reference of the unsupported role.
8703     @@@@enMufDef:
8704     Role <%p (name => {<Q::DIS:uri>});> is not supported
8705 wakaba 1.37 @@@XSubTypeDef:
8706     @@@@QName: NO_REFLECT_GET_DEFINED_ERR
8707     @@@@enDesc:
8708     An attribute is defined to reflect an element attribute
8709     but no reflecting attribute getter template is defined.
8710     @@@@XSourceNodeParam:
8711     @@@@XParam:
8712     @@@@@QName:uri
8713     @@@@@enDesc:
8714     The URI reference of the datatype resource for which
8715     a getter template should have been defined.
8716     @@@XSubTypeDef:
8717     @@@@QName: NO_REFLECT_SET_DEFINED_ERR
8718     @@@@enDesc:
8719     An attribute is defined to reflect an element attribute
8720     but no reflecting attribute setter template is defined.
8721     @@@@XSourceNodeParam:
8722     @@@@XParam:
8723     @@@@@QName:uri
8724     @@@@@enDesc:
8725     The URI reference of the datatype resource for which
8726     a setter template should have been defined.
8727 wakaba 1.40 @@@XSubTypeDef:
8728 wakaba 1.43 @@@@QName: NO_END_TAG_ERR
8729     @@@@enDesc:
8730 wakaba 1.40 Close tag not found.
8731 wakaba 1.43 @@@@XSourceNodeParam:
8732     @@@@XParam:
8733 wakaba 1.49 @@@@@@: elementType
8734     @@@@@enDesc:
8735 wakaba 1.40 The type URI reference of the element that is not closed.
8736 wakaba 1.43 @@@@XParam:
8737 wakaba 1.49 @@@@@@: sourceCode
8738     @@@@@enDesc:
8739 wakaba 1.40 The source code fragment near the position where
8740     an end tag is required.
8741 wakaba 1.43 @@@@enMufDef:
8742 wakaba 1.40 End tag for element "%p (name => {<Q::DIS:elementType>});"
8743 wakaba 1.43 is required%p (name => {<Q::DIS:sourceCode>},
8744     prefix => { (}, suffix => {)});
8745 wakaba 1.49 @@@XSubTypeDef:
8746     @@@@QName: NO_RDF_TYPE_ERR
8747     @@@@enDesc:
8748     There is a resource definition element that does
8749     not have any <Q::rdf:type> attribute.
8750     @@@@XSourceNodeParam:
8751     @@@@XParam:
8752     @@@@@@: uri
8753     @@@@@enDesc:
8754     The URI of the resource which does not have <Q::rdf:type>.
8755     @@@@enMufDef:
8756     Resource%p (name => {<Q::DIS:uri>}, prefix => { "},
8757     suffix => {"}); does not have "rdf:type" attribute
8758 wakaba 1.53 @@@XSubTypeDef:
8759     @@@@QName: PERL_HASH_KEY_ALREADY_DEFINED_ERR
8760     @@@@enDesc:
8761     A hash key is already defined.
8762     @@@@XSourceNodeParam:
8763     @@@@XParam:
8764     @@@@@@:uri
8765     @@@@@enDesc:
8766     The URI of the resource tried to register.
8767     @@@@XParam:
8768     @@@@@@:anotherURI
8769     @@@@@enDesc:
8770     The URI of the already registered resource.
8771     @@@@XParam:
8772     @@@@@@:hashKeyName
8773     @@@@@enDesc:
8774     Hash key.
8775     @@@@XParam:
8776     @@@@@@:hashKeyScope
8777     @@@@@enDesc:
8778     Hash key scope.
8779     @@@@enMufDef:
8780     <%p (name => {<Q::DIS:uri>});>:
8781 wakaba 1.56 Hash key "%p (name => {<Q::DIS:hashKeyName>});" in
8782 wakaba 1.53 <%p (mame => {<Q::DIS:hashKeyScope>});> is already
8783 wakaba 1.54 defined for <%p (name => {<Q::DIS:anotherURI>});>
8784 wakaba 1.63 @@@XSubTypeDef:
8785     @@@@QName: DIS|NO_EXCEPTION_CLASS_ERR
8786     @@@@enDesc:
8787     The exception interface has no class that implements the interface.
8788     @@@@enMufDef:
8789     Exception interface <%p (name => {<Q::DIS:uri>});>:
8790     There is no class that implements this interface
8791     @@@@XParam:
8792     @@@@@@: DIS|uri
8793     @@@@@enDesc:
8794     The URI of the interface.
8795 wakaba 1.37 @ImplNote:
8796     @@lang:en
8797     @@@:
8798     ISSUE: Too many subtypes for a type! New type should be added?
8799 wakaba 1.71
8800     @Attr:
8801     @@Name: text
8802     @@enDesc:
8803     The description of the error, in <LANG::i-default> language.
8804     @@enImplNote:
8805     See <A::dx|Exception.text> for super definition.
8806     @@Type: DISLang|String
8807     @@Get:
8808     @@@PerlDef:
8809     $r = $self->SUPER::text;
8810 wakaba 1.73 if (defined $self->{<H::DIS:uri>}) {
8811     $r = '<' . $self->{<H::DIS:uri>} . '>: ' . $r;
8812     }
8813 wakaba 1.71 if (defined $self->{<H::DIS:sourceNode>}) {
8814     $r = 'Node ' . $self->{<H::DIS:sourceNode>}-><M::SWCFGNode.nodePath>
8815     . ': ' . $r;
8816     }
8817 wakaba 1.4 ##DISException
8818 wakaba 1.71
8819     ElementTypeBinding:
8820     @Name: enImplNote
8821     @ElementType:
8822     dis:ImplNote
8823     @ShadowContent:
8824     @@lang:en
8825 wakaba 1.53
8826     XParamDef:
8827     @QName: hashKeyName
8828     @Type: DISLang|String
8829     @enDesc:
8830     See <M::dp|DISDatabasePerl.plAddHashKey>.
8831    
8832     XParamDef:
8833     @QName: hashKeyScope
8834     @Type: AnyURI
8835     @enDesc:
8836     See <M::dp|DISDatabasePerl.plAddHashKey>.
8837    
8838     XParamDef:
8839     @QName: anotherURI
8840     @Type: ResourceURI
8841     @enDesc:
8842     A URI of another related resource.
8843 wakaba 1.13
8844     XParamDef:
8845     @QName:expectedType
8846     @Type: ResourceURI
8847     @enDesc:
8848     Expected resource type URI reference.
8849    
8850     XParamDef:
8851     @QName: sourceCode
8852     @Type:
8853 wakaba 1.110 DISLang:String
8854 wakaba 1.13 @enDesc:
8855     The source code fragment in which an error occurred.
8856 wakaba 1.5
8857     XParamDef:
8858     @QName: elementType
8859     @Type: ResourceURI
8860     @enDesc:
8861     The name of the element type.
8862    
8863     XParamDef:
8864     @QName: uri
8865     @Type: ResourceURI
8866     @enDesc:
8867     The name of the resource, composed from <Q::namespaceURI>,
8868     <Q::localName> and <Q::for>.
8869    
8870     XParamDef:
8871     @QName: localName
8872     @Type:
8873 wakaba 1.110 DISCore:LocalName
8874 wakaba 1.5 @enDesc:
8875     The local name of the resource, unique in <Q::namespaceURI> namespace.
8876    
8877     XParamDef:
8878     @QName: namespaceURI
8879     @Type: AnyURI
8880     @enDesc:
8881     The namespace URI reference of the resource name.
8882    
8883     XParamDef:
8884     @QName: for
8885     @Type: ForURI
8886     @enDesc:
8887     The <QUOTE::for> URI reference of the resource.
8888    
8889     ElementTypeBinding:
8890     @Name: XSourceNodeParam
8891     @ElementType:
8892 wakaba 1.64 ecore:hasParameter
8893 wakaba 1.5 @ShadowContent:
8894     @@QName: sourceNode
8895     @@Description:
8896     @@@lang:en
8897     @@@@:
8898     The node in which an error has occurred.
8899 wakaba 1.15
8900     ElementTypeBinding:
8901     @Name: XSourceCodeParam
8902     @ElementType:
8903 wakaba 1.64 ecore:hasParameter
8904 wakaba 1.15 @ShadowContent:
8905     @@QName: sourceCode
8906     @@Description:
8907     @@@lang:en
8908     @@@@:
8909     The source code in which an error has occurred.
8910 wakaba 1.4
8911 wakaba 1.52 ElementTypeBinding:
8912     @Name: plMName
8913     @ElementType:
8914     DISPerl:methodName
8915     @ShadowContent:
8916     @@ContentType: lang|Perl
8917 wakaba 1.4
8918     ElementTypeBinding:
8919 wakaba 1.52 @Name: plCName
8920 wakaba 1.4 @ElementType:
8921 wakaba 1.52 DISPerl:exportTagName
8922 wakaba 1.4 @ShadowContent:
8923 wakaba 1.47 @@ContentType: lang|Perl
8924 wakaba 1.3
8925     ElementTypeBinding:
8926     @Name: Method
8927     @ElementType:
8928     dis:ResourceDef
8929     @ShadowContent:
8930     @@rdf:type:
8931     DISLang:Method
8932    
8933     ElementTypeBinding:
8934 wakaba 1.79 @Name: CMethod
8935     @ElementType:
8936     dis:ResourceDef
8937     @ShadowContent:
8938     @@rdf:type:
8939     DISLang:Method
8940 wakaba 1.110 @@ForCheck: ManakaiDOM|ForClass
8941 wakaba 1.79
8942     ElementTypeBinding:
8943 wakaba 1.3 @Name: IntMethod
8944     @ElementType:
8945     dis:ResourceDef
8946     @ShadowContent:
8947     @@rdf:type:
8948     DISLang:Method
8949     @@ManakaiDOM:isForInternal:1
8950 wakaba 1.52 @@ForCheck: ManakaiDOM|ForClass
8951 wakaba 1.3
8952     ElementTypeBinding:
8953     @Name: Attr
8954     @ElementType:
8955     dis:ResourceDef
8956     @ShadowContent:
8957     @@rdf:type:
8958     DISLang:Attribute
8959 wakaba 1.79
8960     ElementTypeBinding:
8961     @Name: CAttr
8962     @ElementType:
8963     dis:ResourceDef
8964     @ShadowContent:
8965     @@rdf:type:
8966     DISLang:Attribute
8967 wakaba 1.110 @@ForCheck: ManakaiDOM|ForClass
8968 wakaba 1.3
8969     ElementTypeBinding:
8970     @Name: Return
8971     @ElementType:
8972     dis:ResourceDef
8973     @ShadowContent:
8974     @@rdf:type:
8975     DISLang:MethodReturn
8976    
8977     ElementTypeBinding:
8978     @Name: Get
8979     @ElementType:
8980     dis:ResourceDef
8981     @ShadowContent:
8982     @@rdf:type:
8983     DISLang:AttributeGet
8984    
8985     ElementTypeBinding:
8986     @Name: Set
8987     @ElementType:
8988     dis:ResourceDef
8989     @ShadowContent:
8990     @@rdf:type:
8991     DISLang:AttributeSet
8992    
8993     ElementTypeBinding:
8994     @Name: Param
8995     @ElementType:
8996     dis:ResourceDef
8997     @ShadowContent:
8998     @@rdf:type:
8999     DISLang:MethodParameter
9000    
9001     ElementTypeBinding:
9002     @Name: PerlDef
9003     @ElementType:
9004     dis:Def
9005     @ShadowContent:
9006     @@ContentType:
9007     lang:Perl
9008    
9009     ElementTypeBinding:
9010     @Name: InCase
9011     @ElementType:
9012     dis:ResourceDef
9013     @ShadowContent:
9014     @@rdf:type:
9015     ManakaiDOM:InCase
9016    
9017     ElementTypeBinding:
9018     @Name: nullCase
9019     @ElementType:
9020     dis:ResourceDef
9021     @ShadowContent:
9022     @@rdf:type:
9023     ManakaiDOM:InCase
9024     @@Value:
9025     @@@is-null:1
9026 wakaba 1.49 @@@ContentType: DISCore|String
9027 wakaba 1.3
9028     ElementTypeBinding:
9029     @Name: TrueCase
9030     @ElementType:
9031     dis:ResourceDef
9032     @ShadowContent:
9033     @@rdf:type:
9034     ManakaiDOM:InCase
9035 wakaba 1.49 @@Value:
9036     @@@@: 1
9037     @@@ContentType: DISCore|Boolean
9038 wakaba 1.3 @@Type:
9039 wakaba 1.110 DOMMain:boolean
9040 wakaba 1.3
9041     ElementTypeBinding:
9042     @Name: FalseCase
9043     @ElementType:
9044     dis:ResourceDef
9045     @ShadowContent:
9046     @@rdf:type:
9047     ManakaiDOM:InCase
9048 wakaba 1.49 @@Value:
9049     @@@@: 0
9050     @@@ContentType: DISCore|Boolean
9051 wakaba 1.3 @@Type:
9052 wakaba 1.110 DOMMain:boolean
9053 wakaba 1.3
9054     ElementTypeBinding:
9055     @Name: enDesc
9056     @ElementType:
9057     dis:Description
9058     @ShadowContent:
9059     @@lang:en
9060    
9061     ElementTypeBinding:
9062     @Name: PropDef
9063     @ElementType:
9064     dis:ResourceDef
9065     @ShadowContent:
9066 wakaba 1.81 @@DISCore:resourceType: DISCore|Property
9067    
9068     ElementTypeBinding:
9069     @Name: RPropDef
9070     @ElementType:
9071     dis:ResourceDef
9072     @ShadowContent:
9073     @@DISCore:resourceType: DISSource|ResourceProperty
9074 wakaba 1.3
9075     ElementTypeBinding:
9076     @Name: MethodRedef
9077     @ElementType:
9078     dis:ResourceDef
9079     @ShadowContent:
9080     @@rdf:type:
9081     DISLang:Method
9082    
9083     ElementTypeBinding:
9084     @Name: NamedParam
9085     @ElementType:
9086     dis:ResourceDef
9087     @ShadowContent:
9088     @@rdf:type:
9089     DISLang:MethodParameter
9090     @@DISPerl:isNamedParameter:1
9091    
9092     ElementTypeBinding:
9093     @Name: NodeParam
9094     @ElementType:
9095     dis:ResourceDef
9096     @ShadowContent:
9097     @@rdf:type:
9098     DISLang:MethodParameter
9099     @@DISPerl:isNamedParameter:1
9100     @@Name: node
9101 wakaba 1.47 @@Type: DISNode
9102     @@actualType:
9103     @@@@: ManakaiDISNode
9104     @@@ForCheck: ManakaiDOM|ForClass
9105 wakaba 1.3 @@Description:
9106     @@@lang:en
9107     @@@@:
9108     The node in which the name has occurred. It is intended
9109     to be reported when an exception had been raised.
9110     @@ResourceDef:
9111     @@@rdf:type:
9112     ManakaiDOM:InCase
9113     @@@Value:
9114     @@@@is-null:1
9115 wakaba 1.49 @@@@ContentType: DISCore|String
9116 wakaba 1.3 @@@Description:
9117     @@@@lang:en
9118     @@@@@:
9119     The source of the name is not a node.
9120    
9121     ElementTypeBinding:
9122     @Name: ForParam
9123     @ElementType:
9124     dis:ResourceDef
9125     @ShadowContent:
9126     @@rdf:type:
9127     DISLang:MethodParameter
9128     @@DISPerl:isNamedParameter:1
9129     @@Name: forArg
9130     @@Type: ForURI
9131     @@Description:
9132     @@@lang:en
9133     @@@@:
9134     The <QUOTE::for> URI reference.
9135     @@ResourceDef:
9136     @@@rdf:type:
9137     ManakaiDOM:InCase
9138     @@@Value:
9139     @@@@is-null:1
9140 wakaba 1.49 @@@@ContentType: DISCore|String
9141 wakaba 1.3 @@@Description:
9142     @@@@lang:en
9143     @@@@@:
9144     Equivalent to <Q::ManakaiDOM:all>, i.e. <QUOTE::for all>.
9145    
9146     ElementTypeBinding:
9147     @Name: ForpParam
9148     @ElementType:
9149     dis:ResourceDef
9150     @ShadowContent:
9151     @@rdf:type:
9152     DISLang:MethodParameter
9153     @@DISPerl:isNamedParameter:1
9154     @@Name: forpArg
9155     @@Type: ForURIList
9156     @@Description:
9157     @@@lang:en
9158     @@@@:
9159     An array reference containing additional <QUOTE::for>
9160     constraints (<QUOTE::For+> list).
9161     @@ResourceDef:
9162     @@@rdf:type:
9163     ManakaiDOM:InCase
9164     @@@Value:
9165     @@@@is-null:1
9166 wakaba 1.49 @@@@ContentType: DISCore|String
9167 wakaba 1.3 @@@Description:
9168     @@@@lang:en
9169     @@@@@:
9170     Equivalent to the empty array reference.
9171    
9172     ElementTypeBinding:
9173     @Name: MediaTypeParam
9174     @ElementType:
9175     dis:ResourceDef
9176     @ShadowContent:
9177     @@rdf:type:
9178     DISLang:MethodParameter
9179     @@DISPerl:isNamedParameter:1
9180     @@Name: mediaType
9181     @@Type: MediaTypeURI
9182     @@Description:
9183     @@@lang:en
9184     @@@@:
9185     The URI reference identifying a media type.
9186     @@ResourceDef:
9187     @@@rdf:type:
9188     ManakaiDOM:InCase
9189     @@@Value:
9190     @@@@is-null:1
9191 wakaba 1.49 @@@@ContentType: DISCore|String
9192 wakaba 1.3 @@@Description:
9193     @@@@lang:en
9194     @@@@@:
9195     No media type specified.
9196    
9197     ElementTypeBinding:
9198     @Name: MediaTypeDefaultParam
9199     @ElementType:
9200     dis:ResourceDef
9201     @ShadowContent:
9202     @@rdf:type:
9203     DISLang:MethodParameter
9204     @@DISPerl:isNamedParameter:1
9205     @@Name: defaultMediaType
9206     @@Type: MediaTypeURI
9207     @@Description:
9208     @@@lang:en
9209     @@@@:
9210     The default media type, i.e. the type used when no explicit
9211     specification is not found in the source tree.
9212     @@ResourceDef:
9213     @@@rdf:type:
9214     ManakaiDOM:InCase
9215     @@@Value:
9216     @@@@is-null:1
9217 wakaba 1.49 @@@@ContentType: DISCore|String
9218 wakaba 1.3 @@@Description:
9219     @@@@lang:en
9220     @@@@@:
9221     Defaulted to <Q::DOMMain:any>.
9222    
9223     ElementTypeBinding:
9224     @Name: RaiseException
9225     @ElementType:
9226     ManakaiDOM:raises
9227    
9228     ElementTypeBinding:
9229     @Name: UndeclaredPrefixException
9230     @ElementType:
9231     ManakaiDOM:raises
9232     @ShadowContent:
9233     @@@: UNDECLARED_NS_PREFIX_ERR
9234     @@Description:
9235     @@@lang:en
9236     @@@@:
9237     The implementation has encounted an undeclared namespace prefix.
9238    
9239     ElementTypeBinding:
9240     @Name: NoDBException
9241     @ElementType:
9242     ManakaiDOM:raises
9243     @ShadowContent:
9244 wakaba 1.47 @@@: NO_ASSOCIATED_DB_ERR
9245 wakaba 1.3 @@Description:
9246     @@@lang:en
9247     @@@@:
9248     No <QUOTE::dis> database is associated to this document.
9249    
9250     ElementTypeBinding:
9251     @Name: XConstDef
9252     @ElementType:
9253     dis:ResourceDef
9254     @ShadowContent:
9255 wakaba 1.63 @@rdf:type: dx|ErrorCode
9256 wakaba 1.3
9257     ElementTypeBinding:
9258     @Name: XSubTypeDef
9259     @ElementType:
9260     dis:ResourceDef
9261     @ShadowContent:
9262 wakaba 1.63 @@rdf:type: dx|ErrorSubCode
9263 wakaba 1.3
9264     ElementTypeBinding:
9265     @Name: XParam
9266     @ElementType:
9267 wakaba 1.63 ecore:hasParameter
9268 wakaba 1.3
9269     ElementTypeBinding:
9270     @Name: XParamDef
9271     @ElementType:
9272     dis:ResourceDef
9273     @ShadowContent:
9274 wakaba 1.63 @@rdf:type: ecore|Parameter
9275 wakaba 1.54
9276     XParamDef:
9277     @QName: DIS|moduleURI
9278     @enDesc:
9279     A URI of the module in which the resource is defined.
9280 wakaba 1.3
9281     ElementTypeBinding:
9282     @Name: enMufDef
9283     @ElementType:
9284 wakaba 1.68 ecore:defaultMessage
9285 wakaba 1.3 @ShadowContent:
9286     @@ContentType:
9287     lang:muf
9288     @@lang:en

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24