#!/usr/bin/perl

use XML::DT ;

my $filename = shift;

$f=sub{ my $r="";
  if( $int ) {
   push(@isa,$q);
   $isas = "['" .  join ("','", @isa) . "']";

   $r= "##{name => q{$title},
   url => u(q{http://alfarrabio.um.geira.pt/img_arq/$url}),
   isa => $isas,
   from => d(q{Arquivo de Imagem}),
   }
";
}
 @isa=(); $title=$int=$url=0;
 $r;
} ;

%xml=( 'foto'    => $f,
       'desenho' => $f,
       'aguarela'=> $f,
       'url'     => sub{$url=$c;""},
       'title'   => sub{$int=$v{aea};$title=$c;""},
       'isa'     => sub{push(@isa,n($c));""},
       'author'  => sub{ "" },
       'resol'   => sub{""},
       'arq'     => sub{  $c =~ s/\n{2,}/\n/g; $c},
#      '-default'=> sub{"<li> $q:$c"},
       '-outputenc' => 'ISO-8859-1',
     );

print  dt($filename,%xml);

sub n{ my $a= lc(shift) ;
  for($a){ s/^ +//; s/ +$//; s/  +/ /g; } $a; }
