/[pub]/test/html-webhacc/cc.cgi
Suika

Diff of /test/html-webhacc/cc.cgi

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

revision 1.41 by wakaba, Sun Mar 16 11:38:47 2008 UTC revision 1.47 by wakaba, Fri Mar 21 11:17:00 2008 UTC
# Line 173  sub check_and_print ($$) { Line 173  sub check_and_print ($$) {
173              'text/xml' => 1,              'text/xml' => 1,
174              'application/atom+xml' => 1,              'application/atom+xml' => 1,
175              'application/rss+xml' => 1,              'application/rss+xml' => 1,
176              'application/svg+xml' => 1,              'image/svg+xml' => 1,
177              'application/xhtml+xml' => 1,              'application/xhtml+xml' => 1,
178              'application/xml' => 1,              'application/xml' => 1,
179                ## TODO: Should we make all XML MIME Types fall
180                ## into this category?
181    
182                'application/rdf+xml' => 1, ## NOTE: This type has different model.
183             }->{$input->{media_type}}) {             }->{$input->{media_type}}) {
184      ($doc, $el) = print_syntax_error_xml_section ($input, $result);      ($doc, $el) = print_syntax_error_xml_section ($input, $result);
185      print_source_string_section ($input,      print_source_string_section ($input,
# Line 214  sub check_and_print ($$) { Line 218  sub check_and_print ($$) {
218      print_listing_section ({      print_listing_section ({
219        id => 'classes', label => 'Classes', heading => 'Classes',        id => 'classes', label => 'Classes', heading => 'Classes',
220      }, $input, $elements->{class}) if keys %{$elements->{class}};      }, $input, $elements->{class}) if keys %{$elements->{class}};
221        print_rdf_section ($input, $elements->{rdf}) if @{$elements->{rdf}};
222    } elsif (defined $cssom) {    } elsif (defined $cssom) {
223      print_structure_dump_cssom_section ($input, $cssom);      print_structure_dump_cssom_section ($input, $cssom);
224      ## TODO: CSSOM validation      ## TODO: CSSOM validation
# Line 684  sub print_source_string_section ($$$) { Line 689  sub print_source_string_section ($$$) {
689      print STDOUT q[<li id="$input->{id_prefix}line-1"></li>];      print STDOUT q[<li id="$input->{id_prefix}line-1"></li>];
690    }    }
691    print STDOUT "</ol></div>    print STDOUT "</ol></div>
692  <script> addSourceToParseErrorList ('$input->{id_prefix}'); </script>";  <script>
693      addSourceToParseErrorList ('$input->{id_prefix}', 'parse-errors-list');
694    </script>";
695  } # print_input_string_section  } # print_input_string_section
696    
697  sub print_document_tree ($$) {  sub print_document_tree ($$) {
# Line 853  sub print_structure_error_dom_section ($ Line 860  sub print_structure_error_dom_section ($
860    print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section">    print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section">
861  <h2>Document Errors</h2>  <h2>Document Errors</h2>
862    
863  <dl>];  <dl id=document-errors-list>];
864    push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error']    push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error']
865        unless $input->{nested};        unless $input->{nested};
866    
# Line 881  sub print_structure_error_dom_section ($ Line 888  sub print_structure_error_dom_section ($
888    }    }
889    $time{check} = time - $time1;    $time{check} = time - $time1;
890    
891    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl>
892    <script>
893      addSourceToParseErrorList ('$input->{id_prefix}', 'document-errors-list');
894    </script></div>];
895    
896    return $elements;    return $elements;
897  } # print_structure_error_dom_section  } # print_structure_error_dom_section
# Line 992  sub print_listing_section ($$$) { Line 1002  sub print_listing_section ($$$) {
1002    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl></div>];
1003  } # print_listing_section  } # print_listing_section
1004    
1005    sub print_rdf_section ($$$) {
1006      my ($input, $rdfs) = @_;
1007      
1008      push @nav, ['#' . $input->{id_prefix} . 'rdf' => 'RDF']
1009          unless $input->{nested};
1010      print STDOUT qq[
1011    <div id="$input->{id_prefix}rdf" class="section">
1012    <h2>RDF Triples</h2>
1013    
1014    <dl>];
1015      my $i = 0;
1016      for my $rdf (@$rdfs) {
1017        print STDOUT qq[<dt id="$input->{id_prefix}rdf-@{[$i++]}">];
1018        print STDOUT get_node_link ($input, $rdf->[0]);
1019        print STDOUT qq[<dd><dl>];
1020        for my $triple (@{$rdf->[1]}) {
1021          print STDOUT '<dt>' . get_node_link ($input, $triple->[0]) . '<dd>';
1022          print STDOUT get_rdf_resource_html ($triple->[1]);
1023          print STDOUT ' ';
1024          print STDOUT get_rdf_resource_html ($triple->[2]);
1025          print STDOUT ' ';
1026          print STDOUT get_rdf_resource_html ($triple->[3]);
1027        }
1028        print STDOUT qq[</dl>];
1029      }
1030      print STDOUT qq[</dl></div>];
1031    } # print_rdf_section
1032    
1033    sub get_rdf_resource_html ($) {
1034      my $resource = shift;
1035      if (defined $resource->{uri}) {
1036        my $euri = htescape ($resource->{uri});
1037        return '<code class=uri>&lt;<a href="' . $euri . '">' . $euri .
1038            '</a>></code>';
1039      } elsif (defined $resource->{bnodeid}) {
1040        return htescape ('_:' . $resource->{bnodeid});
1041      } elsif ($resource->{nodes}) {
1042        return '(rdf:XMLLiteral)';
1043      } elsif (defined $resource->{value}) {
1044        my $elang = htescape (defined $resource->{language}
1045                                  ? $resource->{language} : '');
1046        my $r = qq[<q lang="$elang">] . htescape ($resource->{value}) . '</q>';
1047        if (defined $resource->{datatype}) {
1048          my $euri = htescape ($resource->{datatype});
1049          $r .= '^^<code class=uri>&lt;<a href="' . $euri . '">' . $euri .
1050              '</a>></code>';
1051        } elsif (length $resource->{language}) {
1052          $r .= '@' . htescape ($resource->{language});
1053        }
1054        return $r;
1055      } else {
1056        return '??';
1057      }
1058    } # get_rdf_resource_html
1059    
1060  sub print_result_section ($) {  sub print_result_section ($) {
1061    my $result = shift;    my $result = shift;
1062    
# Line 1121  sub get_error_label ($$) { Line 1186  sub get_error_label ($$) {
1186    
1187    my $r = '';    my $r = '';
1188    
1189    if (defined $err->{token} and defined $err->{token}->{line}) {    my $line;
1190      if ($err->{token}->{column} > 0) {    my $column;
1191        $r = qq[<a href="#$input->{id_prefix}line-$err->{token}->{line}">Line $err->{token}->{line}</a> column $err->{token}->{column}];      
1192      if (defined $err->{node}) {
1193        $line = $err->{node}->get_user_data ('manakai_source_line');
1194        if (defined $line) {
1195          $column = $err->{node}->get_user_data ('manakai_source_column');
1196      } else {      } else {
1197        $err->{token}->{line} = $err->{token}->{line} - 1 || 1;        if ($err->{node}->node_type == $err->{node}->ATTRIBUTE_NODE) {
1198        $r = qq[<a href="#$input->{id_prefix}line-$err->{token}->{line}">Line $err->{token}->{line}</a>];          my $owner = $err->{node}->owner_element;
1199            $line = $owner->get_user_data ('manakai_source_line');
1200            $column = $owner->get_user_data ('manakai_source_column');
1201          } else {
1202            my $parent = $err->{node}->parent_node;
1203            if ($parent) {
1204              $line = $parent->get_user_data ('manakai_source_line');
1205              $column = $parent->get_user_data ('manakai_source_column');
1206            }
1207          }
1208      }      }
1209    } elsif (defined $err->{line}) {    }
1210      if ($err->{column} > 0) {    unless (defined $line) {
1211        $r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a> column $err->{column}];      if (defined $err->{token} and defined $err->{token}->{line}) {
1212          $line = $err->{token}->{line};
1213          $column = $err->{token}->{column};
1214        } elsif (defined $err->{line}) {
1215          $line = $err->{line};
1216          $column = $err->{column};
1217        }
1218      }
1219    
1220      if (defined $line) {
1221        if (defined $column and $column > 0) {
1222          $r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a> column $column];
1223      } else {      } else {
1224        $err->{line} = $err->{line} - 1 || 1;        $line = $line - 1 || 1;
1225        $r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a>];        $r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a>];
1226      }      }
1227    }    }
1228    
1229    if (defined $err->{node}) {    if (defined $err->{node}) {
1230      $r .= ' ' if length $r;      $r .= ' ' if length $r;
1231      $r = get_node_link ($input, $err->{node});      $r .= get_node_link ($input, $err->{node});
1232    }    }
1233    
1234    if (defined $err->{index}) {    if (defined $err->{index}) {
# Line 1193  sub get_node_path ($) { Line 1282  sub get_node_path ($) {
1282    while (defined $node) {    while (defined $node) {
1283      my $rs;      my $rs;
1284      if ($node->node_type == 1) {      if ($node->node_type == 1) {
1285        $rs = $node->manakai_local_name;        $rs = $node->node_name;
1286        $node = $node->parent_node;        $node = $node->parent_node;
1287      } elsif ($node->node_type == 2) {      } elsif ($node->node_type == 2) {
1288        $rs = '@' . $node->manakai_local_name;        $rs = '@' . $node->node_name;
1289        $node = $node->owner_element;        $node = $node->owner_element;
1290      } elsif ($node->node_type == 3) {      } elsif ($node->node_type == 3) {
1291        $rs = '"' . $node->data . '"';        $rs = '"' . $node->data . '"';

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.47

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24