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

XMLResults plugin updates

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

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

Last edited by:

gotze: Dec 28, 2004, 2:48 PM
Subject Author Views Date
Thread XMLResults plugin updates gotze 10456 Dec 28, 2004, 2:43 PM
Thread Re: [gotze] XMLResults plugin updates
kailew 9881 Aug 29, 2010, 10:53 AM
Thread Re: [kailew] XMLResults plugin updates
Andy 9848 Aug 30, 2010, 3:08 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9844 Aug 30, 2010, 12:55 PM
Thread Re: [kailew] XMLResults plugin updates
Andy 9837 Aug 31, 2010, 12:33 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9863 Aug 31, 2010, 12:51 AM
Thread Re: [kailew] XMLResults plugin updates
Andy 9923 Aug 31, 2010, 1:15 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9808 Aug 31, 2010, 1:23 AM
Thread Re: [kailew] XMLResults plugin updates
Andy 9880 Aug 31, 2010, 1:27 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9842 Aug 31, 2010, 2:10 AM
Thread Re: [kailew] XMLResults plugin updates
Andy 9860 Aug 31, 2010, 5:23 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9799 Aug 31, 2010, 10:38 AM
Thread Re: [kailew] XMLResults plugin updates
Andy 9750 Sep 1, 2010, 12:16 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9732 Sep 1, 2010, 11:32 AM
Thread Re: [kailew] XMLResults plugin updates
Andy 9838 Sep 1, 2010, 11:49 AM
Thread Re: [Andy] XMLResults plugin updates
kailew 9740 Sep 1, 2010, 12:08 PM
Thread Re: [kailew] XMLResults plugin updates
Andy 9769 Sep 1, 2010, 12:39 PM
Thread Re: [Andy] XMLResults plugin updates
kailew 9732 Sep 1, 2010, 2:17 PM
Post Re: [kailew] XMLResults plugin updates
Andy 9705 Sep 1, 2010, 11:39 PM
Post Re: [kailew] XMLResults plugin updates
brewt 9792 Aug 31, 2010, 2:12 PM