27 |
my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>; |
my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>; |
28 |
|
|
29 |
my $Namespace = { |
my $Namespace = { |
30 |
|
'' => {loaded => 1}, |
31 |
q<http://www.w3.org/2005/Atom> => {module => 'Whatpm::ContentChecker::Atom'}, |
q<http://www.w3.org/2005/Atom> => {module => 'Whatpm::ContentChecker::Atom'}, |
32 |
q<http://purl.org/syndication/history/1.0> |
q<http://purl.org/syndication/history/1.0> |
33 |
=> {module => 'Whatpm::ContentChecker::Atom'}, |
=> {module => 'Whatpm::ContentChecker::Atom'}, |
39 |
q<http://www.w3.org/1999/02/22-rdf-syntax-ns#> => {loaded => 1}, |
q<http://www.w3.org/1999/02/22-rdf-syntax-ns#> => {loaded => 1}, |
40 |
}; |
}; |
41 |
|
|
42 |
|
sub load_ns_module ($) { |
43 |
|
my $nsuri = shift; # namespace URI or '' |
44 |
|
unless ($Namespace->{$nsuri}->{loaded}) { |
45 |
|
if ($Namespace->{$nsuri}->{module}) { |
46 |
|
eval qq{ require $Namespace->{$nsuri}->{module} } or die $@; |
47 |
|
} else { |
48 |
|
$Namespace->{$nsuri}->{loaded} = 1; |
49 |
|
} |
50 |
|
} |
51 |
|
} # load_ns_module |
52 |
|
|
53 |
our $AttrChecker = { |
our $AttrChecker = { |
54 |
$XML_NS => { |
$XML_NS => { |
55 |
space => sub { |
space => sub { |
170 |
$AttrChecker->{''}->{'xml:base'} = $AttrChecker->{$XML_NS}->{base}; |
$AttrChecker->{''}->{'xml:base'} = $AttrChecker->{$XML_NS}->{base}; |
171 |
$AttrChecker->{''}->{'xml:id'} = $AttrChecker->{$XML_NS}->{id}; |
$AttrChecker->{''}->{'xml:id'} = $AttrChecker->{$XML_NS}->{id}; |
172 |
|
|
173 |
|
our $AttrStatus; |
174 |
|
|
175 |
|
for (qw/space lang base id/) { |
176 |
|
$AttrStatus->{$XML_NS}->{$_} = FEATURE_STATUS_REC | FEATURE_ALLOWED; |
177 |
|
$AttrStatus->{''}->{"xml:$_"} = FEATURE_STATUS_REC | FEATURE_ALLOWED; |
178 |
|
## XML 1.0: FEATURE_STATUS_CR |
179 |
|
## XML 1.1: FEATURE_STATUS_REC |
180 |
|
## XML Namespaces 1.0: FEATURE_STATUS_CR |
181 |
|
## XML Namespaces 1.1: FEATURE_STATUS_REC |
182 |
|
## XML Base: FEATURE_STATUS_REC |
183 |
|
## xml:id: FEATURE_STATUS_REC |
184 |
|
} |
185 |
|
|
186 |
|
$AttrStatus->{$XMLNS_NS}->{''} = FEATURE_STATUS_REC | FEATURE_ALLOWED; |
187 |
|
|
188 |
|
## TODO: xsi:schemaLocation for XHTML2 support (very, very low priority) |
189 |
|
|
190 |
our %AnyChecker = ( |
our %AnyChecker = ( |
191 |
check_start => sub { }, |
check_start => sub { }, |
192 |
check_attrs => sub { |
check_attrs => sub { |
195 |
my $attr_ns = $attr->namespace_uri; |
my $attr_ns = $attr->namespace_uri; |
196 |
$attr_ns = '' unless defined $attr_ns; |
$attr_ns = '' unless defined $attr_ns; |
197 |
my $attr_ln = $attr->manakai_local_name; |
my $attr_ln = $attr->manakai_local_name; |
198 |
|
|
199 |
|
load_ns_module ($attr_ns); |
200 |
|
|
201 |
my $checker = $AttrChecker->{$attr_ns}->{$attr_ln} |
my $checker = $AttrChecker->{$attr_ns}->{$attr_ln} |
202 |
|| $AttrChecker->{$attr_ns}->{''}; |
|| $AttrChecker->{$attr_ns}->{''}; |
203 |
|
my $status = $AttrStatus->{$attr_ns}->{$attr_ln} |
204 |
|
|| $AttrStatus->{$attr_ns}->{''}; |
205 |
|
if (not defined $status) { |
206 |
|
$status = FEATURE_ALLOWED; |
207 |
|
## NOTE: FEATURE_ALLOWED for all attributes, since the element |
208 |
|
## is not supported and therefore "attribute not defined" error |
209 |
|
## should not raised (too verbose) and global attributes should be |
210 |
|
## allowed anyway (if a global attribute has its specified creteria |
211 |
|
## for where it may be specified, then it should be checked in it's |
212 |
|
## checker function). |
213 |
|
} |
214 |
if ($checker) { |
if ($checker) { |
215 |
$checker->($self, $attr); |
$checker->($self, $attr); |
216 |
} else { |
} else { |
217 |
$self->{onerror}->(node => $attr, level => 'unsupported', |
$self->{onerror}->(node => $attr, level => 'unsupported', |
218 |
type => 'attribute'); |
type => 'attribute'); |
219 |
} |
} |
220 |
|
$self->_attr_status_info ($attr, $status); |
221 |
} |
} |
222 |
}, |
}, |
223 |
check_child_element => sub { |
check_child_element => sub { |
352 |
|
|
353 |
my $docel_nsuri = $docel->namespace_uri; |
my $docel_nsuri = $docel->namespace_uri; |
354 |
$docel_nsuri = '' unless defined $docel_nsuri; |
$docel_nsuri = '' unless defined $docel_nsuri; |
355 |
unless ($Namespace->{$docel_nsuri}->{loaded}) { |
load_ns_module ($docel_nsuri); |
|
if ($Namespace->{$docel_nsuri}->{module}) { |
|
|
eval qq{ require $Namespace->{$docel_nsuri}->{module} } or die $@; |
|
|
} else { |
|
|
$Namespace->{$docel_nsuri}->{loaded} = 1; |
|
|
} |
|
|
} |
|
356 |
my $docel_def = $Element->{$docel_nsuri}->{$docel->manakai_local_name} || |
my $docel_def = $Element->{$docel_nsuri}->{$docel->manakai_local_name} || |
357 |
$Element->{$docel_nsuri}->{''} || |
$Element->{$docel_nsuri}->{''} || |
358 |
$ElementDefault; |
$ElementDefault; |
478 |
my $el_nsuri = $item->{node}->namespace_uri; |
my $el_nsuri = $item->{node}->namespace_uri; |
479 |
$el_nsuri = '' unless defined $el_nsuri; |
$el_nsuri = '' unless defined $el_nsuri; |
480 |
my $el_ln = $item->{node}->manakai_local_name; |
my $el_ln = $item->{node}->manakai_local_name; |
481 |
|
|
482 |
unless ($Namespace->{$el_nsuri}->{loaded}) { |
load_ns_module ($el_nsuri); |
|
if ($Namespace->{$el_nsuri}->{module}) { |
|
|
eval qq{ require $Namespace->{$el_nsuri}->{module} } or die $@; |
|
|
} else { |
|
|
$Namespace->{$el_nsuri}->{loaded} = 1; |
|
|
} |
|
|
} |
|
483 |
|
|
484 |
my $element_state = {}; |
my $element_state = {}; |
485 |
my $eldef = $Element->{$el_nsuri}->{$el_ln} || |
my $eldef = $Element->{$el_nsuri}->{$el_ln} || |