diff options
-rw-r--r-- | lib/File/Cache/Parsed.pm | 2 | ||||
-rw-r--r-- | lib/WebCoso/Common.pm | 2 | ||||
-rw-r--r-- | lib/WebCoso/XSLT.pm | 3 | ||||
-rw-r--r-- | t/test-site/src/common/fillFeed.xsl | 21 | ||||
-rw-r--r-- | t/test-site/src/feed.it.tt | 14 |
5 files changed, 20 insertions, 22 deletions
diff --git a/lib/File/Cache/Parsed.pm b/lib/File/Cache/Parsed.pm index 34f5aed..280dab7 100644 --- a/lib/File/Cache/Parsed.pm +++ b/lib/File/Cache/Parsed.pm @@ -78,6 +78,8 @@ sub get { $filename=abs_path($filename); } + return unless $filename; + return $self->{cache}{$filename} if exists $self->{cache}{$filename}; my $contents=eval {file($filename)->slurp}; diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index 30b18fe..5420063 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -86,7 +86,7 @@ sub getTitleFor { my $doc=$fc->get($doc_name); unless ($doc) { LOGWARN("No document for <$doc_name>, returning <$name>"); - return $name; + return "$name"; # force it to a string, since it might be an XML Node } my $title=$xpath->findnodes( q{/document/title}, diff --git a/lib/WebCoso/XSLT.pm b/lib/WebCoso/XSLT.pm index 40c945b..cc64cfb 100644 --- a/lib/WebCoso/XSLT.pm +++ b/lib/WebCoso/XSLT.pm @@ -24,7 +24,8 @@ sub new { $self->{xslt_proc}->register_function($NS,'dates-for', sub{$self->getDatesXML(WebCoso::Common::getDatesFor($self->{fc},@_))}); $self->{xslt_proc}->register_function($NS,'document', - sub{$self->{fc}->get(WebCoso::Common::srcXMLFor(@_))}); + sub{$self->{fc}->get(WebCoso::Common::srcXMLFor(@_)) + || XML::LibXML::Document->new('1.0','utf-8')}); $self->{xslt_proc}->register_function($NS,'message', sub{DEBUG($_[0],' ',$_[1]->get_node(0)->toString());return ''}); $self->{xslt_proc}->debug_callback(sub{DEBUG(@_)}); diff --git a/t/test-site/src/common/fillFeed.xsl b/t/test-site/src/common/fillFeed.xsl index 79c7b57..5ba0d76 100644 --- a/t/test-site/src/common/fillFeed.xsl +++ b/t/test-site/src/common/fillFeed.xsl @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform" xmlns:wc="http://webcoso.thenautilus.net/" + xmlns:f="http://webcoso.thenautilus.net/feeds" exclude-result-prefixes="wc" version="1.0"> @@ -12,29 +13,23 @@ <x:output method="xml" encoding="utf-8" doctype-public=""/> - <x:template match="/document" priority="10"> - <x:apply-imports/> - </x:template> - - <x:template match="*"> + <x:template match="f:*"> <x:copy> <x:apply-templates select="@*"/> <x:apply-templates select="*|text()"/> </x:copy> </x:template> - <x:template match="@*"> + <x:template match="@f:*"> <x:copy/> </x:template> - <x:template match="PH"> - <url><x:value-of select="."/></url> - <title><x:value-of select="wc:title-for($language,$filename,.)"/></title> - <!-- - <body> + <x:template match="f:PH"> + <f:url><x:value-of select="."/></f:url> + <f:title><x:value-of select="wc:title-for($language,$filename,.)"/></f:title> + <f:body> <x:apply-templates select="wc:document($language,$filename,.)/document"/> - </body> - --> + </f:body> </x:template> </x:stylesheet>
\ No newline at end of file diff --git a/t/test-site/src/feed.it.tt b/t/test-site/src/feed.it.tt index 398eaf3..72d20be 100644 --- a/t/test-site/src/feed.it.tt +++ b/t/test-site/src/feed.it.tt @@ -3,12 +3,12 @@ locale => 'en_US', time_zone => 'GMT' }) -%] <?xml version="1.0" encoding="utf-8"?> -<feed> +<f:feed xmlns:f="http://webcoso.thenautilus.net/feeds"> [% FOR c IN changed -%] -<item> - [% IF c.value.creation %]<created>[% df.format(c.value.creation) %]</created>[% END %] - [% IF c.value.last_change %]<last>[% df.format(c.value.last_change) %]</last>[% END %] - <PH>[% dstUriFor(c.key) %]</PH> -</item> +<f:item> + [% IF c.value.creation %]<f:created>[% df.format(c.value.creation) %]</f:created>[% END %] + [% IF c.value.last_change %]<f:last>[% df.format(c.value.last_change) %]</f:last>[% END %] + <f:PH>[% dstUriFor(c.key) %]</f:PH> +</f:item> [% END -%] -</feed> +</f:feed> |