/[pub]/test/html-webhacc/mkcatalog.pl
Suika

Contents of /test/html-webhacc/mkcatalog.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Nov 18 11:05:12 2007 UTC (16 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +1 -2 lines
File MIME type: text/plain
++ ChangeLog	18 Nov 2007 11:04:51 -0000
	* cc-style.css: New rules for warnings.

	* cc-todo.en.txt: Updated.

	* cc.cgi: Default to |Windows-1252| instead of |ISO-8859-1|
	for |inner_html| with external source.  Set |manakai_charset|
	attribute if possible.
	(load_text_catalog): Interpret catalog file as UTF-8.

	* error-description-source.en.xml: New errors for character
	encodings are added.

2007-11-18  Wakaba  <wakaba@suika.fam.cx>

	* error-description-source.xml: s/charset declaration/character
	encoding declaration/g, since HTML5 spec says so.

2007-11-18  Wakaba  <wakaba@suika.fam.cx>

1 #!/usr/bin/perl
2 use strict;
3 use encoding 'us-ascii', STDOUT => 'utf-8';
4
5 use lib qw[/home/httpd/html/www/markup/html/whatpm
6 /home/wakaba/work/manakai2/lib];
7
8 my $HTML_NS = q<http://www.w3.org/1999/xhtml>;
9 my $SRC_NS = q<http://suika.fam.cx/~wakaba/archive/2007/wdcc-desc/>;
10 my $XML_NS = q<http://www.w3.org/XML/1998/namespace>;
11
12 require Message::DOM::DOMImplementation;
13 my $dom = Message::DOM::DOMImplementation->new;
14
15 my $doc;
16 {
17 my $source_file_name = shift or die "$0: No source file specified\n";
18 open my $source_file, '<', $source_file_name
19 or die "$0: $source_file_name: $!";
20 require Message::DOM::XMLParserTemp;
21 $doc = Message::DOM::XMLParserTemp->parse_byte_stream
22 ($source_file => $dom, undef, charset => 'utf-8');
23 $doc->manakai_is_html (1);
24 }
25
26 my $target_lang = 'en';
27 my @node = (@{$doc->child_nodes});
28 while (@node) {
29 my $node = shift @node;
30 if ($node->node_type == $node->ELEMENT_NODE) {
31 if ($node->namespace_uri eq $HTML_NS) {
32 unshift @node, @{$node->child_nodes};
33 } elsif ($node->namespace_uri eq $SRC_NS) {
34 if ($node->manakai_local_name eq 'item') {
35 my $message;
36 for (@{$node->child_nodes}) {
37 if ($_->node_type == $_->ELEMENT_NODE and
38 $_->namespace_uri eq $SRC_NS) {
39 if ($_->manakai_local_name eq 'message') {
40 if ($_->get_attribute_ns ($XML_NS, 'lang') eq $target_lang) {
41 $message = $_;
42 next;
43 } else {
44 $message ||= $_;
45 }
46 }
47 }
48 }
49
50 my $entry = [];
51 push @$entry, $node->get_attribute_ns (undef, 'name');
52 my $level = $node->get_attribute_ns (undef, 'level');
53 $entry->[-1] = $level . ':' . $entry->[-1] if defined $level;
54 push @$entry, $node->get_attribute_ns (undef, 'class');
55 push @$entry, $message->inner_html;
56 s/\s+/ /g for @$entry;
57 print join ';', @$entry;
58 print "\n";
59 } elsif ($node->manakai_local_name eq 'catalog') {
60 print $node->text_content, "\n";
61 } else {
62 warn "$0: ", $node->manakai_local_name, " is not supported\n";
63 }
64 }
65 }
66 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24