/[suikacvs]/webroot/gate/2007/html/WebHACC/Language/XML.pm
Suika

Contents of /webroot/gate/2007/html/WebHACC/Language/XML.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Sat Aug 16 07:42:20 2008 UTC (15 years, 9 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +1 -1 lines
++ ChangeLog	16 Aug 2008 07:38:01 -0000
	* cc-script.js: Support for #index- fragment identifiers.

	* cc-style.css: Prety styling for reformatted sources.
	Support for new version of manifest dump sections.

	* error-description-source.xml: Support for Whatpm::CacheManifest,
	Whatpm::CSS::SelectorsParser, Whatpm::CSS::MediaQueryParser,
	and Whatpm::CSS::Parser errors.  Support for l10n of cache
	manifest dump sections.

2008-08-16  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	16 Aug 2008 07:42:17 -0000
	* CSS.pm, CacheManifest.pm, HTML.pm, XML.pm: Use ->url attribute to
	obtain the URL of the document.

	* CacheManifest.pm (generate_structure_dump_section): It is
	now i18n'ed.  In addition, since URLs are tend to be long,
	tables for fallback entries are replaced by |dd| entries and
	paragraphs.  "No entry" message is now handled by catalog,
	rather than CSS.

2008-08-16  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/ChangeLog	16 Aug 2008 07:39:54 -0000
	* Input.pm (Subdocument new): Invoke superclass's new method
	such that |urls| attribute is initialized.

	* Result.pm (add_error): Use ->url attribute to obtain
	the URL of the document.  No longer output |text| argument,
	since all error types except for those used in the WebIDL module
	are now defined in the catalog.

2008-08-16  Wakaba  <wakaba@suika.fam.cx>

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 require Message::DOM::DOMImplementation;
14 require Message::DOM::XMLParserTemp;
15
16 $self->result->layer_uncertain ('charset');
17
18 my $out = $self->output;
19 $out->start_section (role => 'parse-errors');
20 $out->start_error_list (role => 'parse-errors');
21
22 my $input = $self->input;
23 my $result = $self->result;
24 $self->result->layer_applicable ('syntax');
25
26 my $onerror = sub {
27 my $err = shift;
28 $result->add_error (line => $err->location->line_number,
29 column => $err->location->column_number,
30 type => 'xml parse error',
31 value => $err->text,
32 level => [
33 $err->SEVERITY_FATAL_ERROR => 'm',
34 $err->SEVERITY_ERROR => 'm',
35 $err->SEVERITY_WARNING => 's',
36 ]->[$err->severity],
37 layer => 'syntax');
38 return 1;
39 };
40
41 my $t = \($input->{s});
42 if ($input->{is_char_string}) {
43 require Encode;
44 $t = \(Encode::encode ('utf8', $$t));
45 $input->{charset} = 'utf-8';
46 } else {
47 $self->result->layer_uncertain ('encode');
48 }
49
50 open my $fh, '<', $t;
51 my $dom = Message::DOM::DOMImplementation->new;
52 $self->{structure} = Message::DOM::XMLParserTemp->parse_byte_stream
53 ($fh => $dom, $onerror, charset => $input->{charset});
54 $self->{structure}->manakai_charset ($input->{official_charset})
55 if defined $input->{official_charset};
56
57 $self->{structure}->document_uri ($input->url);
58 $self->{structure}->manakai_entity_base_uri ($input->{base_uri});
59
60 $out->end_error_list;
61 $out->end_section;
62 } # generate_syntax_error_section
63
64 sub source_charset ($) {
65 my $self = shift;
66 return $self->input->{charset} || ($self->{structure}->owner_document || $self->{structure})->input_encoding;
67 ## TODO: Can we always use input_encoding?
68 } # source_charset
69
70 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24