/[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.2 - (hide annotations) (download)
Tue Feb 22 08:21:00 2005 UTC (20 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +1067 -75 lines
DIS.dis: Definition added (but not yet work)

1 wakaba 1.1 Module:
2     @QName:
3     Util:DIS
4     @FullName:
5     @@lang: en
6     @@@:
7     <QUOTE::DIS> Object Model
8     @Namespace:
9     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
10    
11     @Description:
12     @@lang:en
13     @@@:
14     This module provides an object model for <QUITE::dis> document format.
15    
16     @Author:
17     @@FullName: Wakaba
18     @@Mail: w@suika.fam.cx
19     @License:
20     @@@:
21     license:Perl+MPL
22     @@Original:
23     @@@FullName:
24     manakai <CODE::lib/manakai/dis.pl>
25     @@@Year:2004
26     @@@Author:
27     @@@@FullName:Wakaba
28     @@@@Mail:w@suika.fam.cx
29     @Date:
30     @@@:
31 wakaba 1.2 $Date: 2005/02/21 08:06:19 $
32 wakaba 1.1 @@ContentType:
33     dis:Date.RCS
34    
35     @Require:
36     @@Module:
37     @@@Name: SuikaWikiConfig21
38     @@@WithFor:
39     ManakaiDOM:Perl
40     @defaultFor: ForLatest
41    
42     Namespace:
43     @DIS:
44     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#
45     @dis:
46     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
47     @dis2pm:
48     http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#
49     @lang:
50     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
51     @license:
52     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
53     @ManakaiDOM:
54     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
55     @owl:
56     http://www.w3.org/2002/07/owl#
57     @Perl:
58     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl--
59     @rdf:
60     http://www.w3.org/1999/02/22-rdf-syntax-ns#
61     @rdfs:
62     http://www.w3.org/2000/01/rdf-schema#
63     @TreeCore:\
64     @Util:
65     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/
66    
67     ## -- "For" definitions
68    
69     ForDef:
70     @QName:
71     DIS:ForLatest
72     @Description:
73     @@lang:en
74     @@@:
75     For latest version of the <Module::Util:DIS> module implementation
76     @ISA:
77     ManakaiDOM:Perl
78    
79     ## -- Features
80    
81     ElementTypeBinding:
82     @Name: FeatureDef
83     @ElementType:
84     dis:ResourceDef
85     @ShadowContent:
86     @@rdf:type:
87     DOMMain:DOMFeature
88     @@AliasFor:
89     @@@@:
90     ::ManakaiDOM:all
91     @@@For:
92     !=ManakaiDOM:all
93    
94     ElementTypeBinding:
95     @Name: FeatureVerDef
96     @ElementType:
97     dis:ResourceDef
98     @ShadowContent:
99     @@rdf:type:
100     DOMMain:DOMFeature
101    
102     ElementTypeBinding:
103     @Name: featureQName
104     @ElementType:
105     dis:AppName
106     @ShadowContent:
107     @@ContentType:
108     dis:TypeQName
109    
110     FeatureDef:
111     @QName: Core
112     @FeatureVerDef:
113     @@QName: CoreFeature10
114     @@Version: 1.0
115     @@ISA: Core
116     @@FullName:
117     @@@lang:en
118     @@@@:
119     The <QUOTE::dis> object model, version 1.0
120     @@Description:
121     @@@lang:en
122     @@@@:
123     The <QUOTE::dis> object model, version 1.0.
124     @@DOMMain:requireFeature:
125     swcfg21:CoreFeature21
126    
127     ## -- SuikaWikiConfig/2.1 extended classes
128    
129     ClsDef:
130     @ClsQName: ManakaiDISImplementation
131     @ClsISA:
132     swcfg21:SWCFGImplementation
133     @Description:
134     @@lang:en
135     @@@:
136     A <QUOTE::dis> implementation object.
137    
138     @Method:
139     @@Name: createDISDocument
140     @@Description:
141     @@@lang:en
142     @@@@:
143     Creates an empty <Class::ManakaiDISDocument> object.
144     @@Return:
145     @@@Type:ManakaiDISDocument
146     @@@Description:
147     @@@@lang:en
148     @@@@@:
149     The newly created <QUOTE::dis> document object.
150     @@@PerlDef:
151     $r = $self-><M::swcfg21:SWCFGImplementation.createSWCFGDocument>;
152     $r-><AS::swcfg21:SWCFGDocument.defaultElementTypeNamespaceURI>
153     (<Q::dis:>);
154    
155     @Method:
156 wakaba 1.2 @@Name: createDISParser
157     @@Description:
158     @@@lang:en
159     @@@@:
160 wakaba 1.1 Creates a <Class::ManakaiDISParser> object.
161 wakaba 1.2 @@Return:
162     @@@Type: ManakaiDISParser
163     @@@Description:
164     @@@@lang:en
165     @@@@@:
166 wakaba 1.1 A newly created <QUOTE::dis> parser.
167 wakaba 1.2 @@@PerlDef:
168 wakaba 1.1 $r = bless $self-><M::swcfg21:SWCFGImplementation.createParser>,
169     <ClassName::ManakaiDISParser>;
170    
171     @Method:
172 wakaba 1.2 @@Name: createDISDatabase
173 wakaba 1.1 @@Description:
174     @@@lang:en
175     @@@@:
176 wakaba 1.2 Creates a new <QUOTE::dis> database.
177 wakaba 1.1 @@Return:
178 wakaba 1.2 @@@Type:ManakaiDISDatabase
179     @@Description:
180     @@@lang:en
181     @@@@:
182     A newly created <QUOTE::dis> parser.
183     @@PerlDef:
184     $r = bless {
185     forDef => {
186     <Q::ManakaiDOM:all> => {
187     uri => <Q::ManakaiDOM:all>,
188     isa => {<Q::ManakaiDOM:all> => 1},
189     revISA => {},
190     },
191     },
192     resDef => {},
193     }, <CassName::ManakaiDISDatabase>;
194    
195 wakaba 1.1 ##DISImplementation
196    
197     ClsDef:
198     @ClsQName: ManakaiDISParser
199     @ClsISA:
200     swcfg21:SWCFGParser
201     @Description:
202     @@lang:en
203     @@@:
204     A SuikaWikiConfig/2.1 parser that returns <QUOTE::dis> object.
205     @Method:
206     @Name: parse
207     @Description:
208     @@lang:en
209     @@@:
210     Parses a <QUOTE::dis> document and returns it as an object tree.
211     @Param:
212     @@Name: input
213     @@Type:
214     DOMLS:LSInput
215     @@Description:
216     @@@lang:en
217     @@@@:
218     The input source.
219     @Return:
220     @@Type: DISDocument
221     @@Description:
222     @@@lang:en
223     @@@@:
224     The <QUOTE::dis> document object created from the <P::input>.
225     @@@RaiseException:
226     @@@@@:
227     swcfg21:SWCFG_PARSE_ERR
228     @@@@Description:
229     @@@@@lang:en
230     @@@@@@:
231     The <IF::swcfg21:SWCFGParser> was unable to load the SuikaWikiConfig
232     document.
233     @@@PerlDef:
234     __DEEP{
235     $r = $self-><M::swcfg21:ManakaiSWCFGParser.parse> ($input);
236     }__;
237     if (defined $r) {
238     $r = bless $r, <ClassName::ManakaiDISDocument>;
239     }
240     ##DISParser
241    
242     ClsDef:
243     @ClsQName: ManakaiDISNode
244     @ClsISA:
245     swcfg21:ManakaiSWCFGNode
246     @Description:
247     @@lang:en
248     @@@:
249     <QUOTE::dis> node objects.
250    
251     @MethodRedef:
252     @@Name:lookupNamespacePrefix
253     @@Description:
254     @@@lang:en
255     @@@@:
256     Looks up the namespace prefix associated to the given
257     namespace URI. The default namespaces are ignored.
258     @@Param:
259     @@@Name:namespaceURI
260     @@@Type:
261     swcfg21:SWCFGString
262     @@@Description:
263     @@@@lang:en
264     @@@@@:
265     The namespace URI to look for.
266     @@@InCase:
267     @@@@Value:
268     @@@@@is-null:1
269     @@@@Description:
270     @@@@@lang:en
271     @@@@@@:
272     The <DOM::null> namespace.
273     @@NamedParam:
274     @@@Name: makeNewBinding
275     @@@Type:
276     DOMMain:boolean
277     @@@Description:
278     @@@@lang:en
279     @@@@@:
280     Whether a new namespace prefix should be bound when
281     no namespace URI has been associated yet.
282     @@@InCase:
283     @@@@Value:true
284     @@@@Description:
285     @@@@@lang:en
286     @@@@@@:
287     New binding is made if no prefix associated.
288     @@@InCase:
289     @@@@Value:false
290     @@@@Description:
291     @@@@@lang:en
292     @@@@@@:
293     Simply returns the <DOM::null> if no prefix associated.
294     @@Return:
295     @@@Type:
296     swcfg21:SWCFGString
297     @@@Description:
298     @@@@lang:en
299     @@@@@:
300     An associated namespace prefix. If more than one prefix
301     are associated to the namespace URI, the returned prefix
302     is implementation dependent.
303     @@@InCase:
304     @@@@Value:
305     @@@@@is-null:1
306     @@@@Type:
307     swcfg21:SWCFGString
308     @@@@Description:
309     @@@@@lang:en
310     @@@@@@:
311     No associated namespace prefix found.
312     @@@PerlDef:
313     $r = null;
314     my $od = $self-><AG::swcfg21:SWCFGNode.ownerDocument> || $self;
315     my $binds = $od->{<Q::TreeCore:node>}->{<Q::nsBinding>};
316     if (defined $namespaceURI) {
317     FIND: {
318     for my $prefix (keys %$binds) {
319     if (defined $binds->{$prefix} and
320     $binds->{$prefix} eq $namespaceURI) {
321     $r = $prefix;
322     last FIND;
323     }
324     }
325     last FIND unless $makeNewBinding;
326     ## Not found
327     if ($namespaceURI =~ /(\w+)$/) {
328     my $prefix = $1;
329     unless (exists $binds->{$prefix}) {
330     $binds->{$prefix} = $namespaceURI;
331     $r = $prefix;
332     last FIND;
333     }
334     }
335     my $i = 1;
336     {
337     unless (exists $binds->{'ns'.$i}) {
338     $binds->{$r = 'ns'.$i} = $namespaceURI;
339     last FIND;
340     }
341     $i++;
342     redo;
343     }
344     } # FIND
345     } else { ## Null namespace
346     FIND: {
347     if (exists $binds->{'nu'.'ll'} and not defined $binds->{'nu'.'ll'}) {
348     $r = 'nu'.'ll';
349     last FIND;
350     }
351     for my $prefix (keys %$binds) {
352     if (not defined $prefix) {
353     $r = $prefix;
354     last FIND;
355     }
356     }
357     last FIND unless $makeNewBinding;
358     ## Not found
359     my $i = '';
360     {
361     unless (exists $binds->{'nu'.'ll'.$i}) {
362     $binds->{$r = 'nu'.'ll'.$i} = null;
363     last FIND;
364     }
365     $i++;
366     redo;
367     }
368     }
369     }
370     ## TODO: Module ns support
371    
372     @MethodRedef:
373     @@Name:lookupNamespaceURI
374     @@Description:
375     @@@lang:en
376     @@@@:
377     Looks up the namespace URI associated to the given prefix.
378     @@Param:
379     @@@Name:prefix
380     @@@Type:
381     swcfg21:SWCFGString
382     @@@Description:
383     @@@@lang:en
384     @@@@@:
385     The namespace URI to look for.
386     @@NamedParam:
387     @@@Name: makeNewBinding
388     @@@Type:
389     DOMMain:boolean
390     @@@Description:
391     @@@@lang:en
392     @@@@@:
393     Whether a new binding should be created if no namespace URI
394     is associated with the <P::prefix> or not.
395     @@@InCase:
396     @@@@Value:true
397     @@@@Description:
398     @@@@@lang:en
399     @@@@@@:
400     A new binding to the temporary namespace URI
401     exactly same as <P::prefix> is created
402     if no binding found.
403     @@@InCase:
404     @@@@Value:false
405     @@@@Description:
406     @@@@@lang:en
407     @@@@@@:
408     No new binding is created if no binding found. Note that
409     even if no association newly created, this method
410     returns the <DOM::null> value.
411     @@Return:
412     @@@Type:
413     swcfg21:SWCFGString
414     @@@Description:
415     @@@@lang:en
416     @@@@@:The associated namespace URI.
417     @@@InCase:
418     @@@@Value:
419     @@@@@is-null:1
420     @@@@Type:
421     swcfg21:SWCFGString
422     @@@@Description:
423     @@@@@lang:en
424     @@@@@@:
425     No namespace prefix is associated to the prefix or
426     the <DOM::null> namespace is associated.
427     @@@PerlDef:
428     my $od = $self-><AG::swcfg21:SWCFGNode.ownerDocument> || $self;
429     my $binds = $od->{<Q::TreeCore:node>}->{<Q::nsBinding>};
430     if (exists $binds->{$prefix}) {
431     $r = $binds->{$prefix};
432     } elsif ($makeNewBinding) {
433     $r = $binds->{$prefix} = $prefix;
434     } else {
435     $r = null;
436     }
437     ## TODO: Module ns support
438    
439     @IntMethod:
440     @@Name:getNodeReference
441     @@Description:
442     @@@lang:en
443     @@@@:
444     Returns a new reference to the node object.
445     @@ManakaiDOM:isStatic:1
446     @@Param:
447     @@@Name:object
448     @@@Type:
449     ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
450     @@@Description:
451     @@@@lang:en
452     @@@@@:
453     The node object to be referred.
454     @@Return:
455     @@@Type: ManakaiDISNode
456     @@@Description:
457     @@@@lang:en
458     @@@@@:
459     A newly created reference.
460     @@@PerlDef:
461     my $class;
462     if ($object->{<Q::nodeType>} eq '#element') {
463     $class = <ClassName::ManakaiDISElement>;
464     } elsif ($object->{<Q::nodeType>} eq '#comment') {
465     $class = <ClassName::ManakaiDISComment>;
466     } elsif ($object->{<Q::nodeType>} eq '#document') {
467     $class = <ClassName::ManakaiDISDocument>;
468     } elsif ($object->{<Q::nodeType>} eq '#fragment') {
469     $class = <ClassName::ManakaiDISDocumentFragment>;
470     } else {
471     __ASSERT{DISPerl:invariant::
472     msg => {qq[Node type: "$object->{<Q::nodeType>}" ].
473     qq[(ref: "@{[ref $object]}")]},
474     }__;
475     }
476     $r = $object-><M::ManakaiDOM:ManakaiDOMNodeObject::ManakaiDOM:Perl
477     .newReference> ($class);
478    
479 wakaba 1.2 @Attr:
480     @@Name:ownerDISDocument
481     @@NewIn21:
482     @@Description:
483     @@@lang:en
484     @@@@:
485     The <QUOTE::dis> document object associated with this node.
486     @@Get:
487     @@@Type:DISDocument
488     @@@Description:
489     @@@@lang:en
490     @@@@@:
491     The document object associated with this node.
492     @@@InCase:
493     @@@@Value:
494     @@@@@is-null:1
495     @@@@Type:DISDocument
496     @@@@Description:
497     @@@@@lang:en
498     @@@@@@:
499     This node is a document node.
500     @@@PerlDef:
501     $r = <ClassM::ManakaiDISNode.getNodeReference>
502     ($self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>})
503     if $self->{<Q::TreeCore:node>}->{<Q::DOMCore:ownerDocument>};
504 wakaba 1.1 ##DISNode
505    
506     ClsDef:
507     @ClsQName: ManakaiDISElement
508     @ClsISA:
509     swcfg21:ManakaiSWCFGElement
510     @ClsISA: ManakaiDISNode
511     @Description:
512     @@lang:en
513     @@@:
514     <QUOTE::dis> element node objects.
515    
516     @Method:
517     @@Name: forMatch
518     @@Description:
519     @@@lang:en
520     @@@@:
521     Tests whether this element is for a <QUOTE::for> or not.
522     @@Param:
523     @@@Name: forArg
524     @@@Type: ForURI
525     @@@Description:
526     @@@@lang:en
527     @@@@@:
528     The <QUOTE::For> URI reference to test against.
529     @@Param:
530     @@@Name: forpArg
531     @@@Type: ForURIList
532     @@@Description:
533     @@@@lang:en
534     @@@@@:
535     The <QUOTE::For+> URI references to test against.
536     @@@InCase:
537     @@@@Value:
538     @@@@@is-null:1
539     @@@@Description:
540     @@@@@lang:en
541     @@@@@@:
542     No additional <QUOTE::For> URI reference.
543     @@Return:
544     @@@Type:
545     DOMMain:boolean
546     @@@Description:
547     @@@@lang:en
548     @@@@@:
549     Whether this element is for <P::forArg> and <P::forpArg> or not.
550 wakaba 1.2 @@@UndeclaredPrefixException:
551     @@@NoDBException:
552     @@@PerlDef:
553     $for_arg = <Q::ManakaiDOM:all> unless defined $for_arg;
554     $forp_arg ||= [];
555    
556     FORMATCH: {
557     __DEEP{
558     my @ce = @{$self-><AG::ManakaiDISElement.disChildElements>};
559     for my $ce (@ce) {
560     my $et = $ce-><AG::swcfg21:SWCFGElement.expandedURI>;
561     if ($et eq <Q::dis:ForCheck>) {
562     my $for = [split /\s+/, $ce-><AG::swcfg21:SWCFGNode.value>];
563     FCs: for my $f (@$for) {
564     if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
565     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
566     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
567     -><AG::ManakaiDISDocument.disDatabase>
568     -><M::ManakaiDISDatabase.getFor> ($uri);
569     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
570     for my $arg_uri ($for_arg, @{$forp_arg}) {
571     if ($uri eq $arg_uri) {
572     $r = false;
573     last FORMATCH;
574     }
575     }
576     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
577     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
578     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
579     -><AG::ManakaiDISDocument.disDatabase>
580     -><M::ManakaiDISDatabase.getFor> ($uri);
581     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
582     for my $arg_uri ($for_arg, @{$forp_arg}) {
583     if ($f-><M::ManakaiDISForDefinition.isaURI> ($arg_uri)) {
584     $r = false;
585     last FORMATCH;
586     }
587     }
588     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
589     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
590     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
591     -><AG::ManakaiDISDocument.disDatabase>
592     -><M::ManakaiDISDatabase.getFor> ($uri);
593     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
594     for my $arg_uri ($for_arg, @{$forp_arg}) {
595     if ($arg_uri eq $uri) {
596     next FCs;
597     }
598     }
599     $r = false;
600     last FORMATCH;
601     } else { ## -- ISA
602     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
603     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
604     -><AG::ManakaiDISDocument.disDatabase>
605     -><M::ManakaiDISDatabase.getFor> ($uri);
606     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
607     for my $arg_uri ($for_arg, @{$forp_arg}) {
608     if ($f-><M::ManakaiDISForDefinition.isaURI> ($arg_uri)) {
609     next FCs;
610     }
611     }
612     $r = false;
613     last FORMATCH;
614     }
615     } # FCs
616     } # dis:ForCheck
617     } # children
618    
619     my $has_for = false;
620     for my $ce (@ce) {
621     if ($self-><AG::swcfg21:SWCFGElement.expandedURI> eq
622     <Q::dis:For>) {
623     my $for = [split /\s+/, $ce-><AG::swcfg21:SWCFGNode.value>];
624     my $ok = true;
625     $has_for = true;
626     AFOR: for my $f (@$for) {
627     if ($f =~ /^!=(.+)$/) { ## -- NOT EQUAL TO
628     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
629     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
630     -><AG::ManakaiDISDocument.disDatabase>
631     -><M::ManakaiDISDatabase.getFor> ($uri);
632     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
633     if ($uri eq $for_arg) {
634     $ok = false;
635     last AFOR;
636     }
637     } elsif ($f =~ /^!(.+)$/) { ## -- NOT ISA
638     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
639     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
640     -><AG::ManakaiDISDocument.disDatabase>
641     -><M::ManakaiDISDatabase.getFor> ($uri);
642     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
643     if ($f-><M::ManakaiDISForDefinition.isaURI> ($for_arg)) {
644     $ok = false;
645     last AFOR;
646     }
647     } elsif ($f =~ /^=(.+)$/) { ## -- EQUAL TO
648     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
649     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
650     -><AG::ManakaiDISDocument.disDatabase>
651     -><M::ManakaiDISDatabase.getFor> ($uri);
652     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
653     unless ($uri eq $for_arg) {
654     $ok = false;
655     last AFOR;
656     }
657     } else { ## -- ISA
658     my $uri = $self-><AG::ManakaiDISElement.qnameToURI> ($1);
659     my $f = $self-><AG::ManakaiDISNode.ownerDISDocument>
660     -><AG::ManakaiDISDocument.disDatabase>
661     -><M::ManakaiDISDatabase.getFor> ($uri);
662     $f-><AG::ManakaiDISForDefinition.isReferred> ($ce);
663     unless ($f-><M::ManakaiDISForDefinition.isaURI> ($for_arg)) {
664     $ok = false;
665     last AFOR;
666     }
667     }
668     } # AFOR
669     } # dis:For
670     if ($ok) {
671     $r = true;
672     last FORMATCH;
673     }
674     } # $ce
675     $r = $has_for ? false : true;
676     }__;
677     } # FORMATCH
678 wakaba 1.1
679     @Method:
680     @@Name: mediaTypeMatch
681     @@Description:
682     @@@lang:en
683     @@@@:
684     Tests whether the content media type of this element matches to
685     a type or not.
686     @@Param:
687     @@@Name: mediaType
688     @@@Type: MediaTypeURI
689     @@@Description:
690     @@@@lang:en
691     @@@@@:
692     A media type URI reference to test against.
693     @@Param:
694     @@@Name: mediaTypeDefault
695     @@@Type: MediaTypeURI
696     @@@Description:
697     @@@@lang:en
698     @@@@@:
699     The default media type for this element.
700     @@@InCase:
701     @@@@Value:
702     @@@@@is-null:1
703     @@@@Description:
704     @@@@@lang:en
705     @@@@@@:
706     No default type provided. All <P::mediaType> will match.
707     @@Return:
708     @@@Type:
709     DOMMain:boolean
710     @@@Description:
711     @@@@lang:en
712     @@@@@:
713     Whether this element is of <P::mediaType> or not.
714 wakaba 1.2 @@@PerlDef:
715     if (defined $mediaType) {
716     __DEEP{
717     my $ctn = $self-><M::ManakaiDISElement.disGetAttribute>
718     (<Q::dis:ContentType>);
719     my $ct;
720     $ct = $ctn-><AG::ManakaiDISElement.qnameValueURI> if $ctn;
721     $ct = $defaultMediaType unless defined $ct;
722     my $res = $self-><AG::ManakaiDISNode.ownerDISDocument>
723     -><AG::ManakaiDISDocument.disDatabase>
724     -><M::ManakaiDISDatabase.getResource> ($ct);
725     $res-><AS::ManakaiDISResourceDefinition.isReferred> ($ctn or $self);
726     unless ($res-><M::ManakaiDISResourceDefinition.subsetOfURI> ($ct)) {
727     $r = false;
728     } else {
729     $r = true;
730     }
731     }__;
732     } else {
733     $r = true;
734     }
735 wakaba 1.1
736     @Method:
737     @@Name: prefixToURI
738     @@Description:
739     @@@lang:en
740     @@@@:
741     Converts a namespace prefix into associated URI reference.
742     @@Param:
743     @@@Name: prefix
744     @@@Type:
745     swcfg21:SWCFGString
746     @@@Description:
747     @@@@lang:en
748     @@@@@:
749     A namespace prefix to look for.
750     @@@InCase:
751     @@@@Value:
752     @@@@@is-null:1
753     @@@@Description:
754     @@@@@lang:en
755     @@@@@@:
756     Returns the default namespace URI.
757     @@NodeParam:
758     @@Return:
759     @@@Type:
760     swcfg21:SWCFGString
761     @@@Description:
762     @@@@lang:en
763     @@@@@: The URI references associated.
764     @@@UndeclaredPrefixException:
765     @@@PerlDef:
766     if (defined $param) {
767     __DEEP{
768     $r = $self-><M::swcfg21:SWCFGNode.lookupNamespaceURI> ($prefix);
769     }__;
770     unless (defined $r) {
771     __EXCEPTION{UNDECLARED_NS_PREFIX_ERR::
772     infoset:prefix => {$prefix},
773     MDOMX:param-name => 'prefix',
774     DIS:sourceNode => {$node},
775     }__;
776     }
777     } else {
778     ## TODO: default namespace
779     }
780    
781     @Method:
782     @@QName: qnameToURI
783     @@Description:
784     @@@lang:en
785     @@@@:
786     Converts a qualified name (<TYPE::dis:TypeQName>) to
787     an expanded URI reference.
788     @@Param:
789     @@@Name: qname
790     @@@Type:
791     dis:TypeQName
792     @@@Description:
793     @@@@lang:en
794     @@@@@:
795     A qualified name.
796     @@NodeParam:
797     @@Return:
798     @@@Type: AnyURI
799     @@@Description:
800     @@@@lang:en
801     @@@@@:
802     The expanded URI reference.
803     @@@UndeclaredPrefixException:
804     @@@PerlDef:
805     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
806     my ($prefix, $lname) = split /:/, $qname;
807     __DEEP{
808     if (defined $lname) {
809     $r = $self-><M::ManakaiDISElement.prefixToURI> ($prefix) . $lname;
810     } else { ## In default namespace
811     $r = $self-><M::ManakaiDISElement.prefixToURI> (null) . $prefix;
812     }
813     }
814    
815     @Method:
816     @@QName: qnameToPair
817     @@Description:
818     @@@lang:en
819     @@@@:
820     Converts a qualified name (<TYPE::dis:TypeQName>) to
821     a pair of namespace URI and local name.
822     @@Param:
823     @@@Name: qname
824     @@@Type:
825     dis:TypeQName
826     @@@Description:
827     @@@@lang:en
828     @@@@@:
829     A qualified name.
830     @@NodeParam:
831     @@Return:
832     @@@Type:
833     Perl:ARRAY
834     @@@Description:
835     @@@@lang:en
836     @@@@@:
837     A list of namespace URI and local name.
838     @@@UndeclaredPrefixException:
839     @@@PerlDef:
840     $qname =~ s/^\s+//; $qname =~ s/\s+$//;
841     my ($prefix, $lname) = split /:/, $qname;
842     __DEEP{
843     if (defined $lname) {
844     $r = [$self-><M::ManakaiDISElement.prefixToURI> ($prefix), $lname];
845     } else { ## In default namespace
846     $r = [$self-><M::ManakaiDISElement.prefixToURI> (null), $prefix];
847     }
848     }
849    
850     @Method:
851     @@Name: typeforqnamesToURI
852     @@Description:
853     @@@lang:en
854     @@@@:
855     Converts a <TYPE::dis:TypeForQNames>
856     into an expanded URI reference.
857     @@Param:
858     @@@Name: tfqnames
859     @@@Type:
860     dis:TypeForQNames
861     @@@Description:
862     @@@@lang:en
863     @@@@@:
864     A <TYPE::dis:TypeForQNames> to identify a resource.
865     @@Param:
866     @@@Name: defaultTypeURI
867     @@@Type: NameURI
868     @@@Description:
869     @@@@lang:en
870     @@@@@:
871     A name URI reference used if it is missing from
872     <P::tfqnames>.
873     @@@InCase:
874     @@@@Value:
875     @@@@@is-null:1
876     @@@@Description:
877     @@@@@lang:en
878     @@@@@@:
879     Equivalent to <Q::DOMMain:any>.
880     @@Param:
881     @@@Name: defaultForURI
882     @@@Type: ForURI
883     @@@Description:
884     @@@@lang:en
885     @@@@@:
886     A <QUOTE::for> URI reference used if it is missing from
887     <P::tfqnames>.
888     @@@InCase:
889     @@@@Value:
890     @@@@@is-null:1
891     @@@@Description:
892     @@@@@lang:en
893     @@@@@@:
894     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
895     @@NodeParam:
896     @@Return:
897     @@@Type:
898     DISCore:TypeForURI
899     @@@Description:
900     @@@@lang:en
901     @@@@@:
902     The <TYPE::dis:TypeForQNames>-expanded URI references.
903     @@@UndeclaredPrefixException:
904     @@@PerlDef:
905     my ($typeq, $forq) = split /\s*::\s*/, $tfqnames, 2;
906     my ($typeURI, $forURI);
907     if (defined $forq) {
908     __DEEP{
909     $typeURI = $typeq eq ''
910     ? defined $defaultTypeURI ? $defaultTypeURI
911     : <Q::DOMMain:any>
912     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
913     }__;
914     if (length $forq) {
915     $forURI = $self-><M::ManakaiDISElement.qnameToURI> ($forq, %opt);
916     } else {
917     $forURI = <Q::ManakaiDOM:all>;
918     }
919     } else { ## "For" omitted
920     __DEEP{
921     $typeURI = $typeq eq ''
922     ? defined $defaultTypeURI ? $defaultTypeURI
923     : <Q::DOMMain:any>
924     : $self-><M::ManakaiDISElement.qnameToURI> ($typeq, %opt);
925     }__;
926     $for = defined $defaultForURI ? $defaultForURI : <Q::ManakaiDOM:all>;
927     }
928     __DEEP{
929     $r = $self-><AG::swcfg21:SWCFGNode.ownerDocument>
930     -><AG::swcfg21:SWCFGDocument.implementation>
931     -><M::DISImplementation.typeforqnamesToURI>
932     ($typeURI, $forURI);
933     }__;
934 wakaba 1.2
935     @Method:
936     @@Name: disGetAttribute
937     @@enDesc:
938     Gets an attribute node.
939     @@Param:
940     @@@Name: attrName
941     @@@Type: AnyURI
942     @@@enDesc:
943     The name expanded URI of the node to retrieve.
944     @@ForParam:
945     @@ForpParam:
946     @@MediaTypeParam:
947     @@MediaTypeDefaultParam:
948     @@Return:
949     @@@Type: ManakaiDISElement
950     @@@enDesc:
951     The attribute (property) element node.
952     @@@nullCase:
953     @@@@enDesc:
954     No attribute node found.
955     @@@PerlDef:
956     for my $c (@{$self->{src}-><AG::ManakaiDISElement.disChildElements>}) {
957     if ($c-><AG::DISElement.expandedURI> eq $attrName and
958     $c-><AG::ManakaiDISElement.forMatch> ($forArg, $forpArg) and
959     $c-><AG::ManakaiDISElement.mediaTypeMatch>
960     ($mediaType, $mediaTypeDefault)) {
961     $r = $c;
962     last;
963     }
964     }
965    
966     @Method:
967     @@Name: disGetAttributeList
968     @@enDesc:
969     Gets attribute nodes.
970     @@AttrNameParam:
971     @@ForParam:
972     @@ForpParam:
973     @@MediaTypeParam:
974     @@MediaTypeDefaultParam:
975     @@Return:
976     @@@Type: ManakaiDISElementList
977     @@@enDesc:
978     The attribute (property) element nodes.
979     @@@PerlDef:
980     $r = bless [], <ClassName::ManakaiDISElementList>;
981     for my $c (@{$self->{src}-><AG::ManakaiDISElement.disChildElements>}) {
982     if ($c-><AG::DISElement.expandedURI> eq $attrName and
983     $c-><AG::ManakaiDISElement.forMatch> ($forArg, $forpArg) and
984     $c-><AG::ManakaiDISElement.mediaTypeMatch>
985     ($mediaType, $mediaTypeDefault)) {
986     push @$r, $c;
987     }
988     }
989    
990     @Attr:
991     @@Name: disChildElements
992     @@Type: ManakaiDISElementList
993     @@enDesc:
994     A list of child elements.
995     @@Get:
996     @@@enDesc:
997     The current snapshot of child nodes.
998     @@@PerlDef:
999     $r = bless [@{$self-><AG::swcfg21:SWCFGElement.childNodes>}],
1000     <ClassName::ManakaiDISElementList>;
1001    
1002     @Attr:
1003     @@Name: qnameValueURI
1004     @@enDesc:
1005     The element value (written as <TYPE::dis:TypeQName>), as URI reference.
1006     \
1007     {NOTE:: What should be if list value?
1008     \
1009     }
1010     @@Get:
1011     @@@Type:AnyURI
1012     @@@nullCase:
1013     @@@@enDesc:
1014     No value.
1015     @@@UndeclaredPrefixException:
1016     @@@GetProp:
1017     my $v = $self-><AG::swcfg21:SWCFGNode.value>;
1018     if (defined $v and not ref $v eq 'ARRAY') {
1019     __DEEP{
1020     $r = $self-><AG::ManakaiDISElement.qnameToURI> ($v);
1021     }__;
1022     } else {
1023     $r = null;
1024     }
1025    
1026     @Attr:
1027     @@Name: typeforqnamesValueURI
1028     @@enDesc:
1029     The element value (written as <TYPE::dis:TypeForQNames>),
1030     as URI reference.
1031     \
1032     {NOTE:: What should be if list value?
1033     \
1034     }
1035     @@Get:
1036     @@@Type:ResourceURI
1037     @@@nullCase:
1038     @@@@enDesc:
1039     No value.
1040     @@@UndeclaredPrefixException:
1041     @@@GetProp:
1042     my $v = $self-><AG::swcfg21:SWCFGNode.value>;
1043     if (defined $v and not ref $v eq 'ARRAY') {
1044     __DEEP{
1045     $r = $self-><AG::ManakaiDISElement.typeforqnamesToURI> ($v);
1046     }__;
1047     } else {
1048     $r = null;
1049     }
1050 wakaba 1.1 ##DISElement
1051    
1052     ClsDef:
1053 wakaba 1.2 @ClsQName: ManakaiDISElementList
1054     @enDesc:
1055     @@lang:en
1056     @@@:
1057     Lists of elements.
1058     \
1059     {NOTE:: <Class::ManakaiDISElementList> is <QUOTE::dead>;
1060     later changes to the tree does not affect this type of objects.
1061     \
1062     }
1063     ##DISElementList
1064    
1065     ClsDef:
1066 wakaba 1.1 @ClsQName: ManakaiDISComment
1067     @ClsISA:
1068     swcfg21:ManakaiSWCFGComment
1069     @ClsISA: ManakaiDISNode
1070     @Description:
1071     @@lang:en
1072     @@@:
1073     <QUOTE::dis> comment node objects.
1074     ##DISComment
1075    
1076     ClsDef:
1077     @ClsQName: ManakaiDISDocumentFragment
1078     @ClsISA:
1079     swcfg21:ManakaiSWCFGDocumentFragment
1080     @ClsISA: ManakaiDISNode
1081     @Description:
1082     @@lang:en
1083     @@@:
1084     <QUOTE::dis> document fragment node objects.
1085     ##DISDocumentFragment
1086    
1087     ClsDef:
1088     @ClsQName: ManakaiDISDocument
1089     @ClsISA:
1090     swcfg21:ManakaiSWCFGDocument
1091     @ClsISA: ManakaiDISNode
1092     @Description:
1093     @@lang:en
1094     @@@:
1095     <QUOTE::dis> document node objects.
1096 wakaba 1.2
1097     @Attr:
1098     @@Name: disDatabase
1099     @@enDesc:
1100     Associated <QUOTE::dis> database.
1101    
1102     @@Type: ManakaiDISDatabase
1103     @@Get:
1104     @@@NoDBException:
1105     @@@PerlDef:
1106     if ($self->{<Q::TreeCore:node>}->{<Q::db>}) {
1107     $self = $self->{<Q::TreeCore:node>}->{<Q::db>};
1108     } else {
1109     __EXCEPTION{NO_ASSOCIATED_DB_ERR}__;
1110     }
1111     @@Set:
1112     @@@PerlDef:
1113     $self->{<Q::TreeCore:node>}->{<Q::db>} = $given;
1114     require Scalar::Util;
1115     Scalar::Util::weaken ($self->{<Q::TreeCore:node>}->{<Q::db>});
1116 wakaba 1.1 ##DISDocument
1117 wakaba 1.2
1118     PropDef:
1119     @QName: db
1120     @enDesc:
1121     Associated <QUOTE::dis> database.
1122     @rdfs:domain: ManakaiDISDocument
1123     @rdfs:range: ManakaiDISDatabase
1124    
1125     ## -- Definition object database
1126    
1127     ClsDef:
1128     @ClsQName: ManakaiDISDatabase
1129     @enDesc:
1130     Resource database created from <QUOTE::dis> source data.
1131    
1132     @Method:
1133     @@Name: typeforurisToURI
1134     @@Description:
1135     @@@lang:en
1136     @@@@:
1137     Converts a pair of name URI reference and <QUOTE::for> URI reference
1138     into a <TYPE::dis:TypeForQNames>-expanded URI reference.
1139     @@Param:
1140     @@@Name: typeURI
1141     @@@Type: NameURI
1142     @@@Description:
1143     @@@@lang:en
1144     @@@@@:
1145     A URI reference to identify a resource.
1146     @@@InCase:
1147     @@@@Value:
1148     @@@@@is-null:1
1149     @@@@Description:
1150     @@@@@lang:en
1151     @@@@@@:
1152     Equivalent to <Q::DOMMain:any> (for historical reason).
1153     @@Param:
1154     @@@Name: forURI
1155     @@@Type: ForURI
1156     @@@Description:
1157     @@@@lang:en
1158     @@@@@:
1159     A <QUOTE::for> URI reference.
1160     @@@InCase:
1161     @@@@Value:
1162     @@@@@is-null:1
1163     @@@@Description:
1164     @@@@@lang:en
1165     @@@@@@:
1166     Equivalent to <QUOTE::for all>, i.e. <Q::ManakaiDOM:all>.
1167     @@Return:
1168     @@@Type:
1169     DISCore:TypeForURI
1170     @@@Description:
1171     @@@@lang:en
1172     @@@@@:
1173     The <TYPE::dis:TypeForQNames>-expanded URI references.
1174     @@@PerlDef:
1175     $typeURI = <Q::DOMMain:any> unless defined $typeURI;
1176     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
1177     if ($forURI eq <Q::ManakaiDOM:all>) {
1178     $r = $typeURI;
1179     } else {
1180     ## NOTE: [RFC 3986]
1181     ## fragment := *(pchar / "/" / "?")
1182     ## pchar := unreserved / pct-encoded / sub-delims / [:@]
1183     ## unreserved := ALPHA / DIGIT / [._~-]
1184     ## sub-delims := [!$&'()*+,;=]
1185     ## NOTE: [XPointer Framework]
1186     ## SchemeData := *EscapedData
1187     ## EscapedData := NormalChar / "^(" / "^)" / "^^"
1188     ## / "(" SchemeData ")"
1189     ## NormalChar := UnicodeChar - [()^]
1190     for my $uri ($typeURI, $forURI) {
1191     $uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge;
1192     }
1193     $r =qq<data:,200411tf#xmlns(t=data:,200411tf%23)>.
1194     qq<t:tf($typeURI,$forURI)>;
1195     }
1196    
1197     @Method:
1198     @@Name: getModule
1199     @@Description:
1200     @@@lang:en
1201     @@@@:
1202     Returns a <QUOTE::dis> module definition.
1203     @@Param:
1204     @@@Name: modURI
1205     @@@Type: ModuleURI
1206     @@@Description:
1207     @@@@lang:en
1208     @@@@@:
1209     A <QUOTE::dis> module URI reference.
1210     @@Return:
1211     @@@Type: ManakaiDISModuleDefinition
1212     @@@Description:
1213     @@@@lang:en
1214     @@@@@:
1215     The module definition.
1216     @@@PerlDef:
1217     if (defined $self->{modDef}->{$modURI}) {
1218     $r = $self->{modDef}->{$modURI};
1219     } else {
1220     $r = $self->{modDef}->{$modURI}
1221     = bless {
1222     uri => $modURI,
1223     db => $self,
1224     for => <Q::ManakaiDOM:all>,
1225     forp => [],
1226     }, <ClassName::ManakaiDISModuleDefinition>;
1227     require Scalar::Util;
1228     Scalar::Util::weaken ($r->{db});
1229     }
1230    
1231     @Method:
1232     @@Name: getFor
1233     @@Description:
1234     @@@lang:en
1235     @@@@:
1236     Returns a <QUOTE::for> definition object.
1237     @@Param:
1238     @@@Name: forURI
1239     @@@Type: ForURI
1240     @@@Description:
1241     @@@@lang:en
1242     @@@@@:
1243     A <QUOTE::for> URI reference.
1244     @@@InCase:
1245     @@@@Value:
1246     @@@@@is-null:1
1247     @@@@Description:
1248     @@@@@lang:en
1249     @@@@@@:
1250     Defaulted to <Q::ManakaiDOM:all>.
1251     @@Return:
1252     @@@Type: ManakaiDISForDefinition
1253     @@@PerlDef:
1254     $forURI = <Q::ManakaiDOM:all> unless defined $forURI;
1255     if (defined $self->{forDef}->{$forURI}) {
1256     $r = $self->{forDef}->{$forURI};
1257     } else {
1258     $r = $self->{forDef}->{$forURI}
1259     = bless {
1260     uri => $forURI,
1261     isa => {<Q::ManakaiDOM:all> => true},
1262     revISA => {},
1263     db => $self,
1264     }, <ClassName::ManakaiDISForDefinition>;
1265     $self->{forDef}->{<Q::ManakaiDOM:all>}->{revISA}->{$forURI} = true;
1266     require Scalar::Util;
1267     Scalar::Util::weaken ($r->{db});
1268     }
1269    
1270     @Method:
1271     @@Name: getResource
1272     @@Description:
1273     @@@lang:en
1274     @@@@:
1275     Returns a <QUOTE::dis> resource definition.
1276     @@Param:
1277     @@@Name: resURI
1278     @@@Type: ResourceURI
1279     @@@Description:
1280     @@@@lang:en
1281     @@@@@:
1282     A <QUOTE::dis> resource URI reference.
1283     @@@InCase:
1284     @@@@nullValue:
1285     @@@@Description:
1286     @@@@@lang:en
1287     @@@@@@:
1288     Defaulted to <Q::DOMMain:any>.
1289     @@Return:
1290     @@@Type: ManakaiDISResourceDefinition
1291     @@@Description:
1292     @@@@lang:en
1293     @@@@@:
1294     The resource definition.
1295     @@@PerlDef:
1296     $resURI = <Q::DOMMain:any> unless defined $resURI;
1297     if (defined $self->{resDef}->{$resURI}) {
1298     $r = $self->{resDef}->{$resURI};
1299     } else {
1300     $r = $self->{resDef}->{$resURI}
1301     = bless {
1302     uri => $resURI,
1303     subOf => {},
1304     supOf => {},
1305     db => $self,
1306     for => <Q::ManakaiDOM:all>,
1307     forp => [],
1308     }, <ClassName::ManakaiDISResourceDefinition>;
1309     require Scalar::Util;
1310     Scalar::Util::weaken ($r->{db});
1311     }
1312     ##DISDatabase
1313    
1314     ClsDef:
1315     @ClsQName: ManakaiDISModuleDefinition
1316     @enDesc:
1317     <QUOTE::dis> module definitions.
1318     @ClsISA: ManakaiDISPropertyAccessor
1319    
1320     @Attr:
1321     @@Name: uri
1322     @@Type: ModuleURI
1323     @@Description:
1324     @@@lang:en
1325     @@@@:
1326     The URI reference of this <QUOTE::dis> module.
1327     @@Get:
1328     @@@PerlDef:
1329     $r = $self->{uri};
1330    
1331     @Attr:
1332     @@Name: nameURI
1333     @@Type: NameURI
1334     @@enDesc:
1335     The URI reference of this module, without
1336     <QUOTE::for> identifier.
1337     @@Get:
1338     @@@PropDef:
1339     $r = $self->{uri};
1340    
1341     @Attr:
1342     @@Name: localName
1343     @@enDesc:
1344     The local name of this module.
1345     @@Type:
1346     DISCore:localName
1347     @@Get:
1348     @@@PerlDef:
1349     $r = $self->{localName};
1350    
1351     @Attr:
1352     @@Name: namespaceURI
1353     @@Type: AnyURI
1354     @@enDesc:
1355     The namespace URI of the name of this resource.
1356     @@Get:
1357     @@@PerlDef:
1358     $r = $self->{namespaceURI};
1359    
1360     @Attr:
1361     @@Name: forURI
1362     @@Type: ForURI
1363     @@enDesc:
1364     The <QUOTE::for> URI reference for which this module is defined.
1365     @@Get:
1366     @@@PerlDef:
1367     $r = $self->{for};
1368    
1369     @Attr:
1370     @@Name: isDefined
1371     @@Description:
1372     @@@lang:en
1373     @@@@:
1374     Whether this module is defined or not.
1375     @@Type:
1376     DOMMain:boolean
1377     @@Get:
1378     @@@PerlDef:
1379     $r = $self->{<Q::isDefined>};
1380    
1381     ## TODO: exception handler
1382     ##DISModuleDefinition
1383    
1384     ClsDef:
1385     @ClsQName: ManakaiDISForDefinition
1386     @Description:
1387     @@lang:en
1388     @@@:
1389     <QUOTE::dis> <QUOTE::for> definitions.
1390    
1391     @Attr:
1392     @@Name: uri
1393     @@Type: ForURI
1394     @@Description:
1395     @@@lang:en
1396     @@@@:
1397     The URI reference of this <QUOTE::for>.
1398     @@Get:
1399     @@@PerlDef:
1400     $r = $self->{uri};
1401    
1402     @Method:
1403     @@Name: isaURI
1404     @@Description:
1405     @@@lang:en
1406     @@@@:
1407     Whether this <QUOTE::for> is-a another <QUOTE::for> or not.
1408     @@Param:
1409     @@@Name: superURI
1410     @@@Type: ForURI
1411     @@@Description:
1412     @@@@lang:en
1413     @@@@@:
1414     Another <QUOTE::for> URI reference to test.
1415     @@Return:
1416     @@@Type:
1417     DOMMain:boolean
1418     @@@TrueCase:
1419     @@@@enDesc:
1420     <P::superURI> is a super-<QUOTE::for> of this <QUOTE::for>.
1421     @@@FalseCase:
1422     @@@@enDesc:
1423     <P::superURI> is not a super-<QUOTE::for> of this <QUOTE::for>.
1424     @@@PerlDef:
1425     $r = $self->{uri} eq $superURI ? true : $self->{isa}->{$superURI};
1426    
1427     @Attr:
1428     @@Name: isDefined
1429     @@Description:
1430     @@@lang:en
1431     @@@@:
1432     Whether this <QUOTE::for> is already defined or not.
1433     @@Type:
1434     DOMMain:boolean
1435     @@Get:
1436     @@@TrueCase:
1437     This <QUOTE::for> is already defined.
1438     @@@FalseCase:
1439     This <QUOTE::for> is not defined.
1440     @@@PerlDef:
1441     $r = $self->{<Q::isDefined>};
1442    
1443     @Attr:
1444     @@Name: isReferred
1445     @@Description:
1446     @@@lang:en
1447     @@@@:
1448     Whether this <QUOTE::for> is referred somewhere or not.
1449     @@Type:
1450     DOMMain:any
1451     @@Get:
1452     @@@InCase:
1453     @@@@Type:ManakaiDISElement
1454     @@@@enDesc:
1455     This <QUOTE::for> is referred by the element.
1456     @@@nullCase:
1457     This <QUOTE::for> is not referred.
1458     @@@PerlDef:
1459     $r = $self->{<Q::isReferred>};
1460     @@Set:
1461     @@@InCase:
1462     @@@@Type:ManakaiDISElement
1463     @@@@enDesc:
1464     This <QUOTE::for> is referred by the element.
1465     @@@PerlDef:
1466     $self->{<Q::isReferred>} = true if $given;
1467    
1468     @Attr:
1469     @@Name: definingModule
1470     @@Description:
1471     @@@lang:en
1472     @@@@:
1473     The <QUOTE::dis> module in which this <QUOTE::for> is defined.
1474     @@Type: ManakaiDISModuleDefinition
1475     @@Get:
1476     @@@Description:
1477     @@@@lang:en
1478     @@@@@:
1479     The module object.
1480     @@@NullCase:
1481     @@@@Description:
1482     @@@@@lang:en
1483     @@@@@@:
1484     This <QUOTE::for> is not associated to any module.
1485     @@@PerlDef:
1486     $r = $self->{db}
1487     -><M::ManakaiDISDatabase.getResource>
1488     ($self->{<Q::definingModule>})
1489     if defined $self->{<Q::definingModule>};
1490    
1491     @Method:
1492     @@Name: readDefinition
1493     @@enDesc:
1494     Reads <QUOTE::for> definition and sets attributes.
1495     @@Param:
1496     @@@Name: forDefElement
1497     @@@Type: ManakaiDISElement
1498     @@@Description:
1499     @@@@lang:en
1500     @@@@@:
1501     A <CODE::ForDef> element containing definition of this <QUOTE::for>.
1502     @@Return:
1503     @@@RaiseException:
1504     @@@@@:FOR_ALREADY_DEFINED_ERR
1505     @@@@Description:
1506     @@@@@lang:en
1507     @@@@@@:
1508     The <QUOTE::for> definition for this <QUOTE::for> is already read.
1509     @@@PerlDef:
1510     if ($self->{<Q::isDefined>}) {
1511     __EXCEPTION{FOR_ALREADY_DEFINED_ERR}__;
1512     }
1513     ## TODO:
1514     $self->{<Q::isDefined>} = true;
1515    
1516     ## TODO: exception handler
1517     ##DISForDefinition
1518    
1519     ClsDef:
1520     @ClsQName: ManakaiDISResourceDefinition
1521     @enDesc:
1522     <QUOTE::dis> resource definitions.
1523     @ClsISA: ManakaiDISPropertyAccessor
1524    
1525     @Attr:
1526     @@Name: uri
1527     @@Type: ResourceURI
1528     @@Description:
1529     @@@lang:en
1530     @@@@:
1531     The URI reference of this <QUOTE::dis> resource.
1532     @@Get:
1533     @@@PerlDef:
1534     $r = $self->{uri};
1535    
1536     @Attr:
1537     @@Name: nameURI
1538     @@Type: NameURI
1539     @@enDesc:
1540     The URI reference of this <QUOTE::dis> resource, without
1541     <QUOTE::for> identifier.
1542     @@Get:
1543     @@@nullCase:
1544     @@@@enDesc:
1545     This resource does not have its name URI reference.
1546     @@@PropDef:
1547     $r = $self->{uri};
1548    
1549     @Attr:
1550     @@Name: localName
1551     @@enDesc:
1552     The local name of this resource.
1553     @@Type:
1554     DISCore:localName
1555     @@Get:
1556     @@@nullCase:
1557     @@@@enDesc:
1558     This resource does not have its local name.
1559     @@@PerlDef:
1560     $r = $self->{localName};
1561    
1562     @Attr:
1563     @@Name: namespaceURI
1564     @@Type: AnyURI
1565     @@enDesc:
1566     The namespace URI of the name of this resource.
1567     @@Get:
1568     @@@nullCase:
1569     The name of this resource does not have its namespace
1570     or this resource does not have its name.
1571     @@@PerlDef:
1572     $r = $self->{namespaceURI};
1573    
1574     @Attr:
1575     @@Name: isAnonymous
1576     @@enDesc:
1577     Whether this <QUOTE::dis> resource has name or not.
1578     @@Type:
1579     DOMMain:boolean
1580     @@Get:
1581     @@@TrueCase:
1582     This resource does not have any global unique name.
1583     <A::ManakaiDISResourceDefinition.uri> is a temporary URI reference.
1584     @@@FalseCase:
1585     This resource does have its formal name.
1586     <A::ManakaiDISResourceDefinition.uri> is a URI reference
1587     generated from the name and the <QUOTE::for> URI reference
1588     of this resource.
1589     @@@PerlDef:
1590     $r = $self->{<Q::isAnon>};
1591    
1592     @Attr:
1593     @@Name: forURI
1594     @@enDesc:
1595     The <QUOTE::for> URI reference for which this resource is defined.
1596     @@Type:ForURI
1597     @@Get:
1598     @@@PerlDef:
1599     $r = $self->{for};
1600    
1601     @Attr:
1602     @@Name: forpURI
1603     @@enDesc:
1604     The <QUOTE::for+> URI references for which this resource is defined.
1605     @@Type: ForURIList
1606     @@Get:
1607     @@@PropDef:
1608     $r = $self->{forp};
1609    
1610     @Method:
1611     @@Name: subsetOfURI
1612     @@Description:
1613     @@@lang:en
1614     @@@@:
1615     Whether this resource is a subset of another resource or not.
1616     @@Param:
1617     @@@Name: superURI
1618     @@@Type: ResourceURI
1619     @@@Description:
1620     @@@@lang:en
1621     @@@@@:
1622     Another resource URI reference to test.
1623     @@Return:
1624     @@@Type:
1625     DOMMain:boolean
1626     @@@TrueCase:
1627     @@@@enDesc:
1628     <P::superURI> is a super-resource of this resource.
1629     @@@FalseCase:
1630     @@@@enDesc:
1631     <P::superURI> is not a super-resource of this resource.
1632     @@@PerlDef:
1633     $r = $superURI eq $self->{uri} ? true : $self->{subOf}->{$superURI};
1634    
1635     @Attr:
1636     @@Name: isDefined
1637     @@Description:
1638     @@@lang:en
1639     @@@@:
1640     Whether this resource is already defined or not.
1641     @@Type:
1642     DOMMain:boolean
1643     @@Get:
1644     @@@TrueCase:
1645     This resource is already defined.
1646     @@@FalseCase:
1647     This resource is not defined.
1648     @@@PerlDef:
1649     $r = $self->{<Q::isDefined>};
1650    
1651     @Attr:
1652     @@Name: isReferred
1653     @@Description:
1654     @@@lang:en
1655     @@@@:
1656     Whether this resource is referred or not.
1657     @@Type:
1658     DOMMain:any
1659     @@Get:
1660     @@@InCase:
1661     @@@@Type:ManakaiDISElement
1662     @@@@enDesc:
1663     This resource is referred by the element.
1664     @@@nullCase:
1665     This resource is not referred.
1666     @@@PerlDef:
1667     $r = $self->{<Q::isReferred>};
1668     @@Set:
1669     @@@InCase:
1670     @@@@Type:ManakaiDISElement
1671     @@@@enDesc:
1672     This resource is referred by this element.
1673     @@@PerlDef:
1674     $self->{<Q::isReferred>} = $given if $given;
1675    
1676     @Attr:
1677     @@Name: definingModule
1678     @@Description:
1679     @@@lang:en
1680     @@@@:
1681     The <QUOTE::dis> module in which this resource is defined.
1682     @@Type: ManakaiDISModuleDefinition
1683     @@Get:
1684     @@@Description:
1685     @@@@lang:en
1686     @@@@@:
1687     The module object.
1688     @@@NullCase:
1689     @@@@Description:
1690     @@@@@lang:en
1691     @@@@@@:
1692     This resource is not associated to any module.
1693     @@@PerlDef:
1694     $r = $self->{db}
1695     -><M::ManakaiDISDatabase.getModule>
1696     ($self->{<Q::definingModule>})
1697     if defined $self->{<Q::definingModule>};
1698     @@Set:
1699     @@@Description:
1700     @@@@lang:en
1701     @@@@@:
1702     The module object to which the <QUOTE::defining module> is set.
1703     @@@PerlDef:
1704     $self->{<Q::defininingModule>}
1705     = $given-><AG::ManakaiDISModuleDefinition.uri>;
1706    
1707    
1708     ## TODO: exception handler
1709     ##DISResourceDefinition
1710    
1711     ClsDef:
1712     @ClsQName: ManakaiDISPropertyAccessor
1713     @enDescription:
1714     Accessor methods for resource or module properties.
1715    
1716     @Method:
1717     @@Name: getPropertyText
1718     @@enDesc:
1719     Gets property value text.
1720     @@PropNameParam:
1721     @@Param:
1722     @@@Name:default
1723     @@@Type:
1724     swcfg21:SWCFGString
1725     @@@enDesc:
1726     The default value that is returned if no explicit property
1727     value specification found for this resource.
1728     @@@nullCase:
1729     @@@@enDesc:
1730     No default value supplied; <DOM::null> is returned if
1731     no value specified.
1732     @@Return:
1733     @@@Type:
1734     swcfg21:SWCFGString
1735     @@@enDesc:
1736     The property value string.
1737     @@@nullCase:
1738     @@@@enDesc:
1739     No value nor default value has specified.
1740     @@@PerlDef:
1741     if (exists $self->{$propName}) {
1742     $r = defined $self->{$propName} ? $self->{$propName} : $default;
1743     } elsif ($self->{src}) {
1744     $r = $self->{src}-><M::ManakaiDISElement.disGetAttribute>
1745     ($propName, for_arg => $self->{for},
1746     forp_arg => $self->{forp});
1747     $self->{$propName} = $r;
1748     $r = $default unless defined $r;
1749     } else {
1750     $r = $default;
1751     }
1752    
1753     @Method:
1754     @@Name: getPropertyResource
1755     @@enDesc:
1756     Gets property value resource.
1757     @@PropNameParam:
1758     @@Return:
1759     @@@Type: ManakaiDISResourceDefinition
1760     @@@enDesc:
1761     The property value resource.
1762     @@@nullCase:
1763     @@@@enDesc:
1764     No value has specified.
1765     @@@PerlDef:
1766     if (defined $self->{$propName}) {
1767     $r = $self->{db}-><M::ManakaiDISDatabase.getResource>
1768     ($self->{$propName});
1769     } else {
1770     $r = null;
1771     }
1772    
1773     @Method:
1774     @@Name: addPropertyResourceList
1775     @@enDesc:
1776     Adds a resource to a resource-list property value.
1777     \
1778     {ISSUE:: Should an exception be thrown if the property is
1779     not of list?
1780     \
1781     }
1782     @@PropNameParam:
1783     @@Param:
1784     @@@Name: res
1785     @@@Type: ManakaiDISResourceDefinition
1786     @@@enDesc:
1787     A resource to add.
1788     @@Return:
1789     @@@PerlDef:
1790     if (ref $self->{$propName} eq 'ARRAY') {
1791     push @{$self->{$propName}}, $res->{uri};
1792     } elsif (not defined $self->{$propName}) {
1793     $self->{$propName} = [$res->{uri}];
1794     }
1795    
1796     ##DISPropertyAccessor
1797    
1798     PropDef:
1799     @QName:isAnon
1800     @Description:
1801     @@lang:en
1802     @@@:
1803     Whether the subject resource is anonymous or not.
1804     @Type:
1805     DOMMain:boolean
1806    
1807     PropDef:
1808     @QName:isDefined
1809     @Description:
1810     @@lang:en
1811     @@@:
1812     Whether the subject resource is defined or not.
1813    
1814     PropDef:
1815     @Qname:isReferred
1816     @Description:
1817     @@lang:en
1818     @@@:
1819     Whether the subject resource is referred or not.
1820     @Type:
1821     DOMMain:any
1822    
1823     PropDef:
1824     @QName:definingModule
1825     @Description:
1826     @@lang:en
1827     @@@:
1828     The <QUOTE::dis> module in which the subject resource is defined.
1829     @rdfs:domain:
1830     DISCore:Module
1831 wakaba 1.1
1832     ## -- Datatypes
1833    
1834     URITypeDef:
1835     @QName: ForURI
1836     @Description:
1837     @@lang:en
1838     @@@:
1839     <QUOTE::For> URI references.
1840    
1841     DataTypeDef:
1842     @QName: ForURIList
1843     @Description:
1844     @@lang:en
1845     @@@:
1846     References to the array containing <QUOTE::for> URI references.
1847    
1848     URITypeDef:
1849     @QName: MediaTypeURI
1850     @Description:
1851     @@lang:en
1852     @@@:
1853     Media type URI references.
1854    
1855     ## -- Exceptions
1856    
1857     XParamDef:
1858     @QName: sourceNode
1859     @Description:
1860     @@lang:en
1861     @@@:
1862     The node from which the string has come.
1863     @Type: DISNode

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24