/[suikacvs]/messaging/manakai/lib/Message/DOM/DOMImplementationSource.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/DOMImplementationSource.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sat Jul 7 09:11:05 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
Changes since 1.1: +1 -2 lines
Error occurred while calculating annotation data.
++ manakai/t/ChangeLog	7 Jul 2007 09:10:55 -0000
	* DOM-Document.t: New test for ARRAY qualified name
	is added.  Set |strict_error_checking| to false
	for a test not to be raised by |create_attribute_ns|.

2007-07-07  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	7 Jul 2007 09:09:46 -0000
	* Attr.pm (create_attribute, create_attribute_ns): Implemented.

	* DOMDocument.pm: Load character classes from |Char::Class::XML|.
	(compat_mode): Check |defined| not to be warned as "uninitialized"
	when |{manakai_compat_mode}| is |undef|.

	* DOMException.pm (INVALID_CHARACTER_ERR, NAMESPACE_ERR): Added.

	* DOMImplementationRegistry.pm, DOMImplementationSource.pm:
	Statements to set |$Error::Depth| are removed since they
	are result in "uninitialized" warnings unless
	the |Message::DOM::DOMException| module is loaded earlier.
	Usually methods invoked in these methods does not
	raise any exception so that it makes no difference.

2007-07-07  Wakaba  <wakaba@suika.fam.cx>

1 package Message::DOM::DOMImplementationSource;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 push our @ISA, 'Message::IF::DOMImplementationSource';
5
6 $Message::DOM::DOMImplementationRegistry::SourceClass->{''.__PACKAGE__} = 1;
7
8 ## |DOMImplementationSource| methods
9
10 sub get_dom_implementation ($$) {
11 require Message::DOM::DOMImplementation;
12 my $r = Message::DOM::DOMImplementation->new;
13
14 my $features = _parse_features ($_[1]);
15 for my $feature (keys %$features) {
16 my $fkey = $feature;
17 my $plus = $feature =~ s/^\+// ? 1 : 0;
18 for my $version (keys %{$features->{$fkey}}) {
19 unless ($Message::DOM::DOMImplementation::HasFeature->{$feature}
20 ->{$version}) {
21 return undef;
22 }
23 }
24 }
25
26 return $r;
27 } # get_dom_implementation
28
29 sub get_dom_implementation_list ($$) {
30 require Message::DOM::DOMImplementationList;
31 my $list = bless [], 'Message::DOM::DOMImplementationList';
32 my $dom = $_[0]->get_dom_implementation ($_[1]);
33 push @$list, $dom if defined $dom;
34 return $list;
35 } # get_dom_implementation_list
36
37 sub _parse_features ($) {
38 if (defined $_[0]) {
39 if (ref $_[0] eq 'HASH') {
40 my $new = {};
41 for my $fname (keys %{$_[0]}) {
42 if (ref $_[0]->{$fname} eq 'HASH') {
43 my $lfname = lc $fname;
44 ## TODO: Feature names are case-insensitive, but
45 ## what kind of case-insensitivity?
46 for my $fver (keys %{$_[0]->{$fname}}) {
47 $new->{$lfname}->{$fver} = 1 if $_[0]->{$fname}->{$fver};
48 }
49 } elsif (ref $_[0]->{$fname} eq 'ARRAY') {
50 my $lfname = lc $fname;
51 for my $fver (@{$_[0]->{$fname}}) {
52 $new->{$lfname}->{$fver} = 1;
53 }
54 } elsif (defined $_[0]->{$fname}) {
55 $new->{lc $fname} = {''.$_[0]->{$fname} => 1};
56 }
57 }
58 return $new;
59 } else {
60 my @f = split /\s+/, $_[0];
61 ## TODO: Definition of space ???
62 ## TODO: How to parse features string into names and versions ???
63 my $new = {};
64 while (@f) {
65 my $fname = lc shift @f;
66 if (@f and $f[0] =~ /\A[\d\.]+\z/) {
67 $new->{$fname}->{shift @f} = 1;
68 } else {
69 $new->{$fname}->{''} = 1;
70 }
71 }
72 return $new;
73 }
74 } else {
75 return {};
76 }
77 } # _parse_features
78
79 package Message::IF::DOMImplementationSource;
80
81 =head1 LICENSE
82
83 Copyright 2007 Wakaba <w@suika.fam.cx>
84
85 This program is free software; you can redistribute it and/or
86 modify it under the same terms as Perl itself.
87
88 =cut
89
90 1;
91 ## $Date: 2007/07/07 05:58:11 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24