• R/O
  • SSH
  • HTTPS

sotp: Commit


Commit MetaInfo

Revision117 (tree)
Time2009-09-03 23:22:52
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- reiki/trunk/tools/make-toc.pl (revision 116)
+++ reiki/trunk/tools/make-toc.pl (revision 117)
@@ -155,7 +155,7 @@
155155 binmode(OUT, ":utf8");
156156
157157 print OUT '<?xml version="1.0"?>'."\n";
158-print OUT '<r:toc xmlns:r="http://www.cssj.jp/ns/reiki" xmlns="http://www.w3.org/1999/xhtml">'."\n";
158+print OUT '<r:toc xmlns:r="http://www.cssj.jp/ns/reiki">'."\n";
159159
160160 my $base = "$dir/content";
161161 opendir(DIR, $base);
--- reiki/trunk/htdocs/style/browse-aiueo.xsl (revision 116)
+++ reiki/trunk/htdocs/style/browse-aiueo.xsl (revision 117)
@@ -43,7 +43,7 @@
4343 <xsl:call-template name="main">
4444 <xsl:with-param name="prefix">お</xsl:with-param>
4545 <xsl:with-param name="id">o</xsl:with-param>
46- </xsl:call-template><br/>
46+ </xsl:call-template>
4747
4848 <xsl:call-template name="main">
4949 <xsl:with-param name="prefix">か</xsl:with-param>
@@ -64,7 +64,7 @@
6464 <xsl:call-template name="main">
6565 <xsl:with-param name="prefix">こ</xsl:with-param>
6666 <xsl:with-param name="id">ko</xsl:with-param>
67- </xsl:call-template><br/>
67+ </xsl:call-template>
6868
6969 <xsl:call-template name="main">
7070 <xsl:with-param name="prefix">さ</xsl:with-param>
@@ -85,7 +85,7 @@
8585 <xsl:call-template name="main">
8686 <xsl:with-param name="prefix">そ</xsl:with-param>
8787 <xsl:with-param name="id">so</xsl:with-param>
88- </xsl:call-template><br/>
88+ </xsl:call-template>
8989
9090 <xsl:call-template name="main">
9191 <xsl:with-param name="prefix">た</xsl:with-param>
@@ -106,7 +106,7 @@
106106 <xsl:call-template name="main">
107107 <xsl:with-param name="prefix">と</xsl:with-param>
108108 <xsl:with-param name="id">to</xsl:with-param>
109- </xsl:call-template><br/>
109+ </xsl:call-template>
110110
111111 <xsl:call-template name="main">
112112 <xsl:with-param name="prefix">な</xsl:with-param>
@@ -127,7 +127,7 @@
127127 <xsl:call-template name="main">
128128 <xsl:with-param name="prefix">の</xsl:with-param>
129129 <xsl:with-param name="id">no</xsl:with-param>
130- </xsl:call-template><br/>
130+ </xsl:call-template>
131131
132132 <xsl:call-template name="main">
133133 <xsl:with-param name="prefix">は</xsl:with-param>
@@ -148,7 +148,7 @@
148148 <xsl:call-template name="main">
149149 <xsl:with-param name="prefix">ほ</xsl:with-param>
150150 <xsl:with-param name="id">ho</xsl:with-param>
151- </xsl:call-template><br/>
151+ </xsl:call-template>
152152
153153 <xsl:call-template name="main">
154154 <xsl:with-param name="prefix">ま</xsl:with-param>
@@ -182,7 +182,7 @@
182182 <xsl:call-template name="main">
183183 <xsl:with-param name="prefix">よ</xsl:with-param>
184184 <xsl:with-param name="id">yo</xsl:with-param>
185- </xsl:call-template><br/>
185+ </xsl:call-template>
186186
187187 <xsl:call-template name="main">
188188 <xsl:with-param name="prefix">ら</xsl:with-param>
@@ -203,7 +203,7 @@
203203 <xsl:call-template name="main">
204204 <xsl:with-param name="prefix">ろ</xsl:with-param>
205205 <xsl:with-param name="id">ro</xsl:with-param>
206- </xsl:call-template><br/>
206+ </xsl:call-template>
207207
208208 <xsl:call-template name="main">
209209 <xsl:with-param name="prefix">わ</xsl:with-param>
--- reiki/trunk/htdocs/lib/ReikiBase/StatuteParser.pm (revision 116)
+++ reiki/trunk/htdocs/lib/ReikiBase/StatuteParser.pm (revision 117)
@@ -174,7 +174,7 @@
174174 }
175175
176176 {
177- # 本文
177+ # 例規本文
178178 package StatuteHandler;
179179 use strict;
180180 use utf8;
@@ -646,6 +646,8 @@
646646 }
647647
648648 $self->beginXML($out);
649+
650+ # 沿革
649651 my $revisions = $href;
650652 $revisions =~ s/reiki_honbun\/a/reiki_honbun\/enkaku\/k/;
651653 print $outfp
@@ -660,6 +662,7 @@
660662 my $generator = XML::LibXML::SAX::Parser->new( Handler => $handler );
661663 $generator->generate($doc);
662664
665+ # 例規本文
663666 my $statute = $href;
664667 $statute =~ s/reiki_honbun\/a/reiki_honbun\//;
665668 $statute =~ s/1\.html/001\.html/;
@@ -673,6 +676,7 @@
673676 my $handler = StatuteHandler->new();
674677 my $generator = XML::LibXML::SAX::Parser->new( Handler => $handler );
675678 $generator->generate($doc);
679+ $self->{statute} = $statute;
676680
677681 print $outfp "</r:statute>\n";
678682
--- reiki/trunk/htdocs/lib/ReikiBase/SiteParser.pm (revision 116)
+++ reiki/trunk/htdocs/lib/ReikiBase/SiteParser.pm (revision 117)
@@ -9,6 +9,7 @@
99 use Switch;
1010 use LWP::Simple;
1111 use XML::LibXML::SAX::Parser;
12+use XML::SAX::Writer;
1213 use htdocs::lib::ReikiBase::StatuteParser;
1314 use htdocs::lib::Ajino;
1415
@@ -33,6 +34,9 @@
3334 # 出力するHTMLファイルパス
3435 my $out;
3536
37+# REIKI-BASEのファイル名と新しい例規ファイル名のマッピング
38+my %file_to_file = ();
39+
3640 sub reiki_title() {
3741 return $reiki_title;
3842 }
@@ -148,6 +152,7 @@
148152 use strict;
149153 use utf8;
150154 use Text::Trim;
155+ use File::Basename;
151156 use base qw( XML::SAX::Base );
152157
153158 sub start_element {
@@ -179,9 +184,12 @@
179184 my ( $self, $elem ) = @_;
180185
181186 if ($state == 3) {
187+ # 個別例規の解析
182188 my $file = sprintf('%04d-%04d', $chapter_num, $document_num);
183189 my $parser = StatuteParser->new();
184190 $parser->parse("$out/$file.xml", $base, $href);
191+ my $orig = basename($parser->{statute});
192+ $file_to_file{$orig} = $file;
185193 }
186194 $state = 0;
187195 }
@@ -226,6 +234,40 @@
226234 }
227235 }
228236
237+{
238+ # 法令リンクの書き換え
239+ package LinkRewriteHandler;
240+ use strict;
241+ use utf8;
242+ use Encode;
243+ use File::Copy;
244+ use base qw( XML::SAX::Base );
245+
246+ sub new {
247+ my $class = shift;
248+ my $self = $class->SUPER::new(@_);
249+ return bless $self;
250+ }
251+
252+ sub start_element {
253+ my ($self, $elem) = @_;
254+ my $attrs = $elem->{Attributes};
255+ if ($elem->{Name} eq "a") {
256+ my $href = StatuteParser::attrValue( $attrs, 'href' );
257+ if ($href =~ /^([^#]+)/) {
258+ $href = $1;
259+ my $map = $file_to_file{$href};
260+ if ($map) {
261+ print "$href $map \n";
262+ $attrs->{'{}href'}->{Value} = $file_to_file{$href}.'.html';
263+ $attrs->{'{}target'}->{Value} = undef;
264+ }
265+ }
266+ }
267+ $self->SUPER::start_element($elem);
268+ }
269+}
270+
229271 # サイトを解析
230272 sub ParseSite {
231273 binmode(STDOUT, ":utf8");
@@ -260,6 +302,20 @@
260302 my $handler = TaikeiHandler->new();
261303 my $generator = XML::LibXML::SAX::Parser->new( Handler => $handler );
262304 $generator->generate($doc);
305+
306+ # リンク書き換え
307+ while ( my ( $oldFile , $file ) = each %file_to_file ){
308+ print "$oldFile to $file\n";
309+ my $toFile = "$out/$file.xml.x";
310+ open(OUT, ">$toFile");
311+ binmode(OUT, ":utf8");
312+ my $writer = XML::SAX::Writer->new(Output => *OUT);
313+ my $handler = LinkRewriteHandler->new( Handler => $writer );
314+ my $parser = XML::LibXML::SAX::Parser->new( Handler => $handler );
315+ $parser->parse_uri("$out/$file.xml");
316+ close(OUT);
317+ File::Copy::move("$out/$file.xml.x", "$out/$file.xml");
318+ }
263319 }
264320
265321 1;
\ No newline at end of file
Show on old repository browser