/[suikacvs]/test/html-webhacc/WebHACC/Language/XML.pm
Suika

Contents of /test/html-webhacc/WebHACC/Language/XML.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Mon Jul 21 09:15:55 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +6 -4 lines
++ ChangeLog	21 Jul 2008 09:13:35 -0000
	* cc.cgi: Old commented out code for additional
	information sections are removed.  They are now
	implemented as part of |generate_add_info_sections| method.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	21 Jul 2008 09:15:45 -0000
	* DOM.pm (generate_additional_sections): Support
	for the other additional information sections are reintroduced.
	(generate_listing_section, generate_rdf_section): Reimplemented.

	* XML.pm: Typo fixed.

	* HTML.pm: Load DOMImplementation as late as possible, to
	save possiblity that another DOM implementation can be used
	where possible.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package WebHACC::Language::XML;
2     use strict;
3     require WebHACC::Language::DOM;
4     push our @ISA, 'WebHACC::Language::DOM';
5    
6     sub new ($) {
7     return bless {}, shift;
8     } # new
9    
10     sub generate_syntax_error_section ($) {
11     my $self = shift;
12    
13 wakaba 1.4 require Message::DOM::DOMImplementation;
14 wakaba 1.1 require Message::DOM::XMLParserTemp;
15    
16     my $out = $self->output;
17 wakaba 1.3 $out->start_section (role => 'parse-errors');
18     $out->start_error_list (role => 'parse-errors');
19 wakaba 1.1
20     my $input = $self->input;
21     my $result = $self->result;
22    
23     my $onerror = sub {
24     my $err = shift;
25 wakaba 1.2 $result->add_error (line => $err->location->line_number,
26     column => $err->location->column_number,
27     type => 'xml parse error',
28     value => $err->text,
29     level => [
30 wakaba 1.1 $err->SEVERITY_FATAL_ERROR => 'm',
31     $err->SEVERITY_ERROR => 'm',
32     $err->SEVERITY_WARNING => 's',
33 wakaba 1.2 ]->[$err->severity],
34     layer => 'syntax');
35 wakaba 1.1 return 1;
36     };
37    
38     my $t = \($input->{s});
39     if ($input->{is_char_string}) {
40     require Encode;
41     $t = \(Encode::encode ('utf8', $$t));
42     $input->{charset} = 'utf-8';
43     }
44    
45     open my $fh, '<', $t;
46 wakaba 1.4 my $dom = Message::DOM::DOMImplementation->new;
47     $self->{structure} = Message::DOM::XMLParserTemp->parse_byte_stream
48 wakaba 1.1 ($fh => $dom, $onerror, charset => $input->{charset});
49 wakaba 1.4 $self->{structure}->manakai_charset ($input->{official_charset})
50 wakaba 1.1 if defined $input->{official_charset};
51    
52 wakaba 1.4 $self->{structure}->document_uri ($input->{uri});
53     $self->{structure}->manakai_entity_base_uri ($input->{base_uri});
54 wakaba 1.1
55 wakaba 1.3 $out->end_error_list;
56 wakaba 1.1 $out->end_section;
57     } # generate_syntax_error_section
58    
59     sub source_charset ($) {
60     my $self = shift;
61     return $self->input->{charset} || ($self->{structure}->owner_document || $self->{structure})->input_encoding;
62     ## TODO: Can we always use input_encoding?
63     } # source_charset
64    
65     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24