Blame view

parse_orcid.pl 869 Bytes
b28c1b85e   Paulo Gra├ža   Versioning source...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  #!/usr/bin/perl -w
  
  #requires packages libxml-libxslt-perl, libxml-xpath-perl, libxml-perl
  
  # (1) quit unless we have the correct number of command-line args
  $num_args = $#ARGV + 1;
  if ($num_args != 1) {
      print "
  Usage: parse_orcid.pl path/to/filename.xml
  ";
      exit;
  }
  
  
  $filename=$ARGV[0];
  unless (-e $filename) { 
      print "
  File: $filename doesn't exist!
  "; 
      exit;
  }
  
  use XML::LibXML;
  use XML::LibXSLT;
  use File::Spec;
  
  my ($volume, $directory, $file) = File::Spec->splitpath(__FILE__);
  
  XML::LibXSLT->max_depth(1000);
  
  my $xslt = XML::LibXSLT->new();
  
  my $source = XML::LibXML->load_xml(location => $filename);
  my $style_doc = XML::LibXML->load_xml(location=>$directory.'/orcid-map.xslt', no_cdata=>1);
  my $stylesheet = $xslt->parse_stylesheet($style_doc);
  my $results = $stylesheet->transform($source);
  
  print $stylesheet->output_as_bytes($results);