Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: XMLResults plugin updates: Edit Log

Here is the list of edits for this post
XMLResults plugin updates
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.
In the /Plugins, you have XMLResults.pm. Find the section below and edit to something like:

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 @_;
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.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">

<lastBuildDate><%date%> <%time%>GMT</lastBuildDate>

<%loop link_results_loop%>
<pubDate><%Add_Date%> <%time%> GMT</pubDate>
<guid isPermaLink="false"><%build_cgi_url%>/page.cgi?g=pages%2F<%ID%>.html</guid>

<%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.

sub {
# Displays the current time.
my ($sec,$min,$hr) = localtime( time + ($Links::CFG->{date_offset} *3600));
return sprintf ("%02d:%02d:%02d", $hr, $min, $sec);


Last edited by:

gotze: Dec 28, 2004, 2:48 PM

Edit Log: