Revision 2638
Added by harris about 19 years ago
src/perl/get_eml.pl | ||
---|---|---|
12 | 12 |
my $metacat = Metacat->new(); |
13 | 13 |
|
14 | 14 |
|
15 |
#my $url = "http://indus.nceas.ucsb.edu/knb-test/metacat"; |
|
16 |
#my $url = "http://metacat.nceas.ucsb.edu/knb/servlet/metacat"; |
|
17 |
#my $url = "http://dhcp84.nceas.ucsb.edu:8080/knp/servlet/metacat"; |
|
18 |
#my $url = $infile |
|
19 |
|
|
20 | 15 |
if ($metacat) { |
21 | 16 |
$metacat->set_options( metacatUrl => $url ); |
22 | 17 |
} else { |
... | ... | |
63 | 58 |
for (my $loop_index =0; $loop_index < $numberNodes; $loop_index++) |
64 | 59 |
{ |
65 | 60 |
$node = $nodes->item($loop_index); |
66 |
$name = $node->getFirstChild()->getNodeValue();
|
|
61 |
$name = trimwhitespace($node->getFirstChild()->getNodeValue());
|
|
67 | 62 |
|
68 | 63 |
$node = $node->getParentNode(); |
69 | 64 |
my $tempnodes = $node->getElementsByTagName("param"); |
... | ... | |
82 | 77 |
my $tempnode = $tempnodes->item($loop); |
83 | 78 |
my $paramname = $tempnode->getAttributeNode("name")->getValue(); |
84 | 79 |
if($paramname eq "dataset/title"){ |
85 |
$title = $tempnode->getFirstChild()->getNodeValue();
|
|
80 |
$title = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
86 | 81 |
} |
87 | 82 |
if($paramname eq "keyword"){ |
88 |
$keyword = $keyword.",".$tempnode->getFirstChild()->getNodeValue();
|
|
83 |
$keyword = trimwhitespace($keyword.",".$tempnode->getFirstChild()->getNodeValue());
|
|
89 | 84 |
} |
90 | 85 |
if($paramname eq "individualName/surName"){ |
91 |
$cName = $cName.",".$tempnode->getFirstChild()->getNodeValue();
|
|
86 |
$cName = trimwhitespace($cName.",".$tempnode->getFirstChild()->getNodeValue());
|
|
92 | 87 |
} |
93 | 88 |
if($paramname eq "eastBoundingCoordinate"){ |
94 |
$eBC = $tempnode->getFirstChild()->getNodeValue();
|
|
89 |
$eBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
95 | 90 |
} |
96 | 91 |
if($paramname eq "eastbc"){ |
97 |
$eBC = $tempnode->getFirstChild()->getNodeValue();
|
|
92 |
$eBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
98 | 93 |
} |
99 | 94 |
if($paramname eq "westBoundingCoordinate"){ |
100 |
$wBC = $tempnode->getFirstChild()->getNodeValue();
|
|
95 |
$wBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
101 | 96 |
} |
102 | 97 |
if($paramname eq "westbc"){ |
103 |
$wBC = $tempnode->getFirstChild()->getNodeValue();
|
|
98 |
$wBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
104 | 99 |
} |
105 | 100 |
if($paramname eq "northBoundingCoordinate"){ |
106 |
$nBC = $tempnode->getFirstChild()->getNodeValue();
|
|
101 |
$nBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
107 | 102 |
} |
108 | 103 |
if($paramname eq "northbc"){ |
109 |
$nBC = $tempnode->getFirstChild()->getNodeValue();
|
|
104 |
$nBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
110 | 105 |
} |
111 | 106 |
if($paramname eq "southBoundingCoordinate"){ |
112 |
$sBC = $tempnode->getFirstChild()->getNodeValue();
|
|
107 |
$sBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
113 | 108 |
} |
114 | 109 |
if($paramname eq "southbc"){ |
115 |
$sBC = $tempnode->getFirstChild()->getNodeValue();
|
|
110 |
$sBC = trimwhitespace($tempnode->getFirstChild()->getNodeValue());
|
|
116 | 111 |
} |
117 | 112 |
} |
118 | 113 |
|
... | ... | |
124 | 119 |
} |
125 | 120 |
|
126 | 121 |
# print "$name, $title, ($cName), ($keyword), ($eBC,$wBC,$nBC,$sBC), $url?action=read&docid=$name&qformat=knb, \n"; |
122 |
# print trimwhitespace($eBC) + " \n"; |
|
127 | 123 |
if ($eBC ne "" && $nBC ne "" && $eBC ne "0" && $nBC ne "0") { |
128 |
print "$name $eBC $nBC $url?action=read&docid=$name&qformat=knb \n";
|
|
124 |
print "$name $wBC $eBC $sBC $nBC $url?action=read&docid=$name&qformat=knb \n";
|
|
129 | 125 |
} |
130 | 126 |
} |
131 | 127 |
|
128 |
|
|
129 |
# Remove whitespace from the start and end of the string |
|
130 |
sub trimwhitespace($) |
|
131 |
{ |
|
132 |
my $string = shift; |
|
133 |
$string =~ s/^\s+//; |
|
134 |
$string =~ s/\s+$//; |
|
135 |
return $string; |
|
136 |
} |
|
132 | 137 |
#print $numberNodes; |
Also available in: Unified diff
Added a function to strip out the whitespace that was around the bounding
coordinates retrieved from metacat, and also now writing the full set of
bounding coordiantes (east,west,south,north).