--- trunk/all2xml.pl 2003/02/23 07:08:54 29
+++ trunk/all2xml.pl 2003/02/23 15:47:40 35
@@ -63,14 +63,24 @@
my %field_usage; # counter for usage of each field
+ # sort subrouting using order="" attribute
+ sub by_order {
+ return 0 if (! $config->{indexer}->{$a}->{order});
+ return 0 if (! $config->{indexer}->{$b}->{order});
- foreach my $field (keys %{$config->{indexer}}) {
+ return $config->{indexer}->{$a}->{order} <=>
+ $config->{indexer}->{$b}->{order} ;
+ }
+
+ foreach my $field (sort by_order keys %{$config->{indexer}}) {
$field_usage{$field}++;
my $swish_data = "";
my $display_data = "";
- my $line_delimiter = "";
+ my $line_delimiter;
+
+ my ($swish,$display);
foreach my $x (@{$config->{indexer}->{$field}->{isis}}) {
@@ -93,9 +103,15 @@
($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");
#print STDERR "## s: $s d: $d i: $i ## $format ##\n";
- $display_data .= $line_delimiter if ($display_data && $display_data !~ /$line_delimiter$/);
+ # what will separate last line from this one?
+ if ($display_data && $x->{append} && $x->{append} eq "1") {
+ $line_delimiter = ' ';
+ } elsif ($display_data) {
+ $line_delimiter = '
';
+ }
- my ($swish,$display) = (1,1);
+ # init vars so that we go into while...
+ ($swish,$display) = (1,1);
while ($swish || $display) {
($swish,$display) = parse_format($format,$row,$isis_i++);
@@ -112,7 +128,7 @@
# type="swish" ; field for swish
if ($s && $swish) {
if ($filter) {
-print STDERR "using filter '$filter'\n";
+#print STDERR "using filter '$filter'\n";
no strict 'refs';
$swish_data .= join(" ",&$filter($swish));
} else {
@@ -122,6 +138,10 @@
# type="display" ; field for display
if ($d && $display) {
+ if ($line_delimiter && $display_data) {
+ $display_data .= $line_delimiter;
+ undef $line_delimiter;
+ }
if ($filter) {
no strict 'refs';
$display_data .= join($delimiter,&$filter($display));
@@ -147,21 +167,13 @@
}
}
}
- if ($x->{append}) {
- $line_delimiter = ' ';
- } else {
- $line_delimiter = '
';
- }
}
#print STDERR "s_d: $swish_data\nd_d: $display_data\n" if ($swish_data);
if ($display_data) {
- # remove last
- $display_data =~ s/$line_delimiter$//;
-
- $display_data = $isis_codepage->convert($display_data) || die "Can't convert '$display_data' !";
+# $display_data = $isis_codepage->convert($display_data) || die "Can't convert '$display_data' !";
# FIX: this is removed and replaced by html tag.
#$xml .= xmlify($field."_display", $display_data);
@@ -182,7 +194,6 @@
}
if ($field_name) {
$html .= $xml_codepage->convert($field_name);
-# $html .= "-->".$field_name."<--";
}
$html .= $display_data."###\n";
}
@@ -263,6 +274,7 @@
if (my $xml = isis2xml($row,$add_xml)) {
#print STDERR "--ret-->$xml\n";
+ use bytes; # as opposed to chars
print "Path-Name: $path#".int($row->{mfn})."\n";
print "Content-Length: ".(length($xml)+1)."\n";
print "Document-Type: XML\n\n$xml\n";