/[webpac2]/trunk/lib/WebPAC/Output/SWISH.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Output/SWISH.pm

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

revision 1148 by dpavlin, Thu Apr 23 13:20:51 2009 UTC revision 1149 by dpavlin, Fri Apr 24 16:58:09 2009 UTC
# Line 16  __PACKAGE__->mk_accessors(qw( Line 16  __PACKAGE__->mk_accessors(qw(
16  use File::Path qw/make_path/;  use File::Path qw/make_path/;
17  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
18  use YAML;  use YAML;
19    use JSON;
20    
21    
22  =head1 NAME  =head1 NAME
# Line 89  IndexFile $dir/$database Line 90  IndexFile $dir/$database
90  # Croatian ISO-8859-2 characters to unaccented equivalents  # Croatian ISO-8859-2 characters to unaccented equivalents
91  #TranslateCharacters ¹©ðÐèÈæƾ® ssddcccczz  #TranslateCharacters ¹©ðÐèÈæƾ® ssddcccczz
92    
93    # store data into index
94    PropertyNames data
95    
96  # disable output  # disable output
97  ParserWarnLevel 0  ParserWarnLevel 0
# Line 146  sub add { Line 149  sub add {
149    
150          my $xml = qq{<xml>};          my $xml = qq{<xml>};
151    
152            my $data;
153    
154          foreach my $tag (@tags) {          foreach my $tag (@tags) {
155    
156                  my $r = ref $ds->{$tag}->{$type};                  my $r = ref $ds->{$tag}->{$type};
# Line 159  sub add { Line 164  sub add {
164                  $xml .= qq{<$tag><![CDATA[$vals]]></$tag>};                  $xml .= qq{<$tag><![CDATA[$vals]]></$tag>};
165    
166                  $self->{stats}->{attr}->{$tag}++;                  $self->{stats}->{attr}->{$tag}++;
167    
168                    $data->{$tag} = $vals;
169          }          }
170    
171            # serialize to JSON instead of YAML because we will loose whitespace
172            $data = to_json($data);
173            $xml .= qq{<data><![CDATA[$data]]></data>};
174    
175          $xml .= qq{</xml>\n};          $xml .= qq{</xml>\n};
176    
177          my $len = length($xml);          my $len = length($xml);
# Line 170  sub add { Line 181  sub add {
181          print $fh "Path-Name: $uri\nContent-Length: $len\nDocument-Type: XML\n\n$xml" or          print $fh "Path-Name: $uri\nContent-Length: $len\nDocument-Type: XML\n\n$xml" or
182                  die "can't add $uri: $@\n$xml";                  die "can't add $uri: $@\n$xml";
183    
184            warn "$xml\n";
185    
186          return 1;          return 1;
187  }  }
188    

Legend:
Removed from v.1148  
changed lines
  Added in v.1149

  ViewVC Help
Powered by ViewVC 1.1.26