/[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.115 - (hide annotations) (download)
Sun Dec 31 09:11:57 2006 UTC (18 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.114: +77 -558 lines
++ manakai/bin/ChangeLog	31 Dec 2006 08:49:16 -0000
2006-12-31  Wakaba  <wakaba@suika.fam.cx>

	* daf.pl: Support for |For| is entirely removed.

++ manakai/lib/Message/Util/ChangeLog	31 Dec 2006 09:06:08 -0000
	* DIS.dis: Support for |for| is entirely removed.  |forArg|
	parameters are removed.
	(createDISDocument): Removed.
	(tfurisToURI): Removed.
	(tfpurisToURI): The |for| URI slot is
	fixed to |ManakaiDOM:all|.
	(tfqnamesToURI): Removed.
	(tfpqnamesToURI): The |defaultForURI| parameter
	is removed and the |for| URI slot is
	fixed to |ManakaiDOM:all|.
	(forURI): Removed.
	(forMatch): The first parameter, |forArg|, no
	longer takes effect.

	* PerlCode.dis (sourceFor): Removed.
	(stringify): Don't output comment with |sourceFor| URI.

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

++ manakai/lib/Message/Util/Error/ChangeLog	31 Dec 2006 09:09:24 -0000
2006-12-31  Wakaba  <wakaba@suika.fam.cx>

	* Core.dis, DOMException.dis: |dis:dataType|
	of |DISCore:TFQNames| are replaced
	by |DISCore:QName|.

++ manakai/lib/Message/Util/DIS/ChangeLog	31 Dec 2006 09:08:40 -0000
	* DNLite.dis, Perl.dis: Support for |for| is entirely removed.

	* Test.dis (parseTDTErrorString): The |defaultTURI|
	and |defaultFURI| parameters are removed.
	(lexmode): |TFQNames| token type is removed.
	(tdterr): Accepts |QName| where |TFQNames| was accepted.

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

++ manakai/lib/Message/DOM/ChangeLog	31 Dec 2006 08:50:54 -0000
	* |InputProcessor|s and |OutputProcessor|s are
	named so that |report| statements in Perl
	module outputs can be identified by name. |dis:dataType|s
	of |DISCore:TFQNames| are all replaced
	by |DISCore:QName|.

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

++ manakai/lib/manakai/ChangeLog	31 Dec 2006 09:11:27 -0000
	* |dis:dataType| of |DISCore:TFQNames| are replaced
	by |DISCore:QName|.

	* DISCore.dis (DISCore:TFURI): Removed.
	(DISCore:ModuleTFQNames): Removed.

	* daf-dtd-modules.pl: Support for |for| is removed.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24