371 |
$Element->{$ATOM_NS}->{entry} = { |
$Element->{$ATOM_NS}->{entry} = { |
372 |
%AtomChecker, |
%AtomChecker, |
373 |
is_root => 1, |
is_root => 1, |
|
## TODO: MUST author+ unless (child::source/child::author) |
|
|
## or (parent::feed/child::author) |
|
374 |
check_child_element => sub { |
check_child_element => sub { |
375 |
my ($self, $item, $child_el, $child_nsuri, $child_ln, |
my ($self, $item, $child_el, $child_nsuri, $child_ln, |
376 |
$child_is_transparent, $element_state) = @_; |
$child_is_transparent, $element_state) = @_; |
421 |
## NOTE: MAY |
## NOTE: MAY |
422 |
$not_allowed ||= $element_state->{has_element}->{entry}; |
$not_allowed ||= $element_state->{has_element}->{entry}; |
423 |
} elsif ({ # MAY |
} elsif ({ # MAY |
|
author => 1, |
|
424 |
category => 1, |
category => 1, |
425 |
contributor => 1, |
contributor => 1, |
426 |
}->{$child_ln}) { |
}->{$child_ln}) { |
427 |
$not_allowed = $element_state->{has_element}->{entry}; |
$not_allowed = $element_state->{has_element}->{entry}; |
428 |
|
} elsif ($child_ln eq 'author') { # MAY |
429 |
|
$not_allowed = $element_state->{has_element}->{entry}; |
430 |
|
$element_state->{has_author} = 1; |
431 |
} else { |
} else { |
432 |
$not_allowed = 1; |
$not_allowed = 1; |
433 |
} |
} |
449 |
check_end => sub { |
check_end => sub { |
450 |
my ($self, $item, $element_state) = @_; |
my ($self, $item, $element_state) = @_; |
451 |
|
|
452 |
|
if ($element_state->{has_author}) { |
453 |
|
## NOTE: There is either a child atom:author element |
454 |
|
## or a child atom:source element which contains an atom:author |
455 |
|
## child element. |
456 |
|
# |
457 |
|
} else { |
458 |
|
A: { |
459 |
|
my $root = $item->{node}->owner_document->document_element; |
460 |
|
if ($root and $root->manakai_local_name eq 'feed') { |
461 |
|
my $nsuri = $root->namespace_uri; |
462 |
|
if (defined $nsuri and $nsuri eq $ATOM_NS) { |
463 |
|
## NOTE: An Atom Feed Document. |
464 |
|
for my $root_child (@{$root->child_nodes}) { |
465 |
|
## NOTE: Entity references are not supported. |
466 |
|
next unless $root_child->node_type == 1; # ELEMENT_NODE |
467 |
|
next unless $root_child->manakai_local_name eq 'author'; |
468 |
|
my $root_child_nsuri = $root_child->namespace_uri; |
469 |
|
next unless defined $root_child_nsuri; |
470 |
|
next unless $root_child_nsuri eq $ATOM_NS; |
471 |
|
last A; |
472 |
|
} |
473 |
|
} |
474 |
|
} |
475 |
|
|
476 |
|
$self->{onerror}->(node => $item->{node}, |
477 |
|
type => 'element missing:atom|author', |
478 |
|
level => $self->{must_level}); |
479 |
|
} # A |
480 |
|
} |
481 |
|
|
482 |
## TODO: If entry's with same id, then updated SHOULD be different |
## TODO: If entry's with same id, then updated SHOULD be different |
483 |
|
|
484 |
unless ($element_state->{has_element}->{id}) { # MUST |
unless ($element_state->{has_element}->{id}) { # MUST |
1099 |
} |
} |
1100 |
$not_allowed ||= $element_state->{has_element}->{entry}; |
$not_allowed ||= $element_state->{has_element}->{entry}; |
1101 |
} elsif ({ |
} elsif ({ |
|
author => 1, |
|
1102 |
category => 1, |
category => 1, |
1103 |
contributor => 1, |
contributor => 1, |
1104 |
}->{$child_ln}) { |
}->{$child_ln}) { |
1105 |
$not_allowed = $element_state->{has_element}->{entry}; |
$not_allowed = $element_state->{has_element}->{entry}; |
1106 |
|
} elsif ($child_ln eq 'author') { |
1107 |
|
$not_allowed = $element_state->{has_element}->{entry}; |
1108 |
|
$item->{parent_state}->{has_author} = 1; # parent::atom:entry's flag |
1109 |
} else { |
} else { |
1110 |
$not_allowed = 1; |
$not_allowed = 1; |
1111 |
} |
} |