aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2008-10-01 14:37:48 +0000
committerdakkar <dakkar@luxion>2008-10-01 14:37:48 +0000
commit0fb7944c058712bf47a5e428c063550b18dffabb (patch)
tree5a3e4c5635086ce79d6774d98b5f2a12f655836f /lib/WebCoso
parentsensible levels (diff)
downloadWebCoso-0fb7944c058712bf47a5e428c063550b18dffabb.tar.gz
WebCoso-0fb7944c058712bf47a5e428c063550b18dffabb.tar.bz2
WebCoso-0fb7944c058712bf47a5e428c063550b18dffabb.zip
some uniqs
git-svn-id: svn://luxion/repos/WebCoso/trunk@384 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso')
-rw-r--r--lib/WebCoso/Common.pm9
-rw-r--r--lib/WebCoso/XSLT.pm6
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm
index 14b85c8..f36e924 100644
--- a/lib/WebCoso/Common.pm
+++ b/lib/WebCoso/Common.pm
@@ -7,6 +7,7 @@ use XML::LibXML::XPathContext;
use DateTime;
use DateTime::Format::DateParse;
use Log::Log4perl ':easy';
+use List::MoreUtils 'uniq';
our $SRCPATH='src';
our $DSTPATH='dst';
@@ -122,7 +123,7 @@ sub getDates {
my ($fc,@docs)=@_;
my %dates;
- for my $doc_name (@docs) {
+ for my $doc_name (uniq(@docs)) {
my $doc=$fc->get($doc_name);
my ($creation_date)=map {$_->textContent}
$xpath->findnodes(
@@ -140,7 +141,7 @@ sub getTags {
my ($fc,@docs)=@_;
my %tagged;
- for my $doc_name (@docs) {
+ for my $doc_name (uniq(@docs)) {
my $doc=$fc->get($doc_name);
my @tags=map {$_->textContent}
$xpath->findnodes(
@@ -167,7 +168,7 @@ sub fromTo {
else {
push @ret,$file while $file=$iter->();
}
- return @ret;
+ return uniq(@ret);
}
{
@@ -201,7 +202,7 @@ sub keepEarliest {
push @ret,file($d,"document.$lang.$type")->stringify;
}
}
- return @ret;
+ return uniq(@ret);
}
}
diff --git a/lib/WebCoso/XSLT.pm b/lib/WebCoso/XSLT.pm
index 0d36652..ea12b38 100644
--- a/lib/WebCoso/XSLT.pm
+++ b/lib/WebCoso/XSLT.pm
@@ -23,6 +23,9 @@ sub new {
$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},@_))});
+ $self->{xslt_proc}->register_function($NS,'message',
+ sub{DEBUG($_[0],' ',$_[1]->get_node(0)->toString());return ''});
+ $self->{xslt_proc}->debug_callback(sub{DEBUG(@_)});
$self->{fc}->add_parser(qr{\.xml$} =>
sub { $self->{xml_parser}->parse_string($_[1],$_[0]) });
@@ -83,7 +86,7 @@ sub getTagsXML {
my ($docurl,$langs);
while (($docurl,$langs)=each %docs) {
my $dle=$doc->createElementNS($NS,'wc:doc');
- $dle->setAttribute('uri',$docurl);
+ $dle->setAttribute('uri',$docurl||'ERRORE');
$te->appendChild($dle);
for my $lang (@$langs) {
my $le=$doc->createElementNS($NS,'wc:lang');
@@ -114,4 +117,5 @@ sub getDatesXML {
return $doc;
}
}
+
1;