From 23b1ddb971a11119c849ffb16d8a0bc4a97bc6fa Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 2 Oct 2008 12:04:22 +0000 Subject: fixed that damn title-related error git-svn-id: svn://luxion/repos/WebCoso/trunk@388 fcb26f47-9200-0410-b104-b98ab5b095f3 --- lib/WebCoso/Common.pm | 2 ++ lib/WebCoso/XSLT.pm | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/WebCoso') diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm index f36e924..31adfbc 100644 --- a/lib/WebCoso/Common.pm +++ b/lib/WebCoso/Common.pm @@ -62,6 +62,8 @@ sub getTitleFor { my ($fc,$lang,$path,$name)=@_; DEBUG("getTitleFor($lang,$path,$name)"); + $name="$name"; # force it to a string, since it might be an XML Node + my $doc_name=$name; $doc_name=~s{\.html$}{.du.xml}; $doc_name=~s{/$}{/document.$lang.du.xml}; diff --git a/lib/WebCoso/XSLT.pm b/lib/WebCoso/XSLT.pm index ea12b38..70efc62 100644 --- a/lib/WebCoso/XSLT.pm +++ b/lib/WebCoso/XSLT.pm @@ -19,7 +19,7 @@ sub new { $self->{xslt_proc}=XML::LibXSLT->new(); $self->{xslt_proc}->register_function($NS,'title-for', - sub{WebCoso::Common::getTitleFor($self->{fc},@_)}); + sub{$self->getTitleXML(WebCoso::Common::getTitleFor($self->{fc},@_))}); $self->{xslt_proc}->register_function($NS,'tagged',sub{$self->getTagsXML}); $self->{xslt_proc}->register_function($NS,'dates-for', sub{$self->getDatesXML(WebCoso::Common::getDatesFor($self->{fc},@_))}); @@ -118,4 +118,19 @@ sub getDatesXML { } } +sub getTitleXML { + my ($self,$title)=@_; + + return $title if ref($title) + && ($title->isa('XML::LibXML::Node') + || $title->isa('XML::LibXML::NodeList')); + + my $doc=XML::LibXML::Document->new(); + my $de=$doc->createElement('paragraph'); + $doc->setDocumentElement($de); + $de->appendTextNode($title); + + return $doc; +} + 1; -- cgit v1.2.3