/[suikacvs]/markup/html/whatpm/Whatpm/ContentChecker.pm
Suika

Diff of /markup/html/whatpm/Whatpm/ContentChecker.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.49 by wakaba, Sat Sep 29 04:45:09 2007 UTC revision 1.50 by wakaba, Sun Oct 14 09:21:46 2007 UTC
# Line 7  require Whatpm::URIChecker; Line 7  require Whatpm::URIChecker;
7  ## ISSUE: How XML and XML Namespaces conformance can (or cannot)  ## ISSUE: How XML and XML Namespaces conformance can (or cannot)
8  ## be applied to an in-memory representation (i.e. DOM)?  ## be applied to an in-memory representation (i.e. DOM)?
9    
10    ## TODO: Conformance of an HTML document with non-html root element.
11    
12  my $HTML_NS = q<http://www.w3.org/1999/xhtml>;  my $HTML_NS = q<http://www.w3.org/1999/xhtml>;
13  my $XML_NS = q<http://www.w3.org/XML/1998/namespace>;  my $XML_NS = q<http://www.w3.org/XML/1998/namespace>;
14  my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>;  my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>;
# Line 234  sub check_document ($$$) { Line 236  sub check_document ($$$) {
236      $ElementDefault;      $ElementDefault;
237    if ($docel_def->{is_root}) {    if ($docel_def->{is_root}) {
238      #      #
239      } elsif ($docel_def->{is_xml_root}) {
240        unless ($doc->manakai_is_html) {
241          #
242        } else {
243          $onerror->(node => $docel, type => 'element not allowed:root:xml');
244        }
245    } else {    } else {
246      $onerror->(node => $docel, type => 'element not allowed:root');      $onerror->(node => $docel, type => 'element not allowed:root');
247    }    }
# Line 254  sub check_element ($$$) { Line 262  sub check_element ($$$) {
262    $self->{should_level} = 's';    $self->{should_level} = 's';
263    $self->{good_level} = 'g';    $self->{good_level} = 'g';
264    
265      $self->{pluses} = {};
266    $self->{minuses} = {};    $self->{minuses} = {};
267    $self->{id} = {};    $self->{id} = {};
268    $self->{term} = {};    $self->{term} = {};
# Line 316  sub check_element ($$$) { Line 325  sub check_element ($$$) {
325          $Element->{$nsuri}->{''} ||          $Element->{$nsuri}->{''} ||
326            $ElementDefault;            $ElementDefault;
327        $eldef->{attrs_checker}->($self, $todo);        $eldef->{attrs_checker}->($self, $todo);
328      } elsif ($todo->{type} eq 'plus') {      } elsif ($todo->{type} eq 'plus' or $todo->{type} eq 'minus') {
329        $self->_remove_minuses ($todo);        $self->_remove_minuses ($todo);
330      } elsif ($todo->{type} eq 'code') {      } elsif ($todo->{type} eq 'code') {
331        $todo->{code}->();        $todo->{code}->();
# Line 337  sub check_element ($$$) { Line 346  sub check_element ($$$) {
346      }      }
347    }    }
348    
349      delete $self->{pluses};
350    delete $self->{minuses};    delete $self->{minuses};
351    delete $self->{onerror};    delete $self->{onerror};
352    delete $self->{id};    delete $self->{id};
# Line 361  sub _add_minuses ($@) { Line 371  sub _add_minuses ($@) {
371    return {type => 'plus', list => $r};    return {type => 'plus', list => $r};
372  } # _add_minuses  } # _add_minuses
373    
374    sub _add_pluses ($@) {
375      my $self = shift;
376      my $r = {};
377      for my $list (@_) {
378        for my $ns (keys %$list) {
379          for my $ln (keys %{$list->{$ns}}) {
380            unless ($self->{pluses}->{$ns}->{$ln}) {
381              $self->{pluses}->{$ns}->{$ln} = 1;
382              $r->{$ns}->{$ln} = 1;
383            }
384          }
385        }
386      }
387      return {type => 'minus', list => $r};
388    } # _add_pluses
389    
390  sub _remove_minuses ($$) {  sub _remove_minuses ($$) {
391    my ($self, $todo) = @_;    my ($self, $todo) = @_;
392    for my $ns (keys %{$todo->{list}}) {    if ($todo->{type} eq 'minus') {
393      for my $ln (keys %{$todo->{list}->{$ns}}) {      for my $ns (keys %{$todo->{list}}) {
394        delete $self->{minuses}->{$ns}->{$ln} if $todo->{list}->{$ns}->{$ln};        for my $ln (keys %{$todo->{list}->{$ns}}) {
395            delete $self->{pluses}->{$ns}->{$ln} if $todo->{list}->{$ns}->{$ln};
396          }
397      }      }
398      } elsif ($todo->{type} eq 'plus') {
399        for my $ns (keys %{$todo->{list}}) {
400          for my $ln (keys %{$todo->{list}->{$ns}}) {
401            delete $self->{minuses}->{$ns}->{$ln} if $todo->{list}->{$ns}->{$ln};
402          }
403        }
404      } else {
405        die "$0: Unknown +- type: $todo->{type}";
406    }    }
407    1;    1;
408  } # _remove_minuses  } # _remove_minuses
409    
410    ## NOTE: Priority for "minuses" and "pluses" are currently left
411    ## undefined and implemented inconsistently; it is not a problem for
412    ## now, since no element belongs to both lists.
413    
414  sub _check_get_children ($$$) {  sub _check_get_children ($$$) {
415    my ($self, $node, $parent_todo) = @_;    my ($self, $node, $parent_todo) = @_;
416    my $new_todos = [];    my $new_todos = [];

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24