projects
/
webpac2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r1804@llin: dpavlin | 2009-04-24 18:51:47 +0200
[webpac2]
/
lib
/
WebPAC
/
Output
/
SWISH.pm
diff --git
a/lib/WebPAC/Output/SWISH.pm
b/lib/WebPAC/Output/SWISH.pm
index
60ce87f
..
ab8fc22
100644
(file)
--- a/
lib/WebPAC/Output/SWISH.pm
+++ b/
lib/WebPAC/Output/SWISH.pm
@@
-16,6
+16,7
@@
__PACKAGE__->mk_accessors(qw(
use File::Path qw/make_path/;
use Data::Dump qw/dump/;
use YAML;
use File::Path qw/make_path/;
use Data::Dump qw/dump/;
use YAML;
+use JSON;
=head1 NAME
=head1 NAME
@@
-89,6
+90,8
@@
IndexFile $dir/$database
# Croatian ISO-8859-2 characters to unaccented equivalents
#TranslateCharacters ¹©ðÐèÈæƾ® ssddcccczz
# Croatian ISO-8859-2 characters to unaccented equivalents
#TranslateCharacters ¹©ðÐèÈæƾ® ssddcccczz
+# store data into index
+PropertyNames data
# disable output
ParserWarnLevel 0
# disable output
ParserWarnLevel 0
@@
-146,6
+149,8
@@
sub add {
my $xml = qq{<xml>};
my $xml = qq{<xml>};
+ my $data;
+
foreach my $tag (@tags) {
my $r = ref $ds->{$tag}->{$type};
foreach my $tag (@tags) {
my $r = ref $ds->{$tag}->{$type};
@@
-159,8
+164,14
@@
sub add {
$xml .= qq{<$tag><![CDATA[$vals]]></$tag>};
$self->{stats}->{attr}->{$tag}++;
$xml .= qq{<$tag><![CDATA[$vals]]></$tag>};
$self->{stats}->{attr}->{$tag}++;
+
+ $data->{$tag} = $vals;
}
}
+ # serialize to JSON instead of YAML because we will loose whitespace
+ $data = to_json($data);
+ $xml .= qq{<data><![CDATA[$data]]></data>};
+
$xml .= qq{</xml>\n};
my $len = length($xml);
$xml .= qq{</xml>\n};
my $len = length($xml);
@@
-170,6
+181,8
@@
sub add {
print $fh "Path-Name: $uri\nContent-Length: $len\nDocument-Type: XML\n\n$xml" or
die "can't add $uri: $@\n$xml";
print $fh "Path-Name: $uri\nContent-Length: $len\nDocument-Type: XML\n\n$xml" or
die "can't add $uri: $@\n$xml";
+ warn "$xml\n";
+
return 1;
}
return 1;
}