I have identified a few issues concerning the old XMLResults plugin, and thought others might be interested.
Character problems?
I use LSQL in various languages, and have had problems with character encoding of the generated XML. I have found that the solution is to hard-code the encoding into the header.
Solution: In the /Plugins, you have XMLResults.pm. Find the section below and edit to something like:
# -------------------------------------------------------------------
# This is run before the actual search, and is just used to print
# a proper text/xml header (as long as we do it before the text/html
# we are ok).
#
my @args = @_;
if ($IN->param('xml_feed')) {
print $IN->header('text/xml; Charset="ISO-8859-1"');
}
return @_;
}In XML, the preference is UTF-8, so really it should say: 'text/xml; Charset="UTF-8"'.
I am not an expert in character encoding but think that you cannot "trick" the content to become any kind of charset just by declaring it so. The declaration must match the content. Out of the box LSQL creates pure ASCII-US, I think.
The character encoding must also be specified in the generated XML, of course. Edit the xml_search_results.xml template. The template below is tested and works for me, and might be an inspiration for others. This template creates the more modern RSS 2.0, by the way.
<rss version="2.0">
<channel>
<title><%site_title%></title>
<link><%build_root_url%></link>
<description>xxx</description>
<language>sv</language>
<lastBuildDate><%date%> <%time%>GMT</lastBuildDate>
<copyright>xxx</copyright>
<managingEditor>xxx</managingEditor>
<webMaster>xxx</webMaster>
<%loop link_results_loop%>
<item>
<title><%Title%></title>
<link><%build_cgi_url%>/page.cgi?g=artiklar%2F<%ID%>.shtml</link>
<description><%Description%></description>
<pubDate><%Add_Date%> <%time%> GMT</pubDate>
<guid isPermaLink="false"><%build_cgi_url%>/page.cgi?g=pages%2F<%ID%>.html</guid>
</item>
<%endloop%>
</channel>
</rss>
<%time%> is fake time - I use a global (below) that inserts the current time. Strictly speaking, this is not right, of course, but otherwise one must create a timestamp field.
# Displays the current time.
my ($sec,$min,$hr) = localtime( time + ($Links::CFG->{date_offset} *3600));
return sprintf ("%02d:%02d:%02d", $hr, $min, $sec);
}
John
Character problems?
I use LSQL in various languages, and have had problems with character encoding of the generated XML. I have found that the solution is to hard-code the encoding into the header.
Solution: In the /Plugins, you have XMLResults.pm. Find the section below and edit to something like:
Code:
sub pre_search_results { # -------------------------------------------------------------------
# This is run before the actual search, and is just used to print
# a proper text/xml header (as long as we do it before the text/html
# we are ok).
#
my @args = @_;
if ($IN->param('xml_feed')) {
print $IN->header('text/xml; Charset="ISO-8859-1"');
}
return @_;
}
I am not an expert in character encoding but think that you cannot "trick" the content to become any kind of charset just by declaring it so. The declaration must match the content. Out of the box LSQL creates pure ASCII-US, I think.
The character encoding must also be specified in the generated XML, of course. Edit the xml_search_results.xml template. The template below is tested and works for me, and might be an inspiration for others. This template creates the more modern RSS 2.0, by the way.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0">
<channel>
<title><%site_title%></title>
<link><%build_root_url%></link>
<description>xxx</description>
<language>sv</language>
<lastBuildDate><%date%> <%time%>GMT</lastBuildDate>
<copyright>xxx</copyright>
<managingEditor>xxx</managingEditor>
<webMaster>xxx</webMaster>
<%loop link_results_loop%>
<item>
<title><%Title%></title>
<link><%build_cgi_url%>/page.cgi?g=artiklar%2F<%ID%>.shtml</link>
<description><%Description%></description>
<pubDate><%Add_Date%> <%time%> GMT</pubDate>
<guid isPermaLink="false"><%build_cgi_url%>/page.cgi?g=pages%2F<%ID%>.html</guid>
</item>
<%endloop%>
</channel>
</rss>
<%time%> is fake time - I use a global (below) that inserts the current time. Strictly speaking, this is not right, of course, but otherwise one must create a timestamp field.
Code:
sub { # Displays the current time.
my ($sec,$min,$hr) = localtime( time + ($Links::CFG->{date_offset} *3600));
return sprintf ("%02d:%02d:%02d", $hr, $min, $sec);
}
John